Re: EUPHORIA Digest - 19 Jun 1998 to 20 Jun 1998 (#1998-34)

new topic     » topic index » view thread      » older message » newer message

At 12:00 AM 6/21/98 -0400, Automatic digest processor wrote:
>Date:    Sat, 20 Jun 1998 08:02:45 -0400
>From:    Robert B Pilkington <bpilkington at JUNO.COM>
>Subject: Re: EUPHORIA Digest - 18 Jun 1998 to 19 Jun 1998 (#1998-33)
>
>For the purposes of what was going on, a binary file, I don't know if
>gets() would work as well

It will, but nothing would be changed. In particular, the end-of-line
sequence "\r\n" is left as is, not changed to a mere "\n".

>>- can we have the following two functions built-in (so that they
>>execute
>>  faster)?

See below.

>>- can we have left-to-right processing of && and ||? (still, 'and' and
>>'or' will examine all operands)
>
>Huh? Don't understand.

function func_a() puts(1, "test a\n") return 1 end function
function func_b() puts(1, "test b\n") return 1 end function

if func_a() or func_b() then    -- 3 statements: "test a\ntest b\ndone\n"
    puts(1, "done\n")           -- available in current version
end if

if func_a() || func_b() then    -- takes 3 statements: "test a\ndone\n"
    puts(1, "done\n")           -- but not available in current version
end if                          -- note that func_b() is NOT called

integer x
x = func_a()                    -- takes 7 statements plus a declaration
if not x then                   -- prints "test a\ndone\n"
    x = func_b()                -- available in current version
end if
if x then
    puts(1, "done\n")
end if

The && operator works left to right, stopping as soon as a 0 (false) is
found [and thus returning 0 (false)], or if none of the expressions
evaluate to 0 (false), a 1 (true) is returned. The and keyword does the
same but it evaluates all operands.

The || operator works left to right, stopping as soon as a non-0 (true) is
found [and thus returning 1 (true)], or if all of the expressions evaluate
to 0 (false), a 0 (false) is returned. The or keyword does the same but it
evaluates all operands.

It would be possible then to say things like:
-- common after x = gets(f)
if sequence(x) && length(x) && x[length(x)] = '\n' then
                                            -- took 7 statements, now 3
    x = x[1..length(x) - 1]                 -- else will bomb out with x = {}
end if

-- rtrim
while length(x) && x[length(x)] = ' ' do    -- took 6 statements
    x = x[1..length(x) - 1]
end while

if y && z && x / y < w / z then             -- took 7 statements, now 3
    printf(1, "%d/%d < %d/%d\n", {x, y, w, z})
end if

if y && z && x / y < w / z then             -- took 13 statements, now 5
    printf(1, "%d/%d < %d/%d\n", {x, y, w, z})
else
    printf(1, "either %d or %d is 0, or %d/%d >= %d/%d\n", {y,z,x,y,w,z})
end if

>>- can we have ?: operator (or immediate if), like
>>    a = b ? c : d
>
>Huh? Understand even less. Euphoria is supposed to be readable. And
>what's wrong with the if method? I understand it, everybody understands
>it.

Plain if method takes 5 statements and you have to write 'a' twice (what if
you are using thisisaverylongvariablename? don't tell me to copy and paste!!).

Also if you do postprocessing, e.g. use as argument, do something after it
(a = ((b ? c : d) + (e ? f : g)) * h), it will save more statements.

Yes, I am still complaining about the very low 300 statements limit for a
poor guy like me. Registered users (including Ralf) please keep your mailer
from replying. I don't want to start a flame war. smile

>>global function getsc(file_number fn, file_number len)
>>global function filesize(file_number fn)
>
>What's with these? Are they meant for showing us useful functions
>(filesize is useful....), or did you want them added to file.e?
>(Probably just code for the sake of code, but I'd figure I'd ask...)

I want them added because including a standard .e costs no statements (or
is that 'include' counted as one???)

I figure that using a built-in getsc and probably get and value, would be
best. The get, being a C function (Euphoria is in Watcom C or is that C++?)
would then allow ungetch() after reading an invalid token, thus correcting
(?) the problem of reading "12x" as GET_SUCCESS.

I don't ask for an inline assignment because that would kill Euphoria's
clarity. I do however have a suggested syntax: := (taken from Pascal) --
since <- is used in "if a<-5 then".

a := 8  -- will do the same as a = 8

s = {}
while (c = getc(f)) >= 0 do -- does not work, c is COMPARED not assigned
    s = s & c
end while

s = {}
while (c := getc(f)) >= 0 do -- understood
    s = s & c
end while

s = {} -- current way
c = getc(f)
while c >= 0 do
    s = s & c
    c = getc(f) -- costs one extra statement *in this example*
end while

But of course, using
    s = getsc(f, filesize(f))
would use only one statement AND does not need c to be declared. smile

>Date:    Sun, 21 Jun 1998 10:59:15 -0700
>From:    Monty King <boot_me at GEOCITIES.COM>
>Subject: re.
>
>    Reguarding adding those routines to Euphoria, I'd like to say, well if
>you keep wanting to change things, then write some routines to change things
>the way you like it!  It is possible to write in those routines yourself if
>you want to.  I like Euphoria the way it is, syntax-wise.

If you can suggest me, *without paying,* how to get Euphoria to increase
the 300 line limit, I will stop complaining.

By "without paying", you can maybe point me to a contest with free entry
fee, that has a prize of Euphoria complete edition (but I'm not good at
making graphics postcards), or anything like that.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu