1. To David, Ralf (3), Lewis, Joe (2),

At 12:00 AM 6/24/98 -0400, Automatic digest processor wrote:
>Date:    Tue, 23 Jun 1998 10:41:07 -0700
>From:    "Cuny, David" <David.Cuny at DSS.CA.GOV>
>Subject: Andy vs. 300 lines

    Nice subject, David, nice subject. I like it smile

>Date:    Tue, 23 Jun 1998 21:01:07 +0200
>From:    Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL>
>Subject: Re: EUPHORIA Digest - 21 Jun 1998 to 22 Jun 1998 (#1998-36)
>
>function file_length(sequence fname)
>sequence dirinfo
>    dirinfo = dir (fname)
>    if length(dirinfo) then
>        return dirinfo[1][D_SIZE]
>    else
>        return -1    -- File not found!
>    end if
>end function

    This version takes less statements.

    function file_length(sequence fname)
    sequence dirinfo
        dirinfo = dir (fname)
        if length(dirinfo) then
            return dirinfo[1][D_SIZE]
        end if
        return -1    -- File not found!
    end function

>>a and b = (a * b) != 0
>>a or b  = ((a != 0) + (b != 0)) != 0
>
>I thought you wanted optimization.
>Plus with short circuit this too wouldn't work. They would be broken
>forever, unless you do something like this:

    Oops, I forgot '=' does have two meanings in Euphoria smile

    Replace:
        a and b     ('and' here means COMPLETE and -- the one we have now)
    with:
        (a * b) != 0

    and replace:
        a or b      ('or' here means COMPLETE or -- the one we have now)
    with:
        ((a != 0) + (b != 0)) != 0

    while you canNOT substitute expressions (not functions) for the short-
    circuit operands.

    The above replacements (using +, *, and !=) do not have 'and's or
    'or's, it works now and forever. smile

>Its a workaround needed for existing programs when we optimize euphoria, so
>a few programmers who didn't want to optimize it themselves get a 0.0001 %
>better optimized code.. ???!!!??

    You just need to replace the and with * and or with +, as above.

    Try it!

>you don't need to type a lot. (you only need to track a couple of bugs down
>for the next 20 hours.. blink)

    I had that enjoyable moments for only a few times out of so many
    programs I had in C++. Really enjoyable, it's much better than one
    you get when debugging your own Assembly virus code blink

>-- Voila!
>elsif y[1] = GET_SUCCES and integer(y[2]) then if y[2] >= 1 and y[2] <=
>length(x) the if x[y] < 31 then
>    puts (1, "Thank you.\n")
>end if end if else
>    puts (1, "That is not a valid month!\n\n")
>end if
>-- Was that so hard ?

    WRONG.

    (1) Syntax: GET_SUCCES - unknown identifier [fixed to GET_SUCCESS]
    (2) Syntax: the - unknown command [fixed to then]
    (3) Logic: If y[1] = GET_SUCCESS and integer(y[2]) but y[2] <= 0 or
        y[2] > length(x) or x[y] >= 31 then your version puts nothing.
        Original version puts "That is not a valid month!\n\n". [need
        manual fix]

    I doubt you understand what I mean by proper alignment, Ralf.

    Your code is seen by ex as:

    elsif y[1] = GET_SUCCESS and integer(y[2]) then
        if y[2] >= 1 and y[2] <= length(x) then
            if x[y] < 31 then
                puts (1, "Thank you.\n")
            end if  -- no else here!!
        end if      -- no else here either!!
    else
        puts (1, "That is not a valid month!\n\n")
    end if

    To make it work as expected you will need 13 statements unless
    you make functions.

    elsif y[1] = GET_SUCCESS and integer(y[2]) then
        if y[2] >= 1 and y[2] <= length(x) then
            if x[y] < 31 then
                puts (1, "Thank you.\n")
            else
                puts (1, "That is not a valid month!\n\n")
            end if
        else
            puts (1, "That is not a valid month!\n\n")
        end if
    else
        puts (1, "That is not a valid month!\n\n")  -- repeated THRICE
    end if

    Now that I can hopefully assume you understand a bit about this,
    how about your version of short-circuited 5-levels-of-'or' with
    elsif another 4-levels-of-'or' and finally an else part?

    Short circuit code (e() only called if a() to d() are all 0, etc):
    if a() or b() or c() or d() or e() then
        puts (1, "Either a, b, c, d or e is true\n")
    elsif f() or g() or h() or i() then
        puts (1, "Neither a, b, c, d nor e is true,\n" &
                 "but either f, g, h or i is true\n")
    else
        puts (1, "a, b, c, d, e, f, g, h and i are all false\n")
    end if

    You will need to convert the above 7 statements to at least 21
    statements.

    If you can figure what those 21 are, let's try a more difficult
    puzzle:
    if (a() or b()) and ((c() or d()) and e()) then
        puts (1, "First condition works\n")
    elsif (f() and g()) or (h() and i()) then
        puts (1, "First condition fails, second condition works\n")
    else
        puts (1, "Both conditions fail\n")
    end if

    Order of evaluation is still a to i, possibly skipping something.
    You need... um, MANY statements smile

