lua-users home
lua-l archive

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


On Fri, Jun 23, 2006 at 02:10:26PM -0400, Aaron Brown wrote:
> By the way, if you've never seen the 'fun "foo" "bar" "baz"'
> syntax before, here's an example of it:
> 
>  > function fun(s)
>  >>   print(s)
>  >>   return fun
>  >> end
>  > fun "foo" "bar" "baz"
>  foo
>  bar
>  baz

I thought that would be pretty useful, but playing around with it, it
seems string literals are more special than numbers:

> function p(s) print(s); return p; end
> p "hi" "bye" "gone"
hi
bye
gone
> p "hi" 2 "gone"
stdin:1: unexpected symbol near '2'
> p "hi" (2) "gone"
hi
2
gone
> p 2
stdin:1: '=' expected near '2'


I thought that both numbers and strings were literals, but after some
reading through the manual, I see there is only one kind of literal, a
literal string.

I guess this is a legacy of lua as data description language? Would
things break terribly if any of {}, "", and Number could be passed as an
argument expression without parentheses?

Cheers,
Sam