Re: ? 1={}, is there really any other interpretation?

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

Pete Lomax wrote:
> 
> Al Getz wrote:
> > Not sure what you mean by being 'trolled'.
> Don't worry about it. I just meant the uneasy self-important sensation that
> the author is playing with me, that they could not possibly believe what they
> were saying but instead deliberately crafting a message solely intended to
> provoke
> the maximum retaliatory outburst. blink I probably spent too long reading that
> XP patent thing yesterday, and as noted I have a long history of ranting on
> and on and on about this topic...
> > 
> > > Clearly, ? 1={} *should* print FALSE
> > 
> > Well, lets look at another operation with an atom and a sequence...
> > 
> > ?1+{1,2,3} --prints "{2,3,4}" without the quotes
> > 
> If you want consistency then "1+{1,2,3}" should trigger an error, and much the
> same way that we've all been forced for years to replace = with equal, force
> it to be replaced with sq_add(1,{1,2,3}) or maybe 1 at +{1,2,3}.
> 
> > It is possible that i am a victim of my own programming techniques,
> > in that the code i presented is only typical and not as general as
> > it might imply.
> As I said, "not previously infected with the flawed concept
> of implicit sequence ops. [NB I said implicit.]"
> 
> Obviously, sq_eq(a,b) or a@=b are in contrast explicit sequence ops.
> 
> > Because of this i invite you to present some
> > code that might make use of your suggestion of having 1={}
> > return FALSE (or TRUE even).
> Too easy:
> }}}
<eucode>
> function killFilter()
>     if name="Pete Lomax" then
>         return reply_to="Al Getz"
>     end if
>     return False
> end function
> integer flag
>   flag=killFilter()
> </eucode>
{{{

> Almost everyone who has ever written some Eu code has tried something like
> that
> only to first run into the dreaded "true/false condition must be ATOM"
> then "type check error, flag is {1,1,1,1,1,1,1}", then "sequence lengths are
> not the same (4!=7)" and so on.
> 
> Obviously if you are asking for a "1={}" example that cannot be trivially
> replaced
> by "equal(1,{})" then there ain't one. The closest I can get:
> }}}
<eucode>
>   if alen=1 then emit_one_byte_opcode()
>   elsif alen=2 then emit_two_byte_opcode()
>   elsif alen={} then fatal("no valid length for opcode")
> </eucode>
{{{

> The point is simply that the above is the most natural and elegant way to
> write
> such code. I know you could easily fix it via equal() or using -1 for the
> error
> case.
> 
> Regards,
> Pete


Hi Pete,


I dont take this technical stuff too personal anymore, as i try
to let the logic speak for itself.  Also, if someone wants to argue
for days that 1=2 then after the first try or two i would be
happy to let them believe what they will.
I also dont put out 'feelers' for the sole purpose of arguing
over something, because i just dont feel like wasting the time.

As i said in my previous post, more or less, is that i would be
happy to see some of your (or others) code that demonstrates
a good use for 1={} returning FALSE, and you did that and made
the point clear with:

> function killFilter()
>     if name="Pete Lomax" then
>         return reply_to="Al Getz"
>     end if
>     return False
> end function

That's very nice too, and illustrates how that sort of syntax
could be very useful.  On the other hand, the old way isnt
so bad either, and comes in handy too.  I guess this means
we have a conflict where if you make it work one way you get
some benefits and some loss of other benefits, and if the
other way you get some other benefits and some other loss.
It's got to be one way or the other, and right now it works
as we all now are aware of (1={} returns {}).

Because of all this, i would suggest that it's time to introduce
the double equals sign "==", which comes in handy in my
Scientific Calculator (it's math language) as well as many other
computer languages.

To modify your nice example:

 function killFilter()
     if name=="Pete Lomax" then
         return reply_to=="Al Getz"
     end if
     return False
 end function

This, at least for me, has a nice personal side effect...
After working in Euphoria for hours, days, weeks, and i go
back to C or C++ to do something special, i will make the
mistake:

 if (a=b)
    DoThis();

at least once smile

Also, i dont mind using the double equals sign for testing
and the single for assignments (or tests with atoms) but
i guess it could become confusing too.

I agree with most of what you are saying now, but I cant agree however
that making

? 1+{1,2,3}

return an error would be an improvement, even if we didnt worry about
backwards compatibility anymore.

More generally, i think that sequences are always going to be just
a little confusing.  For example, how do you answer this question:

x={{}}

Is the sequence x holding anything or not?

Then, what should be returned for this:

? 1=x

Then, change x:

  x={{{}}}

Now what should ? 1=x  return (or print)?


I guess what you are suggesting is to make operations between atoms
and sequences totally illegal?
If so, then i think we would be forced to use:
  pos=find(1,s)
over and over again for a large sequence.
Or, what else could be used to determine which elements of s
are equal to 1 exactly if 1={} current functionality is lost?



Take care,
Al

E boa sorte com sua programacao Euphoria!


My bumper sticker: "I brake for LED's"

 From "Black Knight":
"I can live with losing the good fight,
 but i can not live without fighting it".
"Well on second thought, maybe not."

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

Search



Quick Links

User menu

Not signed in.

Misc Menu