🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #600

Re: What I'd really like to see in an if-statement...

#600
From: John Gateley
Date: Fri, 01 Sep 1989 15:13
36 lines
2060 bytes
In article <282@castle.ed.ac.uk> db@lfcs.ed.ac.uk (Dave Berry) writes:
>In article <13359@megaron.arizona.edu> gudeman@arizona.edu (David Gudeman) writes:
>>In article  <8620@batcomputer.tn.cornell.edu> lacey@batcomputer.tn.cornell.edu (John Lacey) writes:
>>>In talking about _Real Conditionals_ :), 
>>>So far, Lisp, Icon, and BCPL have all tried and failed to meet the challenge
>>
>>Urr.  I thought both Lisp and Icon succeeded. [...]
>I agree about Icon, but are you sure about Lisp?  I thought that
>(< a b) returned either t or nil.  If so, although it can handle
>cases like (< a b c d), it can't handle (<= (< a b) c).

First, do
(setf (symbol-function '<=help) (symbol-function '<=))
for all the relational predicates.

Next define a macro:
(defmacro <= (&rest args)
  (let ((result (tree-walk args)))
    result))
and so on for all the relational predicates.

Here, treewalk is a function which basically restructures the input so that
nested relations are handled properly: for example (<= (< a b) c)
means (let ((b-temp b)) (and (< a b-temp) (<= b-temp c)).

Cautions: this may not work someday in CL, as I think the cleanup committee
decided that lisp: functions may not be redefined. Also, if it does work
it may cause a performance hit since the compiler might have special
knowledge about <= and friends.

So, Lisp succeeds. The macro facility in Lisp gives you the ability to
model just about any programming syntax you want (within the inherent
bounds of lisp syntax).

John
gateley@m2.csc.ti.com
Technical Details
Message-ID: <89723@ti-csl.csc.ti.com>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!sun-barr!texsun!pollux!ti-csl!m2!gateley
References: <13359@megaron.arizona.edu> <282@castle.ed.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!sun-barr!texsun!pollux!ti-csl!m2!gateley
From: gateley@m2.csc.ti.com (John Gateley)
Newsgroups: comp.lang.misc
Subject: Re: What I'd really like to see in an if-statement...
Message-ID: <89723@ti-csl.csc.ti.com>
Date: 1 Sep 89 15:13:21 GMT
References: <13359@megaron.arizona.edu> <282@castle.ed.ac.uk>
Sender: news@ti-csl.csc.ti.com
Reply-To: gateley@m2.UUCP (John Gateley)
Organization: TI Computer Science Center, Dallas
Lines: 36