Prefix vs. Infix? 
Author Message
 Prefix vs. Infix?

Other than the obvious, what's the difference?  Is there any reason I
should use one vs. the other?  (Does prefix compile faster, etc?)

Whats the reasoning behind this optional syntax setup anyway?



Tue, 01 Apr 1997 00:44:15 GMT  
 Prefix vs. Infix?

   Other than the obvious, what's the difference?  Is there any reason I
   should use one vs. the other?  (Does prefix compile faster, etc?)

Prefix is simpler, cleaner, and more elegant, and allows for a macro
system and other code-manipualting tools that are also simpler,
cleaner, and more elegant.  However, if not properly indented it can
be hard for humans to read.  (Programming environments and good
editors take care of this automatically.)

Infix can be a terrible rat's nest, but we spend years teaching school
children to deal with it, and the vast majority of mainstream
programming languges use infix syntax.  Any langauge that does not use
infix syntax faces major difficulties in the marketplace, or at least
the "mainstream" portion of it.

Prefix is probably a bit faster to parse, but this difference is
not important -- other costs dominate in any decent compiler.

In Dylan, which aspires to be a mainstream langauge, only the infix
syntax is officially supported, so you don't have to worry about this
choice.  (I agree with this decision on pragmatic grounds, painful as
it is for me on aesthetic grounds.)

-- Scott

===========================================================================

Principal Research Scientist            Phone:     412 268-2575
School of Computer Science              Fax:       412 268-5576 (new!)
Carnegie Mellon University              Latitude:  40:26:46 N
5000 Forbes Avenue                      Longitude: 79:56:55 W
Pittsburgh, PA 15213                    Mood:      :-)
===========================================================================



Tue, 01 Apr 1997 03:01:14 GMT  
 Prefix vs. Infix?

writes:

Quote:
> Other than the obvious, what's the difference?  Is there any reason I
> should use one vs. the other?  (Does prefix compile faster, etc?)

Lisp people prefer prefix because operator precidence is unambiguous,
because Lisps have traditionally used infix notation, and because it
makes writing the parser substantially easier.  Compare a parser for
Scheme to a parser for C for a glaring example.

Most other computer people prefer infix, because they have been using it
since kindergarten, and because, despite it's ambiguity, it's been the
standard mathematical representation for centuries.

Forth programmers prefer postfix, because it's non-ambiguous, and easy
and efficient to use with a virtual stack machine.

Inside, it's all parse trees anyhow.  Printing out a parse tree in
prefix, infix and postfix notation is a typical homework problem for a
second-year computer science course.  So don't get hung up on syntax.
Modern languages like Dylan (and Mathematica, if I may make a shameless
plug) let you use prefix or infix, as you prefer.

John Brewer
Wolfram Research, Inc.
(but speaking for myself)



Tue, 01 Apr 1997 02:30:23 GMT  
 Prefix vs. Infix?

Quote:

> In Dylan, which aspires to be a mainstream langauge, only the infix
> syntax is officially supported, so you don't have to worry about this

Apologies for not keeping up to date.  I have the dylan interim manual,
but evidently I failed to notice that prefix won't continue to be
supported.
Maybe I just made some assumptions since MacMarlais supports prefix,
but
anyway....

I sort of like the lispish prefix notation myself (I also like RPN
calculators), but I can see how (like RPN calculators) infix is
important for dylan to go over well in the "main stream."



package!!"
                                                  -Me



Tue, 01 Apr 1997 07:07:26 GMT  
 Prefix vs. Infix?

[...]

Quote:
>  Maybe I just made some assumptions since MacMarlais supports prefix,
>  but

My fault, sorry.  The various versions of the Marlais interpreter
(since version 0.5) do unashamedly support both infix and prefix
notation.  The prefix notation is as close to the original Dylan book
as seemed reasonable to make it.  Some extensions have been made to
support new features introduced in the DIRM.  Setter syntax will soon
change to match the DIRM requirements as well.  We want to remain true
to the spirit of Larry Tesler's foreword in the original Dylan book in
which he said

        "By providing alternate syntaxes atop the extremely neutral
        base of Lisp, we believed we could present a familiar face not
        only to Lisp programmers,m but also to those accustomed to
        other syntaxes, including Smalltalk's."

It's easy to do this with Marlais, because Marlais doesn't compile
production quality code--it interprets a list-based intermediate
representation of Dylan.  Infix is implemented by parsing and
translating to lists, then eval'ing.  Hack or sound enginneering
choice?  You decide.

Apple has probably decided it would be prohibitively expensive to
provide more than one production-quality front-end for their compiler.
Twice the work on front-ends, twice the work on documentation, etc.,
etc., etc.  Of course, Marlais comes with zero documentation besides
the source (perhaps this should be remedied some day) which makes our
job much easier.

Quote:
>  anyway....
>   I sort of like the lispish prefix notation myself (I also like RPN
>  calculators), but I can see how (like RPN calculators) infix is
>  important for dylan to go over well in the "main stream."

So do I.

Quote:


>  Science

>  UN*X

>  package!!"

                                                     -Me
Joe Wilson



Tue, 01 Apr 1997 17:25:00 GMT  
 Prefix vs. Infix?

:    Other than the obvious, what's the difference?  Is there any reason I
:    should use one vs. the other?  (Does prefix compile faster, etc?)

: Prefix is simpler, cleaner, and more elegant, and allows for a macro
: system and other code-manipualting tools that are also simpler,
: cleaner, and more elegant.  However, if not properly indented it can
: be hard for humans to read.  (Programming environments and good
: editors take care of this automatically.)

Um, I find that often Lisps it can be hard to read even when
indented.

: Infix can be a terrible rat's nest, but we spend years teaching school
: children to deal with it, and the vast majority of mainstream
: programming languges use infix syntax.  Any langauge that does not use
: infix syntax faces major difficulties in the marketplace, or at least
: the "mainstream" portion of it.

: Prefix is probably a bit faster to parse, but this difference is
: not important -- other costs dominate in any decent compiler.

: In Dylan, which aspires to be a mainstream langauge, only the infix
: syntax is officially supported, so you don't have to worry about this
: choice.  (I agree with this decision on pragmatic grounds, painful as
: it is for me on aesthetic grounds.)

So prefix is better for compilers and programmers and tool writers
and infix is better for humans.

I have the vague suspicion that there could be a somewhat deep reason
{beyond just "Euler started us out this way"} why humans like to see
mathematics with infix related to the kinds of natural languages that we are
neurally wired up to do.

Interestingly I find that postfix is much easier when actually performing
manual operations (with an HP calculator), but terrible to read.

: -- Scott

There must be a psychology thesis in here somewhere...
--

-Institute for Nonlinear Science, University of California, San Diego
-*** AD: Archive for nonlinear dynamics papers & programs: FTP to
-***     lyapunov.ucsd.edu, username "anonymous".



Tue, 01 Apr 1997 14:40:54 GMT  
 Prefix vs. Infix?

[...]

Quote:
>  Maybe I just made some assumptions since MacMarlais supports prefix,
>  but

My fault, sorry.  The various versions of the Marlais interpreter
(since version 0.5) do unashamedly support both infix and prefix
notation.  The prefix notation is as close to the original Dylan book
as seemed reasonable to make it.  Some extensions have been made to
support new features introduced in the DIRM.  Setter syntax will soon
change to match the DIRM requirements as well.  We want to remain true
to the spirit of Larry Tesler's foreword in the original Dylan book in
which he said

        "By providing alternate syntaxes atop the extremely neutral
        base of Lisp, we believed we could present a familiar face not
        only to Lisp programmers,m but also to those accustomed to
        other syntaxes, including Smalltalk's."

It's easy to do this with Marlais, because Marlais doesn't compile
production quality code--it interprets a list-based intermediate
representation of Dylan.  Infix is implemented by parsing and
translating to lists, then eval'ing.  Hack or sound enginneering
choice?  You decide.

Apple has probably decided it would be prohibitively expensive to
provide more than one production-quality front-end for their compiler.
Twice the work on front-ends, twice the work on documentation, etc.,
etc., etc.  Of course, Marlais comes with zero documentation besides
the source (perhaps this should be remedied some day) which makes our
job much easier.

Quote:
>  anyway....
>   I sort of like the lispish prefix notation myself (I also like RPN
>  calculators), but I can see how (like RPN calculators) infix is
>  important for dylan to go over well in the "main stream."

So do I.

Quote:


>  Science

>  UN*X

>  package!!"

                                                     -Me
Joe Wilson



Tue, 01 Apr 1997 17:25:36 GMT  
 Prefix vs. Infix?

Quote:

>In Dylan, which aspires to be a mainstream langauge, only the infix
>syntax is officially supported, so you don't have to worry about this
>choice.  (I agree with this decision on pragmatic grounds, painful as
>it is for me on aesthetic grounds.)

It seems to me that it would be really nice if the infix syntax and
the prefix syntax were isomorphic, in the sense that one could easily
transform one to the other in the editor.  Then people could share
code but nonetheless always work in the syntax of their choice.

I initially had the impression that this is what was being done with
Dylan.  Was this ever the intent, and if so, is it still in the plan?

Greg Anglin
Statistical Computing Laboratory



Wed, 02 Apr 1997 04:02:00 GMT  
 Prefix vs. Infix?

Quote:

>In Dylan, which aspires to be a mainstream langauge, only the infix
>syntax is officially supported, so you don't have to worry about this
>choice.  (I agree with this decision on pragmatic grounds, painful as
>it is for me on aesthetic grounds.)

It seems to me that it would be really nice if the infix syntax and
the prefix syntax were isomorphic, in the sense that one could easily
transform one to the other in the editor.  Then people could share
code but nonetheless always work in the syntax of their choice.

I initially had the impression that this is what was being done with
Dylan.  Was this ever the intent, and if so, is it still in the plan?

Greg Anglin
Statistical Computing Laboratory



Wed, 02 Apr 1997 01:02:15 GMT  
 Prefix vs. Infix?

Quote:

> So prefix is better for compilers and programmers and tool writers
> and infix is better for humans.

Even if infix was inherently more readable, and not just coincidently
the way we were trained to read math, you can't automatically jump to
the conclusion that infix is always better for humans, as opposed to
programmers.  I use macros in Scheme extensively to build language
constructs that more closely match the problems my non-Scheme
programming "customers" are trying to deal with.  For them, dealing
with prefix is a heck of a lot easier than dealing with a language
that doesn't support the higher level abstractions that Scheme can be
made to do.

thant



Wed, 02 Apr 1997 03:22:07 GMT  
 Prefix vs. Infix?


   Apple has probably decided it would be prohibitively expensive to
   provide more than one production-quality front-end for their compiler.
   Twice the work on front-ends, twice the work on documentation, etc.,
   etc., etc.

Not really.  The added expense to produce and maintain a Lisp-like
front-end would be trivial.  The real problem is confusion in the
marketplace: we don't want to split the Dylan world into two different
groups talking two different dialects, reading two different sets of
textbooks, etc.  Once we all took a hard look at that option, we
realized that giving Dylan two public faces was a bad move.  If some
people quietly use prefix syntax for their own personal hacking, that
should cause little trouble.

Within the Gwydion project, everyone is now using infix syntax, even
though most of us are Old Lispers who philosophically prefer prefix.
Since infix is the official syntax for Dylan, we want to make sure we
support it properly, and we couldn't do that if we didn't use it
ourselves.  Every once in a while I get ticked off at some
particularly obnoxious bit of infix and decide that we should go back
to prefix-Dylan, but so far this is just blowing off steam.

-- Scott

===========================================================================

Principal Research Scientist            Phone:     412 268-2575
School of Computer Science              Fax:       412 268-5576 (new!)
Carnegie Mellon University              Latitude:  40:26:46 N
5000 Forbes Avenue                      Longitude: 79:56:55 W
Pittsburgh, PA 15213                    Mood:      :-)
===========================================================================



Wed, 02 Apr 1997 08:13:00 GMT  
 Prefix vs. Infix?


   Apple has probably decided it would be prohibitively expensive to
   provide more than one production-quality front-end for their compiler.
   Twice the work on front-ends, twice the work on documentation, etc.,
   etc., etc.

Not really.  The added expense to produce and maintain a Lisp-like
front-end would be trivial.  The real problem is confusion in the
marketplace: we don't want to split the Dylan world into two different
groups talking two different dialects, reading two different sets of
textbooks, etc.  Once we all took a hard look at that option, we
realized that giving Dylan two public faces was a bad move.  If some
people quietly use prefix syntax for their own personal hacking, that
should cause little trouble.

Within the Gwydion project, everyone is now using infix syntax, even
though most of us are Old Lispers who philosophically prefer prefix.
Since infix is the official syntax for Dylan, we want to make sure we
support it properly, and we couldn't do that if we didn't use it
ourselves.  Every once in a while I get ticked off at some
particularly obnoxious bit of infix and decide that we should go back
to prefix-Dylan, but so far this is just blowing off steam.

-- Scott

===========================================================================

Principal Research Scientist            Phone:     412 268-2575
School of Computer Science              Fax:       412 268-5576 (new!)
Carnegie Mellon University              Latitude:  40:26:46 N
5000 Forbes Avenue                      Longitude: 79:56:55 W
Pittsburgh, PA 15213                    Mood:      :-)
===========================================================================



Wed, 02 Apr 1997 05:13:39 GMT  
 Prefix vs. Infix?

Quote:

>Prefix is simpler, cleaner, and more elegant [...]

>Infix can be a terrible rat's nest, but we spend years teaching school
>children to deal with it, and the vast majority of mainstream
>programming languges use infix syntax. [...]

Another advantage of fully-parenthesized prefix is that it allows
multi-operand operators: like

        (+ u v w x y z)

instead of

        u + v + w + x + y + z

Large expressions are a pain to read either way, but I think the
first form is simpler.   ---Luigi



Wed, 02 Apr 1997 00:41:44 GMT  
 Prefix vs. Infix?

   It seems to me that it would be really nice if the infix syntax and
   the prefix syntax were isomorphic, in the sense that one could easily
   transform one to the other in the editor.

   I initially had the impression that this is what was being done with
   Dylan.  Was this ever the intent, and if so, is it still in the plan?

That was the plan, more or less, when both syntaxes were officially
recognized.  Now there's nothing for the infix syntax to be isomorphic
to.

-- Scott

===========================================================================

Principal Research Scientist            Phone:     412 268-2575
School of Computer Science              Fax:       412 268-5576 (new!)
Carnegie Mellon University              Latitude:  40:26:46 N
5000 Forbes Avenue                      Longitude: 79:56:55 W
Pittsburgh, PA 15213                    Mood:      :-)
===========================================================================



Wed, 02 Apr 1997 05:32:38 GMT  
 Prefix vs. Infix?

   I have the vague suspicion that there could be a somewhat deep reason
   {beyond just "Euler started us out this way"} why humans like to see
   mathematics with infix related to the kinds of natural languages that we are
   neurally wired up to do.

I guess that infix syntax acts as a reminder for what you are currently
talking about. If you have `(+ ...complex-term-1... ...complex-term-2)',
you may have forgotten what complex-term-2 is good for by the time you
reach it. Of course, if you use infix syntax: `...term1... + ...term2...',
you have to guess what term1 is good for until you reach the `+'.
  If it weren't for the typing overhead, I would like the Smalltalkish
keyword arguments best: function name at the beginning, and a reminder
in front of every argument. We find the same with indirect objects in
natural languages.

   Interestingly I find that postfix is much easier when actually performing
   manual operations (with an HP calculator), but terrible to read.

That's what people mean with `write-only language': Not enough redundancy.

   : -- Scott
--

"If I have not seen as far as others, then that's |  Axel Wienberg
 because giants were standing on my shoulders"    |  Hinzeweg 9
                        Hal Abelson               |  21075 Hamburg



Fri, 04 Apr 1997 18:14:14 GMT  
 
 [ 25 post ]  Go to page: [1] [2]

 Relevant Pages 

1. infix vs. prefix (was: Points, then Finish)

2. infix vs. prefix (was: Points, then Finish)

3. Infix vs Prefix

4. Prefix, Infix, RPN

5. Prefix, Infix, RPN

6. LOGO-L> RE: prefix/infix discussion

7. Infix/Prefix and Lisp Syntax

8. infix to prefix conversion

9. Prefix and infix anchors

10. Prefix, Infix, Postfix...

11. Prefix to Infix

12. Infix to Prefix .

 

 
Powered by phpBB® Forum Software