lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 25.04.2014 16:05 schröbte Coroutines:
On Fri, Apr 25, 2014 at 6:40 AM, Gavin Wraith <gavin@wra1th.plus.com> wrote:

As RISC OS stands rather
isolated among operating systems, so RiscLua has more freedom to go
its own way. Thus (in the environment of the riscos library)
"![addr] = word, ?[addr] = byte and $[addr] = string" pretty much
correspond to BBC Basic's "!addr% = word%, ?addr% = byte% and
$addr% = string$".

Andrew was asking about usage data in another reply to this thread,
have you (all?) had much trouble allowing these characters in
identifiers?  Has it caused serious confusion anywhere?

I said in another message I'd hoped these would not be allowed at the
beginning of an identifier (my preference, though).



I have built my own build tool around a modified Lua 5.1 that allows $ in identifiers, but those identifiers are used for a specific purpose: They are external programs that are looked up in PATH before the chunk runs, so that the build tool can try another build script if not all required programs are available. The code looks nice, IMHO (small example attached). I haven't had any problems so far, but I sort of rely on the fact that my $-identifiers are guaranteed to be separate from normal Lua identifiers.

Philipp


#!/usr/bin/env buildsh

local cflags = make.qw[[
  -Wall -Wextra -Wfatal-errors -fno-common -Os -fpic
]]

local luainc = make.assert_file( "/usr/include/lua5.1/lua.h",
                                 "/usr/local/include/lua51/lua.h",
                                 "/usr/include/lua.h",
                                 "/usr/local/include/lua.h" )
luainc = "-I" .. luainc:dirname()

local sources = { "simple.c" }
local ofiles = make.gsub( sources, "%.c$", ".o" )

local function build()
  for i, cf in ipairs( sources ) do
    $gcc{ cflags, luainc, "-c", "-o", ofiles[ i ], cf }
  end
  $gcc{ cflags, "-shared", "-o", "simple.so", ofiles, apr_ldflags }
end

return {
  build = build,
}