>-- Also to avoid using else and elsif: (if you there clumbsy)
>
>for doesntmatter = 1 to 1 do
>
>    if this and that then
>        do (that)
>        exit
>    end if
>    if that and this then     -- elsif
>        do (this)
>        exit
>    end if
>    do (this and that)    -- else
>
>end for

    Great workaround Ralf! Just how few of my 300 statements are
    left there? blink

>A file length function is not a trivial building block! Don't you agree ?

    Why do they have a file length function in Assembly? (func #23)

>function perl_gets (integer fh, integer eol)
>sequence ret
>    ret = {getc(fh)}
>    while ret[length(ret)] != -1 and ret[length(ret)] != eol do
>        ret = append(ret, getc(fh)
>    end while
>    if ret[length(ret)] = -1 then
>        return ret[1..length(ret)-1]
>    else
>        return ret
>    end if
>end function
>
>Another problem solved in 10 easy to write, easy to read, fast executed
>lines.

    Twelve.

    Missing ) on statement 5 "ret = append(ret, getc(fh)"

    Can save four statements by changing the last if block to:
        return ret[1..length(ret) - (ret[length(ret)] = -1)]

>'end if' are not statements:
>
>if this () and this ()  then
>    do (that)
>end if
>
>Are 1) if-block 2) this () 3) this () 4) do (that) statements
>Thus 4 statements.
>End if is part of the if-statement.

    Robert Craig: Please define statement count.

    (It should be easy to have a code in ex/exw to do this. You can
    make a constant always accessible and will tell, as an atom, how
    many statements are in the current file, e.g. STATEMENT_COUNT.
    You can also have another constant for "am I shrouded"...)

>Use interrupts. See the stuff about 'trivial building blocks again'
>And there is now a library for this as well.

    Great, use interrupts! You *can* access files using interrupts.
    You can get dir() using interrupts. You can do graphics with
    interrupts. Why bother having an Euphoria statements for them?
    Please, tell me!! smile

>Perl wins at this point, I'm afraid.

    Actually, I prefer Euphoria. Yes Rob you should consider that. smile

    I like
    {junk, variable} = gets(0)

    A further enhancement that will break Euphoria's rules:
    {1, variable} = gets(0) -- 1 means skip one thing
    -- each element can be an integer or a variable

    {1, a, -1, b, 1, c, -2, d, 1} = {1, 2, 3, 4}
    -- that means: a = 2, b = 2, c = 4, d = 3
    -- too complicated?
    --   1 2 3 4
    --  ^           pointer starts at beginning
    --              {1,
    --   1 2 3 4
    --    ^         pointer advances one to the right
    --              a,
    --   1 2 3 4    get a, advance one by default
    --     -^       (a = 2)
    --              -1,
    --   1 2 3 4    pointer moves back by one element
    --    ^
    --              b,
    --   1 2 3 4    get b
    --     -^       (b = 2)
    --              1,
    --   1 2 3 4    advance one
    --        ^
    --              c,
    --   1 2 3 4    get c
    --         -^   (c = 4)
    --              -2,
    --   1 2 3 4    back two
    --      ^
    --              d,
    --   1 2 3 4    get d
    --       -^     (d = 3)
    --              1}
    --   1 2 3 4    advance one
    --          ^
    -- to check if the expression is correct do not compare lengths
    -- just check if the pointer never moves outside leftmost..rightmost
    -- and ends after the last element

