diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-11-06 15:13:55 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-11-06 15:15:14 -0800 |
| commit | c8ccbe5f42b5a197010b5ee95491dce5b9bbcbf4 (patch) | |
| tree | db2259bad177e558067a7cc2ea09836749242009 /lib | |
| parent | 0f17c5eb9ac4660f2f969bd1e67af42713e45eac (diff) | |
Removed utils.lua, simplified some metaprogramming stuff, added native support
for calling functions with (%a %b %c) instead of (call %a with [%b,
%c]), renamed _List -> List, _Dict -> Dict, improved example code.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/object.nom | 16 | ||||
| -rw-r--r-- | lib/os.nom | 2 |
2 files changed, 7 insertions, 11 deletions
diff --git a/lib/object.nom b/lib/object.nom index d5555df..6f6fc20 100644 --- a/lib/object.nom +++ b/lib/object.nom @@ -54,25 +54,21 @@ test: (my action %actions %body) compiles to: lua> "\ ..local fn_name = \%actions[1].stub:as_lua_id() - local \%args = table.map(\%actions[1]:get_args(), function(a) return tostring(nomsu:compile(a)) end) - table.insert(\%args, 1, \(\%me as lua id)) + local \%args = List(\%actions[1]:get_args()) + table.insert(\%args, 1, \(\%me)) local lua = LuaCode(tree.source, "class.", fn_name, " = ", \(..) what (%args -> %body) compiles to ..) for i=2,#\%actions do local alias = \%actions[i] local alias_name = alias.stub:as_lua_id() - local \%alias_args = table.map(alias:get_args(), function(a) return tostring(nomsu:compile(a)) end) - table.insert(\%alias_args, 1, \(\%me as lua id)) + local \%alias_args = List(alias:get_args()) + table.insert(\%alias_args, 1, \(\%me)) lua:append("\\nclass.", alias_name, " = ") - if utils.equivalent(\%args, \%alias_args) then + if \%args == \%alias_args then lua:append("class.", fn_name) else - lua:append("function(") - lua:concat_append(\%alias_args, ", ") - lua:append(")\\n return class.", fn_name, "(") - lua:concat_append(\%args, ", ") - lua:append(")\\nend") + lua:append(\(what (%alias_args -> %actions.1) compiles to)) end end return lua" @@ -32,7 +32,7 @@ test: (%expr for file %f in %path) compiles to (..) Lua value "\ ..(function() - local ret = _List{} + local ret = List{} for i,\(%f as lua expr) in Files.walk(\(%path as lua expr)) do ret[#ret+1] = \(%expr as lua statements) end |
