[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string[], doesn't exist?
- From: Sam Roberts <sroberts@...>
- Date: Fri, 23 Jun 2006 13:24:44 -0700
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