I can imagine plenty of other such operators. Imagine an OO language with a "message send" operator that quotes the name of the message:

    x <- foo(a, b, c)

or the infix dot-operator for selecting record fields, which doesn't just take two expressions.

Dave

David A. Wheeler wrote:
Dave Herman:
One minor note on your recent blog entry about it. You claim that && and || can be aliased to AND and OR, respectively, by writing:

(define && and)
(define || or)

This isn't quite true, at least in Scheme. Since AND and OR are not functions but rather special forms, you need macros for this...

My thanks to Dave Herman for correcting the error of my ways.  It _worked_ on 
one implementation, which misled me into thinking it'd work in general (not 
true).

Unfortunately, this issue appears to be pretty common across Lisp-based languages: "and" and "or" are special.  At 
least in Common Lisp, Emacs Lisp, and Scheme, both "and" and "or" are short-circuit operators. Typically function 
parameters are completely determined before they are called, but this does NOT happen with "and" and "or". 
(Justification:
http://merd.sourceforge.net/pixel/language-study/syntax-across-languages/Blns.html,
part of the interesting cross-language comparison here:
http://merd.sourceforge.net/pixel/language-study/syntax-across-languages/ ).

Since "and" and "or" are almost universally special cases in Lisp-like 
languages anyway, I think sweet-expressions ought to allow them as infix operators as well 
(probably in uppercase and lowercase forms).  Thus, this would be legal:
  if {{x > 2} and {y < 3}}
    'goodness
    'badness

I originally didn't permit this in sweet-expressions, because I worried about 
existing code like this:
 '(Mary and Martha)
But if (...) will only be used to surround "strict s-expressions", and [...] force 
"no infix" interpretation, then this is no longer a problem.

Yeah, I know about exclusive-or, but it's rare and there's less consensus on 
its name.  So adding it also doesn't seem worthwhile.

I don't know of any other infix operators that are ALSO special forms (other than "and" 
and "or").  Anyone?

--- David A. Wheeler

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Readable-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/readable-discuss


Reply via email to