[Article] D's Garbage Collector Problem
Chris via Digitalmars-d
digitalmars-d at puremagic.com
Thu Sep 11 04:13:36 PDT 2014
On Thursday, 11 September 2014 at 10:23:56 UTC, Rikki Cattermole
wrote:
> On 11/09/2014 10:05 p.m., Chris wrote:
>> On Thursday, 11 September 2014 at 09:37:04 UTC, ketmar via
>> Digitalmars-d
>> wrote:
>>> On Thu, 11 Sep 2014 09:29:41 +0000
>>> Chris via Digitalmars-d <digitalmars-d at puremagic.com> wrote:
>>>
>>>> he has
>>> she has. ;-)
>>
>> Japers, I wasn't sure, if it was he or she and just gambled on
>> a 50%
>> chance :) My apologies.
>>
>> PS and OT I hope Higgs will become a long term project.
>> Imagine, you
>> could combine Higgs and vibe.d. You could write your own D
>> extensions
>> for server side JS. In this way you could have projects where
>> anyone who
>> knows JS could contribute (good bye PHP), no need to know D. I
>> have a
>> test version of a LuaD + Lua Server Pages + vibe.d server.
>> Works very
>> well. JS is even more wide spread than Lua (albeit inferior as
>> a language).
>
> *starts drooling at the idea of using Jade for Cmsed*
> Would seriously fix so many problems with templates.
>
> Any chance I could get a copy of your test for LuaD + Lua
> Server Pages?
> I may want to investigate that angle as well.
Of course. Once I have a "clean" version. The first test version
is full of embarrassing hit-and-miss code, commented blocks etc.
But you could probably glue one together yourself.
1. get Open Luasp http://www.luasp.org/
2. get LuaD
3. create a vibe.d project (a normal default project will do, for
testing at least)
4. link your project to libluad and liblualsp (or lualsp.so)
In you vibe.d code route to your lua handling function
shared static this() {
[...]
router.any("*", &luaTest);
[...]
}
void luaTest(HTTPServerRequest req, HTTPServerResponse res) {
// do your lualsp / LuaD thing
}
Then you have basically a few options. Use Lua code as in
test.lua:
repuire("lualsp")
dofile_lsp("example.html")
in (Lua)D:
lua.doFile("test.lua")
or
lua.doString("require('lualsp')");
lua.doString("dofile_lsp('public/example1.html')");
or (what I do), call the functions provided by lualsp directly
extern (C) int luaopen_lualsp(lua_State *L);
extern (C) int luaL_do_lsp_file(lua_State* L,const char*
filename);
[etc....]
Or a combination of the above.
Just have a look at the various methods provided by both LuaD and
lualsp.
Note: lualsp writes to stdout, make sure you use
std.c.stdio.stdout
to grab the output. Not the one provided in Phobos' std.stdio
Excerpt from dub.json
"libs": [
"luad",
"lua5.1",
"lualsp"
],
Make sure you use Lua 5.1. LuaD (afsaik) only supports 5.1 as of
now.
It works like PHP (echo, print etc). I put this together in order
to avoid PHP in the future. Lua is a sound language and you can
expect developers to be familiar with it.
More information about the Digitalmars-d
mailing list