Re: [Flightgear-devel] Re: Nasal advice...
Melchior FRANZ wrote: Wouldn't work in my case. Would only make it even less elegant. Then I better stick with this: Only if you don't want to write your own functions (in which case every feature I don't want to support is going to be inelegant and you'll never win until I turn Nasal into another monstrosity like perl). Write a function to turn a number into a 4 byte string (or more, you technically can do up to 6 in an IEEE double). Write a function to set or get a bit in a string. Write a function to turn a 4 byte string into a number. Compose them appropriately to set bits in numbers. Probably four lines of code, and you can do: setprop(name, setbit(getprop(name), 2)); Look more elegant than bit twiddling to my eyes... The problem is that in joystick files I don't have the possibility to initialize bit fields or define bit operations. Stick the bit stuff (which clearly isn't joystick-dependent) in globals.nas. Problem solved. Once again, bit operations on floating point numbers won't work like you want them to. Think about implementing sign extension in shifts, or rotations, or even (off the top of your head) tell me how many bits are retained when you left shift. Andy ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Re: Nasal advice...
I wrote: Write a function to [...]. Compose them appropriately to set bits in numbers. Probably four lines of code, Turns out it's three lines of code: n2s = func(n) { var s = buf(6); setfld(s, 0, 48, n); return s; } getbit = func(n, b) { getfld(var s = n2s(n), b, 1) } setbit = func(n, b) { setfld(var s = n2s(n), b, 1); return fld(s, 0, 48); } These guys provide 48 bits in a number. You can theoretically stretch that to 53, but it requires some fiddling of the doubles that I don't want to promise yet. :) Obviously you can't use this yet, because I haven't written the underlying bit functions. But hopefully this will address the elegance issues. Andy ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
Re: [Flightgear-devel] Re: Nasal advice...
Melchior FRANZ wrote: Alternatively, take TeX's syntax: `\A ... for extra geek points. ;-) If you are really seeking for ggek points: $eq1 = 2 * $val; $eq2 = -7 + $val; test_val = (1 (3 + #-3 * ${want_eq1 ? $eq1 : $eq2}); :-) Erik ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d
RE: [Flightgear-devel] Re: Nasal advice...
Melchior FRANZ * Vivian Meazza -- Sunday 24 April 2005 20:41: Andy Ross wrote `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. Hmm ... and I changed my mind and would now find `A` a reasonable choice. :-P You would change your mind - ask 3 programmers and get 4 answers :-). ` and ' *are* different characters. They *have* to look different, otherwise they are pointless. Every Unix shell considers them functionallly different. Nobody has complained )to me) so far. If a font doesn't show a clear difference, then it's the font that is broken, not the glyph. And then, with proper syntax coloring a character and a string constant have different colors. Alternatively, take TeX's syntax: `\A ... for extra geek points. ;-) Nothing wrong with the font - it's the reader that's broken. I suppose you work on the basis of why make it difficult when with a bit of extra effort you can make it impossible? Regards, Vivian ___ Flightgear-devel mailing list Flightgear-devel@flightgear.org http://mail.flightgear.org/mailman/listinfo/flightgear-devel 2f585eeea02e2c79d7b1d8c4963bae2d