>>Perl allows command output capturing, as in
>
>1) I don't  understand the code, way to unreadable (point to Euphoria)
>2) Catching input and output is possible:

    I meant, output of a system() call is returned as a string.

    And you can still access the errorlevel.

    Yes you can capture Euphoria's I/O but not other programs' that are
    executed by system().

    Example:
    a = capture("dir /a /one /v") -- under win95's dos
    -- parse a, it's already sorted and has long file names

    b = capture("chkdsk")
    -- parse b, it's got the disk free and size

    c = capture("copy /y a.e temp.e") -- /y means overwrite...
    if find("1 file(s) copied", c) then
        -- file has been copied
    else
        printf(2, "Error copying file\n%s", {c})
        -- e.g. output:
        --  Error copying file
        --  File not found - a.e
        --          0 file(s) copied
    end if

    It's (going to be) very handy.

>You don't know that, ever tried setting files = 1000000000 and opening half
>of the files.
>But true, the 12 is way to little for serieus applications.

    Files that much is probably not allowed. FILES= ranges from 8 to 255.

>I can make an Euphoria executor for scripts though as a routine. (running at
>less speed than normal thus!)

    Yeah? can you modify variables in context? can you make functions and
    procedures? can you include files? I don't think so...

    Remember the scripts executed can be built first... e.g. with &, append

>>Perl can check if a variable or a routine exists, is defined, or ... well,
>>Euphoria has routine_id but no variable_id.
>
>You don't want this. Bad programming style and no obvious purpose.

    It serves a purpose once that script executor is available smile

>    Ugly colors.  True, I always bring my source codes to an art-galary.
>    They are high-contrast and work in EGA as well. Which is a lot more
>practical than more subtle colors.

    Define art-galary.

>And there are many ways around the 300 statements limit.
>If you would know Euphoria well enough, you would know it beats perl on
>almost any turf, and you would know the ways around the 300 statements
>limit.

    Surely I know it better than you.
    I did some optimizations on your code. smile

>Perl has no obvious theoretic base, while Euphoria is so thought-through.
>Robert could put all the theoretic stuff about functional program languages,
>safety, scoping rules, implementation details, etc. in the documentation,
>but people tend to need to know how to use it. Not why it is made in such a
>way, that forces us to use it in a certain way.

    If Robert ever has the time, I would welcome such a document.

>What I would like is the ability to shroud everything except this and that
>file:
>
>shourd mylib.e -except options.e
--
>This is good for plugins, options, highscores, hardware support, etc.

    Cool. Rob? smile

    copy /y a.e options.e
    shroud mylib.e -except options.e

    -- from mylib.e
    if rand(2) = 1 then
        system("copy /y a.e options.e >nul", 2)
    else
        system("copy /y b.e options.e >nul", 2)
    end if
    include options.e

    An alternative to eval, once it's ready:
    eval("include " & (96 + rand(2)) & ".e")

>You seem to have a lot of time to write emails. Why not work for money *or*
>stop complaining about the 300 statements limit. We are lucky RDS decided to
>release a public domain version anyway. You should be thankfull. It's their
>work. (yes, some people out there work instead of writing long emails)

    Er...

    Anyone in need of a project? I would welcome some $1 votes next months,
    but no idea yet... sad

>>I type quickly and still want to have short-circuit...
>
>Howcome, please give me ONE good argument...

    Optimization. You won't believe it until we have it.

