Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED
- From: Patrick Masotta <masottaus@xxxxxxxxx>
- To: luajit@xxxxxxxxxxxxx
- Date: Thu, 21 Jun 2012 08:04:53 -0700 (PDT)
I agree the patch is not "necessary" but it adds the beauty of simmetry and
simplicity
local var_01 = ffi.new("char[50]", "default value for var_01" )
local var_01_desc = ffi.new("char[?]", 0, "This is the var_01
description\nvar_01 is used for...\nvar_01 allowed values are...");
the former chunk does not create aux variables and looks far better than
local var_01 = ffi.new("char[50]", "default value for var_01" )
local str_01 = "This is the var_01 description\nvar_01 is used for...\nvar_01
allowed values are...");
local var_01_desc = ffi.new('char [?]', #str_01+1, str_01)
mostly if you are a LUA newcomer and/or you have to declare 100s of
variables....
(just my opinion)
>
> But I'd say the patch is not really necessary, the Lua
> wrapper/helper is a better option. I'd be surprised if
> LuaJIT doesn't do a good job of optimizing that away anyway
> (be easy enough to check a dump output to check).
>
> - Claire
>
>
>
Other related posts:
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Peter Cawley
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Robert G. Jakabosky
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Michal Kottman
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Paulo Matias
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Robert G. Jakabosky
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Robert G. Jakabosky
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Robert G. Jakabosky
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Claire Lewis
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED - Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Claire Lewis
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Javier Guerra Giraldez
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Coda Highland
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Adam Strzelecki
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Coda Highland
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Geoff Leyland
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Geoff Leyland
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Dimiter 'malkia' Stanev
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Claire Lewis
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Sean Conner
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- dcharno
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Craig Barnes
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Adam Strzelecki
- » Re: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- Patrick Masotta
- » RE: newbie: local buf = ffi.new("char[?]", "HELLO WORLD") fails PROBABLY SOLVED- William Adams