Re: Wierd Language Syntax idea

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

-----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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu