1. Wierd Language Syntax idea

How about:
if get_key() > -1 then
        ? it
end if

while getc(fn) != -1 do
        puts(fn2,it)
end while

I know it is highly impractical but does anyone else like it?
It is a lot nicer than using silly assignments :

integer key
key = 0
while key > -1 do
        key=get_key()
        ? key
end while


And by the way, I want to be able to do

{x,y} = foo()

and to be able to evaluate

{{1,2},{3,4},{5,6}} * {x,y}

"Can you live a moment longer by worrying about it ?"

Daniel

new topic     » topic index » view message » categorize

2. Re: Wierd Language Syntax idea

>And by the way, I want to be able to do

>
>{x,y} = foo()

This and you other suggestion can be solved by the programming method the
language ICON uses.
Consider this ICON function (in EUphoria pseudo-code):

function for (integer begin, integer end, integer step) do
    return  begin
    if end > begin then
        begin = begin + step
        return begin
    end if
end function

sequence txt
txt = "This is a message"

puts (1, txt)        -- Will print the first character of txt
all puts (1, txt)      -- Keeps streaming txt until it returns no more value
-- Thus: it prints the whole txt sequence

all for(1,10,1) do puts (1, txt) end do
-- Will display the first 10 characters of txt only once!

Why ? Lets trace it.
First the for () statement will return 1, then the first character is
displayed. the 'ALL' means we don't stop until we no longer have any
arguments to use. So it will print a character of txt 10 times.

A bit more of this strange, but powerfull, behaviour.

    all txt = 'e' do puts(1, "X") else puts(1, "*") end do

Will display: ***********X****X

How can this solve your {x,y} assignment problem. Simple: It doesn't need
any assigns at all. Using this streaming technique, you could put *any*
algoritm in a single statement containing your whole program. How explecit
can one be ?

Just search for ICON PROGRAMMING LANGUAGE
The language itself, is really shitty, very slow, weird unneeded datatypes,
etc. But this aspect could inspire us.

We really don't like to assign every thing, check its value or stuff like
that. This would solve it.

>and to be able to evaluate
>
>{{1,2},{3,4},{5,6}} * {x,y}

Yes, it would be nice if this worked!
Robert, if sequences don't match, they should go a level deeper until they
do. It would be more powerfull behaviour.
BTW what about being able to say:

sequence s
s = {4,4,5,5,2}

if +s != 20 then
    puts(1, "that's weird when I add 4, 4, 5, 5 and 2 together I *do* have
20")
end if

And like +sequence_name, why not also have -seq_name and *seq_name and
/seq_name

Ralf

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

3. Re: Wierd Language Syntax idea

Daniel wrote:

>And by the way, I want to be able to do
>
>{x,y} = foo()

Python has this as well. It would be a great addition to Euphoria. Other wish
list items:

1. Error trapping. For example,

   TRAP_ROUTINE = routine_id("myErrorHandler")

I think that this is the most important thing that could be added to Euphoria,
so we can have graceful error recovery.

2. Variable initialization. For example,

   integer x1 = 0, y1 = 0

And no, I'm *not* trying to turn Euphoria into 'C'.

-- David Cuny

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

4. Re: Wierd Language Syntax idea

At 08:26 PM 6/4/98 +0200, Ralf wrote:
...
>>
>>{{1,2},{3,4},{5,6}} * {x,y}
>
>Yes, it would be nice if this worked!
>Robert, if sequences don't match, they should go a level deeper until they
>do. It would be more powerfull behaviour.

I vote yes also! That would be useful in a dozen places in my
windoz code, just as an example, when adjusting screen
coordinates by some offset.

>BTW what about being able to say:
>
>sequence s
>s = {4,4,5,5,2}
>
>if +s != 20 then
>    puts(1, "that's weird when I add 4, 4, 5, 5 and 2 together I *do* have
>20")
>end if
>
>And like +sequence_name, why not also have -seq_name and *seq_name and
>/seq_name
>
>Ralf

I'm less sure about this one. Personally, I think the following
makes clearer code:
  if sum(s) != 20 then
     ....
And, of course we could easily add these ourselves as functions,
i.e. sum(s), sub(s), mult(s), div(s)

Irv

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

5. Re: Wierd Language Syntax idea

Daniel and Irv want (for example):

     {{1,2},{3,4},{5,6}} * {0,1}

to give the result:

     {{0,2},{0,4},{0,6}}

instead of an error, like it does now (length 3 != 2)

But what if you had:

    {{1,2}, {3,4}} * {0,1}

Now the lengths *do* match 2=2, so currently Euphoria
will give you:

   {{0,0}, {3,4}}

Do you guys really want to break existing Euphoria
programs and instead get the result:

   {{0,2}, {0,4}}

or would you rather have your new behavior revert back
to the old behavior whenever the lengths *just happen* to
be the same (by coincidence)?

What you are trying to achieve seems legitimate, but
I can't accept it in the current form that you propose it.

Regards,
     Rob Craig
     Rapid Deployment Software

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

6. Re: Wierd Language Syntax idea

From:    Irv
>i.e. sum(s), sub(s), mult(s), div(s)

    I prefer that too, despite my usual preference for operators rather than
functions.  But what order would div(s) go in?
would div( { 4, 2, 10 } )  equal .2 or 1.25 or 20...


From:    David Cuny
>Other wish list items:
>1. Error trapping.

    I second that.

>2. Variable initialization. For example,
>   integer x1 = 0, y1 = 0

    I thought that way when I started, but I've kinda gotten used to
Euphoria's way.
It might be a little clearer to some though, as it would look the same as
constant declaration.

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

7. Re: Wierd Language Syntax idea

my two cents:

the number of *'s dictates the depth into the first sequence that the
second is multiplied into, so:

{{0,1},{2,3}}*{1,2} = {{0,1},{4,6}}

{{0,1},{2,3}}**{1,2} = {{0,2},{2,6}}

{{0,1},{2,3},4}**{1,2} = {{0,2},{2,6},{4,8}}

etc.




as for the wish list, I'd like to be able to write:

foo[2..4][3]={1,2,3}


        isaac

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

8. Re: Wierd Language Syntax idea

>as for the wish list, I'd like to be able to write:
>
>foo[2..4][3]={1,2,3}

That would be interresting. How about:

enemy[1..end][X..Y] += enemy[1..end][XV..YV]

Well, on second thought, that's a bit less readable than:

for i = 1 to length(enemy) do
    enemy[i][X] = enemy[i][X] + enemy[i][XV]
    enemy[i][Y] = enemy[i][Y] + enemy[i][YV]
end for


I like the 'end' idea a lot:

enemy = enemy[1..i-1] & enemy[i+1..length(enemy)]

vs

enemy = enemy[1..i-1] & enemy[i+1..end]

Well, maybe I can't think of a really good real world example....

A workaround for anybody who wants this, is to do something like this:

integer i, len
i = 1
len = length(enemy)
while i < len do
    if enemy[i][ALIVE] then  -- enemy[i].alive would be nicer.... ;)
        -- Do movement and such, take damage, etc
    else
        enemy = enemy[1..i-1] & enemy[i+1..len]
        i = i - 1
    end if
    i = i + 1
    len = length(enemy)
end while

_____________________________________________________________________
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

9. Re: Wierd Language Syntax idea

-----Original Message-----
De: Robert B Pilkington <bpilkington at JUNO.COM>
Para: EUPHORIA at cwisserver1.mcs.muohio.edu
<EUPHORIA at cwisserver1.mcs.muohio.edu>
Fecha: viernes 5 de junio de 1998 14:49
Asunto: Re: Wierd Language Syntax idea
>I like the 'end' idea a lot:
>
>enemy = enemy[1..i-1] & enemy[i+1..length(enemy)]
>
>vs
>
>enemy = enemy[1..i-1] & enemy[i+1..end]

hmm... how about having a dinamically-asigned auto-updated variable?

sequence    enemy
dynavar       end = length(enemy)

? end                        -- {}
enemy = {1,2,3}
? end                        -- {3}
enemy = {{1,2,3},2,3}
? end                        -- {{3},2}

It should be easy to implement (at least with sequence lenghts)... just a
pointer to where the length of the object is stored.

Another approach (OO style):

attribute slength (sequence x)
    sequence r
    integer n
    r = {}
    if length(x) > 0 then
        n = 0
        for loop = 1 to length(x) do
            if atom(x[loop]) then
                n = n + 1
            else
               r = r & {x.slength}
            end if
        end for
        r = r & n
    end if
    return r
end attribute

sequence myseq

seq = {}
? seq.slength    -- {}
seq = {1,2,3}
? seq.slenght    -- {3}
seq[1] = {1,2,3}
? seq.slength    -- {{3},2}

"attribute" can be thougth as an extension to "type". The parameter in the
attribute declaration tells the compiler to which data types that attribute
is for.... so you can define attribute ... (sequence x), and attribute ...
(mytype q). Sounds like polymorphism? The "attribute" can be accesed using
dot notation. I'm sure this won't break any existing code.

Regards,
    Daniel Berstein
    daber at pair.com

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

10. Re: Wierd Language Syntax idea

At 05:56 AM 6/5/98 -0400, Isaac wrote:

>as for the wish list, I'd like to be able to write:
>
>foo[2..4][3]={1,2,3}
>

Also No.1 on my wish list.

Graeme.
----------------------------------------------------

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

Search



Quick Links

User menu

Not signed in.

Misc Menu