>Have you seen the things we need to pull, when we don't want short-circuit
>for an if-statements. Now that's ugly.

    No, just

        (a * b) != 0

        ((a != 0) + (b != 0)) != 0

    Not very ugly. You can even leave out the last != 0 since it is implied
    by if (and also while). Example:

        if a() * b() then   -- calls both function
            -- will do this if both are nonzero
        else
            -- will do this if at least one is zero
        end if

    Note that both 'a' and 'b' can be as complex as you had with and/or
before.

    If you REALLY cannot afford to use the one-char operands * and + you can
    try

        if and_bits(a != 0, b != 0) then

    and

        if or_bits(a != 0, b != 0) then

    but I'd prefer using * and + I think.

>Plus its not ugly, read it out loud, its almost an full english explenation
>to ex.exe what you want to do.

    Try understanding how ugly it is to have an elsif, an else, ... in
    your implementation of the short-circuit evaluation.

>It's not meant for an art-galary you know.

    Uh -- did I ask you to define art-galary? couldn't find galary in
    most dictionaries...

>Date:    Tue, 23 Jun 1998 21:29:07 +0200
>From:    Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL>
>Subject: Length & Shortcircuit
>
>atom a
>a = 123
>? length(a)
>
>Why does this generate an error anyways.
>I would prefer if it would return 1, since an atom operates the same as an
>one element sequence!

    ? length(sprintf("%s", {a}))

    That would work...

    testlen.ex
    ? length(sprintf("%s", {1}))
    ? length(sprintf("%s", {{1}}))
    ? length(sprintf("%s", {{1,2,3}}))
    ? length(sprintf("%s", {{}}))
    ? length(sprintf("%s", {{1,{2,3}}}))

    ex testlen
    1
    1
    3
    0

    testlen.ex:5
    sequence found inside character string
    --> see ex.err

    ... except if you have a subsequence. sad

>This would make short-circuit even less usable.

    This is why I want a ?: operator. Unfortunately ?x is already used for
    print(1,x)puts(1,'\n') so we need another operator e.g. ~:

    ? sequence(a) ~ length(a) : 1

