1. Re: Qbasic Stuff/Wish List
David Cuny wrote:
>I finally converted my web page generator and sent it off to Robert.
Good. I just started to write my own, now I can relax and play some
bridge instead.
> I've never gotten used to Euphoria sometimes returning a string, and
> sometimes returning a numeric code. It's jarring, and the resulting
> code moves the logic from the top of the 'while' loop and into the
> loop body:
>
> while 1 do
>
> o = gets( handle )
> if integer(o) then
> exit
> end if
>
> ...
>
> end while
I know, that's how Robert does it in the manual, but the following is
neater and also faster, because it eliminates one of the tests:
o = gets(handle)
while sequence(o) do
...
o = gets(handle)
end while
> I've coded a pair of functions to support the QBasic way of doing
> things:
>
> while not eof( handle ) do
> s = line_input( handle )
> end while
>
> eof() is used to check for an end of file. line_input() is guaranteed
> to return a sequence from the file. If it's the end of the file, it
> returns an empty sequence. It would be nice (for me, anyway) if
> Euphoria's built-in file routines worked with eof(). Robert wouldn't
> need to change their defined behaviors, either - they could still
> return -1 on EOF.
This is not just unnecessarily slow, (for the reason stated above plus
the functions overheads), it's also incorrect, because it generates a
phony line sequence.
> Finally, inspired by Python, left() and right() allow negative
> indexes. So you can write:
>
> -- return string, less 1 character off right side
> s = left(s,-1)
>
> instead of:
>
> s = s[1..length(s)-1)]
Yeah. This is the kind of thing I have been advocating for years.
Python slices have a beautiful logic behind them, but I am afraid it's
too late for us and for Robert to read the book now ...;)
> I know that it might be considered bloat, but it would be Real
> Convenient if Euphoria allowed C++ style comments:
>
> // like this
>
> in addition to "classic" comments
>
> -- like this
For heaven's sake, David, why?!
But _block_ comments are are still on my wishlist, though they have
drifted towards the bottom of it now - I created macros in all my
editors to do them with a single keystroke anyway.
jiri