Re: = vs := and = vs ==

new topic     » goto parent     » topic index » view thread      » older message » newer message
petelomax said...
jaygade said...

If I was designing a Euphoria-like language, here's how I would handle operators:

Mismatched sequence size is a no op for elements of the longer sequence [even for - and /]. 
{} op object is no op. Returns object unchanged. 

Interesting idea.

... snip...

then this implements that suggestion

function xq_div(object a, object b) 
    if atom(a) then 
        if atom(b) then return a/b end if 
        for i=1 to length(b) do 
            b[i] = xq_div(a,b[i]) 
        end for 
        return b 
    elsif atom(b) then 
        for i=1 to length(a) do 
            a[i] = xq_div(a[i],b) 
        end for 
        return a 
    end if 
--  if length(a)!=length(b) then fatal(a,b) end if 
    if length(a)<length(b) then 
        for i=1 to length(a) do 
            b[i] = xq_div(a[i],b[i]) 
        end for 
        return b 
    end if 
    for i=1 to length(b) do 
        a[i] = xq_div(a[i],b[i]) 
    end for 
    return a 
end function 

Not exactly difficult, at least in hll, though there are quite a few of them, and like I said I'm not convinced it is necessarily an improvement.

I've now implemented something like this (though nop elements are truncated): http://scm.openeuphoria.org/hg/euphoria/rev/bc7ba9aea3a6

(I'll look into keeping, instead of truncating, the nop elements at some point in time.)

petelomax said...
jaygade said...

{} is false. Any non-empty sequence is true.

Oh, I have heard that one before blink

I concluded this is a knee-jerk reaction to the dreaded "true/false condition must be an ATOM", which used to plague me back in the days when I used RDS Eu.

Since moving full-time to Phix and removing implicit sequence ops, this happens, I kid you not, less than once a year.

Besides, I simply just don't buy that expressions such as "{1,2,3} and {4,5,6}" have any meaningful true/false answer, and for my money "programming error" wins hands down.

I've also implemented jaygade's suggestion for this in the feature branch.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu