Unless

Started by Kazimir Majorinc, July 16, 2008, 09:07:03 PM

Previous topic - Next topic

Kazimir Majorinc

In Newlisp unless is "pessimistic if" as Cormullion stated it in his free book.


Quote(unless (= 0 1)(print "55")(print "66"))


is same thing as


Quote(if (not (= 0 1))(print "55")(print "66"))


However, in CL and Scheme, unless is "pessimistic when."


Quote(when (not (= 0 1))(print "55")(print "66"))


So, original expression prints 5566 in CL and Scheme and 55 in Newlisp.



It might be good to synchronize that with CL and Scheme, because difference can be source of the bugs and reason for complains, and because CL and Scheme semantics seems to be more beneficial - it spares one (begin) - while Newlisp version only change the order of the alternative s-expression.



Maybe some other keyword could be used for "unless" in the current meaning, if someone think it is useful.
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

Jeff

#1
We could call it ifn't.
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

Lutz

#2
Or 'pif' for pessimistic if :)



This kind of change would have to be announced in the next release before implementing it in the release after that, because it could break code.

Jeff

#3
I don't have any real problem with if/unless being semantically paired rather than when/unless.  In fact, I think I prefer it, as there are fewer instances where I would use unless if it did not have a negative form.
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

rickyboy

#4
Well, as long as you're voting, I agree with Kazimir and vote for the semantic pairing of when/unless.  And if can be paired with something else, like pif (what Lutz suggested).  Other candidates can be nif, ifn (although American southerns think this is "if", as in "Be prepared fer if'n them kin folk stop by fer vittles."), nisi (for the Latin inclined), ifnot, et c.



Heck, start a contest!  ;-)
(λx. x x) (λx. x x)

rickyboy

#5
By the way, between the following two people, who would win in a cage fighting match?



http://bp2.blogger.com/_8x5vgWh9U8A/SDP-tAjJpyI/AAAAAAAAACg/LMCbZU9gOFg/S1600-R/KM2.jpg"> OR http://celebrity-pics.movieeye.com/celebrity_pictures/Bill_Gates_718639.jpg">



Kazimir versus Bill Gates.



My money is on Kazimir.  (Bill is not allowed to hire someone to do the fighting for him.)



:-)
(λx. x x) (λx. x x)

cormullion

#6
Quote from: "rickyboy"Well, as long as you're voting, I agree with Kazimir and vote for the semantic pairing of when/unless.


if symmetry is that important, I'll go along with it too. But it will break some of my code, and I'm not keen on breaking code just to be compatible with some other languages (neither of which I use or am interested in) or for the sake of symmetry (which is wonderful, in moderation).



If you made a list of all the things that Common Lisp and Scheme had that newLISP should have (or vice versa) I can't believe that this is the one area that should be addressed before all the others...


Quote from: "rickyboy"And if can be paired with something else, like pif (what Lutz suggested).  Other candidates can be nif, ifn (although American southerns think this is "if", as in "Be prepared fer if'n them kin folk stop by fer vittles."), nisi (for the Latin inclined),


Aargh! Please no neologisms or contrivances... That doesn't seem to follow the newLISP way... About the only one I'd vote for is if-not.  And I don't like that very much. But at least it's consistent.

rickyboy

#7
Quote from: "cormullion"Aargh! Please no neologisms or contrivances... That doesn't seem to follow the newLISP way... About the only one I'd vote for is if-not.  And I don't like that very much. But at least it's consistent.

Ahh!  What happened to your humour today?  You're breaking my heart!  ;-)
(λx. x x) (λx. x x)

Jeff

#8
if-not sounds good.  I still like ifn't.
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

Kazimir Majorinc

#9
That's me debugging.  



Strange enough, it is not B. Gates on the picture you posted. But if I click on the right button of the mouse and save the picture on the disk, then Bill is on the picture. Try it, its fun.



http://img155.imageshack.us/img155/7344/foldergi3.png">



Hm ... maybe I'm stronger, but my wife claims Bill is more attractive than Clooney guy. Women are incomprehensible!
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

Kazimir Majorinc

#10
From the language design perspective I think it is important to continue improving, even if improvement is small and breaking code is extensive.



Otherwise language starts dying.
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

rickyboy

#11
Quote from: "Kazimir Majorinc"That's me debugging.

Hahaha!



I was going to airbush-out your index finger, so it would look like you were shaking a fist, ready to fight.  ;-)  


Quote from: "Kazimir Majorinc"Strange enough, it is not B. Gates on the picture you posted. But if I click on the right button of the mouse and save the picture on the disk, then Bill is on the picture. Try it, its fun.

Yeah, that was weird.  I have already changed the IMG url.  Hopefully, this one will consistently display Bill Gates face.  (Don't know if that's good or bad.)


Quote from: "Kazimir Majorinc"Hm ... maybe I'm stronger, but my wife claims Bill is more attractive than Clooney guy. Women are incomprehensible!

Hahahaha!  Yes, I too have given up on trying to guess what women will like.  They are inscrutable!!  :-)
(λx. x x) (λx. x x)

newdep

#12
In anycase... its time to have a "perhpas" or a "maybe" or a "couldbe" inside newlisp...

Just to make code more exiting from time to time when executing it ;-)
-- (define? (Cornflakes))

Jeff

#13
How does that work?  It gives an even chance of evaluation?
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

DrDave

#14
Maybe "perhaps", "sometimes", "maybe", etc. could implement fuzzy logic rather than probablitities or random selection.
...it is better to first strive for clarity and correctness and to make programs efficient only if really needed.

\"Getting Started with Erlang\"  version 5.6.2