Re: [Flightgear-devel] Nasal advice...

2005-04-24 Thread Erik Hofman
Andy Ross wrote:
More not-quite-FlightGear subject matter ahead.  But I need advice:
Nasal needs a character constant syntax.  That is, the ability to
write an ASCII charactrer as a numerical constant.  In C/C++, you use
single quotes to do this (e.g. the token 'A' is just a synonym for the
integer value 65).
   (Brief background: I just added the ability to read and write
   individual bytes in a string with the [] operator, just like you
   can for elements of the vector.  Thus the need for character
   constants to which to compare those bytes.)
But Nasal can't do that, because it already uses single quotes for
unescaped strings, something that will be really useful in the regular
expression interface I am putting together.
At first I was thinking using #'A' since # represents a number already 
in most cases, but then again; how about just using a new function?

Erik
___
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d


RE: [Flightgear-devel] Nasal advice...

2005-04-24 Thread Vivian Meazza
Andy Ross wrote

 
 So anyway, which of the following are good/bad choices for a character
 constant syntax:
 
`A`   @A   $A   %A   A   @A   $A   %A   A   cA

Anything but `A` - I'm bound to misread that in the future sometime. I
favour a function.

Regards,

Vivian



___
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d


Re: [Flightgear-devel] Nasal advice...

2005-04-24 Thread Jim Wilson
 From: Andy Ross
 
snip

 Perl and Python get away without having character constants at all.
 They do string indexing by making substrings at runtime.  But
 substrings are garbage-collected, which makes them a little expensive.
 I don't want to thrash the heap just to iterate through a single
 string (the lack of the ability to do this really annoys me in perl).
 So basically, I can't just emulate C, perl or python here, I need to
 invent a new syntax.
 

You could perhaps extend the w3 named entity syntax which uses  as left 
delimiter and 
; as right.  So that A; would equal #65;  

But maybe the ; would be a parsing headache...

Best regards,

Jim



___
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d


Re: [Flightgear-devel] Nasal advice...

2005-04-24 Thread Andy Ross
Erik Hofman wrote:
 At first I was thinking using #'A' since # represents a number
 already in most cases, but then again; how about just using a
 new function?

Just to be clear, there is a function to do this already: strc()
returns the value of the Nth byte in a string.  The index
defaults to zero, so you can write strc(A) to get 65 right now.
With the new syntax, you can even write A[0] to do the same.

The problem (a minor one, admittedly) is that those are runtime
operations that have to generate code.  What I really want is the
ability to just write the number 65 using some simple key
combination involving the character A.  :)

I think I'm leaning towards back quotes, but I'm still not sure.
Using backquotes has always meant something special, and
character constants aren't very special...

Andy

___
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d