Re: function notation and linguistics (was: What's so great about lisp?)



First, I'd like to say that your points are very valid and the theory of
S-expressions was probably motivated by syntax trees of natural
languages. Lisp is designed to be its own metalanguage: by exposing its
AST in an easy-to-manipulate form, it effectively encourages (a)
building new languages on that same format and (b) reasoning about
programs written in itself. Prolog is similar in this respect
(homoiconic).

A parenthesised expression in Lisp corresponds to the idea of
"expression" (or "phrase") in linguistics. A symbol in Lisp corresponds
to the idea of "word" (or "idiom") in linguistics. The idea of "clause"
does not have a clear counterpart in Lisp, but in Logo it is modelled as
a list. (An anonymous function serves some of the same purpose as a
subordinate clause.)

Some other points:

In <nuclei-20050924143843@xxxxxxxxxxxxxxxxxxxxxxx> ram@xxxxxxxxxxxxxxxxxx (Stefan Ram) writes:

>while( x < 0 )f( x );
> can be regarded as an application of the nucleaus "while"
> to the satellites "x < 0" and "f( x );". (The semantics are
> that of a function, mapping an expression and a statement
> to another statement.)

This is why some Logos have:

while [:x < 0] [f :x]

> So eventually, every structure in every language is the
> application of a nucleaus to satellites (sometimes, however,
> the details are open to interpretation, for example, which
> constituent in a given text has the role of the nucleus.).

Definitely. For example, in "red hat" we would be tempted to describe
"hat" as the nucleus; but it's clear that "hat" needs no parameters, for
example, in the clause "eat the hat". So, in type-based grammars, we
usually make "red" a (unary) function and "hat" a constant (= nullary
function).

When natural languages have multiple ways of using a word, we tag
expressions with explicit "type declarations":

"John sees a red hat"
-> (S (NP (N john)) (VP (V sees) (NP (A red) (NP (N hat)))))
"I like red"
-> (S (NP (PRON I)) (VP (V like) (NP (N red))))

See how the tags differ for "red" in the trees? In programming
languages, we require every word to behave syntactically similarly in
all contexts.

(Actually, my example parse trees _still_ use NP in a polymorphic way;
it's used for both N expressions and A,NP expressions. Prolog accounts
for this by internally treating NP/1 and NP/2 as different tags.)

Panu

--
personal contact: atehwa@xxxxxx, +35841 5323835, +3589 85619369
work contact: panu.kalliokoski@xxxxxxxxxxx, +35850 3678003
kotisivu (henkkoht): http://www.iki.fi/atehwa/
homepage (technical): http://sange.fi/~atehwa/
.



Relevant Pages

  • Re: Good functional programming habbit?
    ... The context is "is lisp a functional language?". ... expressions (in languages that make such a distinction). ... Lisp doesn't distinguish between statements and expressions. ... S-K calculus to be a "functional programming language". ...
    (comp.lang.lisp)
  • Re: Where does the drive to syntax come from?
    ... > than parens and prefix notation.) ... > non-programmers have an idea what languages should look like and it's ... data trees. ... (And so lisp is an ~first-order data type in lisp). ...
    (comp.lang.lisp)
  • Re: Where does the drive to syntax come from?
    ... new programmers--who *want* elaborate syntax. ... One part of me thinks that maybe this is due to the pervasive influence of non-Lisp languages; even non-programmers have an idea what languages should look like and it's not Lisp. ... meaning code trees are simply a subset of data trees. ...
    (comp.lang.lisp)
  • Re: How does LISP decide the order to evaluate consecutive statements?
    ... >> I'm a newbie to LISP and all the languages I've at least been exposed to in ... > That is not true of these languages. ... expressions, not statements (actually, I think A might be something ...
    (comp.lang.lisp)
  • When static typing is worth it
    ... typed languages like Lisp. ... developed more quickly in modern statically typed languages than ... static type system and remove run-time checks. ... incurs a run-time error if the list is ...
    (comp.lang.lisp)