>Date:    Tue, 23 Jun 1998 14:39:46 CDT
>From:    Lewis Townsend <keroltarr at HOTMAIL.COM>
>Subject: Re: EUPHORIA Digest - 21 Jun 1998 to 22 Jun 1998 (#1998-36)
>
>Well, I still have to rename nonzip files e.g. text

    I don't have a clue then, sorry sad

>Date:    Tue, 23 Jun 1998 20:27:08 -0500
>From:    Joe Phillips <bubba at TXWES.EDU>
>Subject: Re: Short Circuiting
>
>I could understand a non short-circuiting language confusing those that
>were used to the other, but I cannot determine a reason to not like this
>type of logic.

    Uh -- because Ralf's USED to the non-short-circuiting operands.

>Date:    Tue, 23 Jun 1998 20:33:24 -0500
>From:    Joe Phillips <bubba at TXWES.EDU>
>Subject: Re: Short Circuiting
>
>To get the above code to work, you could create a function into which you
>send s. This would provide a single point of logic that would allow a
>simple if-then-else structure as you desire. (Although a short-circuit
>logic would be cleaner)

    Agreed! Short-circuit logic would be cleaner!!

    I don't like defining functions just to do one check sad

    It's impractical. You can't pass function calls and have only one
    of them called if it already decides the result. You can pass
    routine_ids but you can't tell their argument syntax... at least
    not that easy.

>Date:    Wed, 24 Jun 1998 04:19:44 +0200
>From:    Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL>
>Subject: Re: Short Circuiting
>
>In other words, short-circuiting is a very clumbsy things and results in
>very weird errors and it is very inconsistent.
>
>The that () function should always be called.
>Please, don't implent short-circuiting.

    When programmers of many languages (they all support short-c.) program
    they INTEND to have that() only called if this is false, otherwise they
    write

    if that() and this then

    Besides EUPHORIA (it's an acronym) only BASIC (another acronym), I
    think, that does not support short-c.

    If both are always to be called, C has & and && for this purpose, but
    to be unterse, you can say

    if this() * that() then -- assume this() is also a func
    -- otherwise it doesn't matter!

    I think the problem here is that you, Ralf, are too used to* the non-
    short-c. operands.

    * used to: usually dealing with

    ... right?

new topic     » topic index » view message » categorize

2. Re: To David, Ralf (3), Lewis, Joe (2),

>    This version takes less statements.


Seriously, the number of statements is completely unimportant.
Readable, re-usability, safety and speed are.
Like you said, if you're uncapable of programming below the 300 statement
limit, why bother bringing the number of statements down ?
However, you're version is bit cleaner I must admit.
It was a thought-in-a-sec-programmed-in-a-sec thingie.

>    Replace:
>        a and b     ('and' here means COMPLETE and -- the one we have now)
>    with:
>        (a * b) != 0

I meant, you want short-circuit as an optimization while you can gain the
same speed now, however the above statement is slower than the 'a and b'
So, actually, optimized-as-possible-programs will run *slower* with
short-circuit plus a few will be broken.

>    The above replacements (using +, *, and !=) do not have 'and's or
>    'or's, it works now and forever. smile

It works slower, you wanted optimization, make your point, if there is one.

>    WRONG.
>
>    (1) Syntax: GET_SUCCES - unknown identifier [fixed to GET_SUCCESS]
>    (2) Syntax: the - unknown command [fixed to then]

Another thought-in-a-sec-programmed-in-a-sec thingies. Syntax errors don't
count.

>    (3) Logic: If y[1] = GET_SUCCESS and integer(y[2]) but y[2] <= 0 or
>        y[2] > length(x) or x[y] >= 31 then your version puts nothing.
>        Original version puts "That is not a valid month!\n\n". [need
>        manual fix]

No, I should've put the 'else..end if' stuff before after the first end-if.
However, there are cleaner ways to go about this, which are much more safe
and readable than you approuch in the first place.  First of all, all
sections of your code that share no variables other than obvious ones should
be placed in functions or procedures for clearity and reusability,
esspecially something as trivial as inputting a month. However, in this case
it might even be beter to make a type called month and verify the if the get
() was succesful and test if the value is a month. If not, the user has to
try again.

There are work-arounds to do what you want the way you want to do it, and
these, I  must admit, look less readable, unlike different approuches. If
you can't think of a nice clean, safe approuch to get a month from the user
without any need for short-circuit, ask me, and I'll give you the code you
need.

>    I doubt you understand what I mean by proper alignment, Ralf.

I doubt you understand what proper means. What you consider proper and what
I consider proper is, and should be something, something different.

For example, when you are in a mental instituation, you are not behaving
properly, however the nut-cases that live there behaving as expected. Visa
versa, they are not behaving properly when they walk around in this world.
My point is, proper is a relative. Indentation is a personal choice.

>    Your code is seen by ex as:
>
>    elsif y[1] = GET_SUCCESS and integer(y[2]) then
>        if y[2] >= 1 and y[2] <= length(x) then
>            if x[y] < 31 then
>                puts (1, "Thank you.\n")
>            end if  -- no else here!!
>        end if      -- no else here either!!
>    else
>        puts (1, "That is not a valid month!\n\n")
>    end if

Trust me, my code is seen the way I typed it.
Internally, ex.exe simply considers *any* whitespace (not matter if it is
a -newline-  and twelf tabs or a just a space) as a seperator. It seperates
keywords, symbols and values.
You choose to see it that way. I choose to see it the way I want to see it
and ex.exe looks at it and converts it all the 32-bit pointers to machine
code. (the code to execute the wanted action). Ex.exe could care less about
your proper or nonproper indentation.

>    To make it work as expected you will need 13 statements unless
>    you make functions.

Euphoria is a *functional* language. It is meant to work with functions for
the most simple and trivial tasks. Functions or types are the cleanest way
to do this anyway.
And the number of statements is completely irrelevent and has nothing to do
with the programming language.

>    Now that I can hopefully assume you understand a bit about this,
>    how about your version of short-circuited 5-levels-of-'or' with
>    elsif another 4-levels-of-'or' and finally an else part?

Like I said, use a different approuch.
When I draw an algorithm on paper it does not have 5 short-circuited levels
of or and if it has it looks precizely the way the euphoria program will
look like.
I think the problem here is you, not nothing how to do somehting with
euphoria easily wihtout the need of short-circuit.

>    If you can figure what those 21 are, let's try a more difficult
>    puzzle:

    Puzzle ??
    Give me an example of an usage where you would need to this, and I will
give you an method of achieving this with the need of knowledge of euphoria
but without the need of short-circuit.

Then he says:
>    You need... um, MANY statements smile

and..
>    Great workaround Ralf! Just how few of my 300 statements are
>    left there? blink

Statement count is irrelevent, and is the last thing that should convience
RDS to put this in the language. Those that bring food on their table don't
have to care about the statement count so why should RDS? They are serving
their clients not their parasites!

>>A file length function is not a trivial building block! Don't you agree ?
>
>    Why do they have a file length function in Assembly? (func #23)

You don't have a file length funciton in Assembly.
You have a dos-interrupt you can call for that (func #23)
You can do the same in Euphoria, what in the world is your point..??
(Plus, you can call machine code and use Pete's dynamic ASM translator)

>>function perl_gets (integer fh, integer eol)
>>sequence ret
>>    ret = {getc(fh)}
>>    while ret[length(ret)] != -1 and ret[length(ret)] != eol do
>>        ret = append(ret, getc(fh)
>>    end while
>>    if ret[length(ret)] = -1 then
>>        return ret[1..length(ret)-1]
>>    else
>>        return ret
>>    end if
>>end function
>>
>>Another problem solved in 10 easy to write, easy to read, fast executed
>>lines.
>
>    Twelve.

You'll get over it blink

>    Missing ) on statement 5 "ret = append(ret, getc(fh)"

Oh..  so now Perl is much better, cuz I forgot a ')'.
This is a discussion and you're trying to prove that Perl has a few nice
things that Euphoria needs, I show you how easy Euphoria fills this, 'lack'
in your eyes, and you try to prove otherwise by complaining about a ')' I
forgot.. geez

>    Can save four statements by changing the last if block to:
>        return ret[1..length(ret) - (ret[length(ret)] = -1)]

Readability, re-usability, safety.. statement count doesn't matter.

>    Robert Craig: Please define statement count.

Why, will it bring food on his table ?

>    (It should be easy to have a code in ex/exw to do this. You can
>    make a constant always accessible and will tell, as an atom, how
>    many statements are in the current file, e.g. STATEMENT_COUNT.
>    You can also have another constant for "am I shrouded"...)

Why, those who pay could care less about this, there is really no motivation
for Robert to put this in the language..
And what's the use of a 'am I shrouded' variable.. ?

>>Use interrupts. See the stuff about 'trivial building blocks again'
>>And there is now a library for this as well.
>
>    Great, use interrupts! You *can* access files using interrupts.
>    You can get dir() using interrupts. You can do graphics with
>    interrupts. Why bother having an Euphoria statements for them?
>    Please, tell me!! smile

Speed, safety, clean.
Why not file-length, you wonder..
Well, file length is provided, in dir ().
Why not a built-in function for file-lenght only, so it is 0,0001% faster
you now wonder.
Because we don;t want to learn 1002312123 number of functions to use a
programming language. Euphoria avoids many functions by using routines as
dir () and video_config ().
That's what we call a compromize.
A very clean one, actually.

>    I meant, output of a system() call is returned as a string.
>    And you can still access the errorlevel.

First of all, you can make a device (using interrupts) and use '<' and '>'
But indeed it would be cleaner if we would have returned the error_level and
the output as a sequence.
But, its even worse at this point. system () actually launches another
shell. Not very memory efficient, not to mention speed.

>    It's (going to be) very handy.

True. Robert, this has a been a discussion before, i think Euphoria can use
the improvement suggested.

>    Yeah? can you modify variables in context? can you make functions and
>    procedures? can you include files? I don't think so...

Nope, not unless I want it to be able to.
But I was thinking in the line of a function. Arguments and a return value.
Stuff being able to just modify any variable is asking for untraceble errors
and is unneeded functionality.

>    Remember the scripts executed can be built first... e.g. with &, append

Yes.

>>    Ugly colors.  True, I always bring my source codes to an art-galary.
>>    They are high-contrast and work in EGA as well. Which is a lot more
>>practical than more subtle colors.
>
>    Define art-galary.

I mean, I could care less how my code looks, it just has to be readable in
any case. Changing the colors makes it less readable with EGA, MonoChromes
and LCD-screens. Euphoria's elegance works in mysterious ways.

>>Perl has no obvious theoretic base, while Euphoria is so thought-through.
>>Robert could put all the theoretic stuff about functional program
languages,
>>safety, scoping rules, implementation details, etc. in the documentation,
>>but people tend to need to know how to use it. Not why it is made in such
a
>>way, that forces us to use it in a certain way.
>
>    If Robert ever has the time, I would welcome such a document.

Any1 saved all the Euphoria-mail from the last so many years. I lost the
last a lot when I changed computer. I only have from 1-april-98. Still 1400
euphoric mails blink

>    An alternative to eval, once it's ready:
>    eval("include " & (96 + rand(2)) & ".e")

Yes, still it shouldn't be able to integrate with the program.
However an advanced form of get as an expression evaluator would be nice.

>>>I type quickly and still want to have short-circuit...
>>
>>Howcome, please give me ONE good argument...
>
>    Optimization. You won't believe it until we have it.

Lets consider a program that needs both. It 'needs' short-circuit and it
*needs* normal if-fing.
When I optimize it for the current version of Euphoria it will be faster,
because the short-circuit would internally be compiled to the same as the
'if-trick' I pulled, while the normal if-fing will go slower on this future
fantasy version of Euphoria.

>    If you REALLY cannot afford to use the one-char operands * and + you
can
>    try

    If you REALLY cannot find a different approuch for a problem that you
think needs short-circuit, you can always do this:

    if a then if b then if c then
    end if end if end if

>    Try understanding how ugly it is to have an elsif, an else, ... in
>    your implementation of the short-circuit evaluation.

Try reading it out loud.
Try a different approuch.
Try Perl, try C, or any other language offereing short-circuit. Like them ?

>>It's not meant for an art-galary you know.
>
>    Uh -- did I ask you to define art-galary? couldn't find galary in
>    most dictionaries...

I'm sorry. I'm making this so difficult for you. You have to look up words
as 'galary', because you don't know what I meant by them. That's ok. Just
try again, think it over a couple of times. Within a few weeks you will gain
the knowledge you need to solve this mystery. "What did he mean ?" Maybe I
should give away prizes for the first one that guesses right blink

>>This would make short-circuit even less usable.
>
>    This is why I want a ?: operator. Unfortunately ?x is already used for
>    print(1,x)puts(1,'\n') so we need another operator e.g. ~:
>
>    ? sequence(a) ~ length(a) : 1

Ahhhhhhhhhhhhhhhhh!!!!!
You do love mysteries don't ya ?!!
Cuz, that is precizely what the above is, a walking mystery.

>>I could understand a non short-circuiting language confusing those that
>>were used to the other, but I cannot determine a reason to not like this
>>type of logic.
>
>    Uh -- because Ralf's USED to the non-short-circuiting operands.

That's cheap.
Visa versa. You are USED to the short-circuiting operands, because of C,
Perl, etc. (you have the list yourself..)

>>To get the above code to work, you could create a function into which you
>>send s. This would provide a single point of logic that would allow a
>>simple if-then-else structure as you desire. (Although a short-circuit
>>logic would be cleaner)
>
>    Agreed! Short-circuit logic would be cleaner!!
>
>    I don't like defining functions just to do one check sad

"I dont like defining functions just to do one check"
-- 1) Euphoria is a functional language. Which means you have functions for
even the most trivial things. All functions should be small and trivial and
use other small and trivial functions that use other small and trivial
functions, that use... etc...  It is a style of programming, which Euphoria
is designed for. You're using the wrong language.

-- 2) The 'I' and the 'like' prove that it is not an argument at all.

>    When programmers of many languages (they all support short-c.) program
>    they INTEND to have that() only called if this is false, otherwise they
>    write

I can not come up with many cases where this would be the case, on the other
hand I can come up with millions of cases where the need for
non-shortcuiting would be critical. (Note the need for short-circuit is not
a critical thing, if you even want to call it a 'need' at all)

>    Besides EUPHORIA (it's an acronym) only BASIC (another acronym), I
>    think, that does not support short-c.

So, if you want C, go use C.
Euphoria != C (thankfully)
Euphoria != Basic

Wanne know why ? Because Euphoria is better.
The number of language that do that differently makes no argument, it only
gives you more languages to use for those programs you need.. eh.. wait..
you never need short-circuiting..

>    I think the problem here is that you, Ralf, are too used to* the non-
>    short-c. operands.
>
>    * used to: usually dealing with
>
>    .. right ?

I think the problem here is that you, Andy, are too used to* the short-c
operads.

* used to: usually dealing with

.. right ?

Ralf Nieuwenhuijsen
nieuwen at xs4all.nl

new topic     » goto parent     » topic index » view message » categorize

3. Re: To David, Ralf (3), Lewis, Joe (2),

-----Original Message-----
De: Andy Kurnia <akur at DELOS.COM>
Para: EUPHORIA at cwisserver1.mcs.muohio.edu
<EUPHORIA at cwisserver1.mcs.muohio.edu>
Fecha: miƩrcoles 24 de junio de 1998 12:20
Asunto: To David, Ralf (3), Lewis, Joe (2), but all may read (Rob Craig
should)



>    Great workaround Ralf! Just how few of my 300 statements are
>    left there? blink


Here's the problem Andy. Euphoria isn't based on 300 statements limit. If
this particular programming language is useful to you (eficient, easy to
learn, flexible, or whatever you think), then register. If the benefits
Euphoria can give you don't deserve $30+/- you can still use the PD edition
for free. Don't expect that RDS will ever change the language for the only
purpose to make it use less statements... that absurd, and you (seem to be)
are an inteligent person that certainly uderstand it.

I think the 300 limit thread must come to an end... both point of views have
been completly exposed and the jury (RDS) will give it's veredict upon the
next release of Euphoria. Unfortunatly I think you'll loose this Andy.

Regards,
    Daniel   Berstein
    daber at pair.com

new topic     » goto parent     » topic index » view message » categorize

4. Re: To David, Ralf (3), Lewis, Joe (2),

>>    This is why I want a ?: operator. Unfortunately ?x is already
>>    used for print(1,x)puts(1,'\n') so we need another operator e.g. ~:
>>
>>    ? sequence(a) ~ length(a) : 1
>
>Ahhhhhhhhhhhhhhhhh!!!!!
>You do love mysteries don't ya ?!!
>Cuz, that is precizely what the above is, a walking mystery.

Well, let's see, I think that means:

atom x
if sequence(a) then
    x = length(a)
else
    x = 1
end if
? x

So that means we can have a function! :)

global function tildewasquestionmark(atom boolean, object o1, object o2)
    -- If boolean is true then return o1, otherwise return o2, and
    -- it's only 4 or 5 statements! :) (Dunno if 'else' is counted.)
    if boolean then
        return o1
    else
        return o2
    end if
end function

? tildewasquestionmark(sequence(a), length(a), 1)

(You may want to change the function name to something a little more
understandable... :) Although the current method is probably more
understandable than what it was.. ;)


_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu