A few little questions

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

A few little questions

Reuben Thomas-3
Some things that came up in a bout of hacking over Christmas:

1. Why can't inner functions be defined for local values? I mean that:

function y ()
  function f() ...
  end
end

works, but

function y ()
  local f = function g()
              function h()
	      end
	    end
end

doesn't. By the way, provided f() in the first example above doesn't clash
with any other global, you can use inner functions of this sort to get
mutual recursion in "local" functions (albeit not anonymous functions).

This seems like an area of Lua that needs to be sorted out, as it's a bit
un-uniform.

2. It looks ugly on Windows PCs to use `' around tokens in error messages,
because these characters tend not to be symmetrical quotes as they usually
are under UNIX. Using '' would be a better compromise.

3. I miss having exceptions! (Though maybe they can be coded up using call
and error?)

4. In the manual it says 'Lua code can "catch" an error using the function
call': this is ambiguous. [Sorry, I can't quite find the bit of the manual
this referred to now]

5. What are the "syntactic reasons" for forcing break and return to occur at
the end of a block? (Sorry if this was already answered, but I couldn't find
it; a message number would suffice!)

-- 
http://sc3d.org/rrt/ | impatience, n.  the urge to do nothing


Reply | Threaded
Open this post in threaded view
|

nocoes-3.1.pdf

YutakaUeno
I was wondering if somebody have a document
"introductory programming manual" translated into English.
http://www.tecgraf.puc-rio.br/lua/ftp/nocoes-3.1.pdf

I tried a machine translation by AltaVista, into English.
The result is pretty bad. ( without chapter10, library reference )
http://www.etl.go.jp/~ueno/lua/docj/lua-tut2.txt

Actually, what I need is a Japanese version. It is ok for an intermediate
language to translate into Japanese, and I stopped working on English.
But I would be happy to have another better version in English, 
or this manuscript corrected.

---ueno

Reply | Threaded
Open this post in threaded view
|

Re: A few little questions

Peter Shook-2
In reply to this post by Reuben Thomas-3
On Wed, Jan 10, 2001 at 08:57:29PM +0000, Reuben Thomas wrote:
> Some things that came up in a bout of hacking over Christmas:
> 
> 1. Why can't inner functions be defined for local values? I mean that:
> 
> function y ()
>   function f() ...
>   end
> end
> 
> works, but
> 
> function y ()
>   local f = function g()
>               function h()
> 	      end
> 	    end
> end
> 

Check out The Complete Syntax of Lua in the back of the Lua manual and you'll
see that you need to delete the 'g', like so

  function y ()
    local f = function()
                function h()
  	      end
  	    end
  end


Cheers,

- Peter

Reply | Threaded
Open this post in threaded view
|

Re: A few little questions

Luiz Henrique de Figueiredo
In reply to this post by Reuben Thomas-3
>5. What are the "syntactic reasons" for forcing break and return to occur at
>the end of a block? (Sorry if this was already answered, but I couldn't find
>it; a message number would suffice!)

One reason is that semicollons are optional and thus render code such as
	return
	a()
ambiguous, because it is parsed as "return a()".
--lhf