[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Human languages (was Re: expressions vs. statements)

   From: Jan Wender <j.wender@science-computing.de>
   One point to consider: Most (if not all) human languages also have
   devices to turn nouns into verbs and vice versa....  So either you
   could conclude, that programming languages also should have
   features like this or that human languages do not lend themselves
   as models for programming languages.

Definitely, programming languages should also have means for
transforming nouns into verbs and vice versa.

For transforming a verb into a noun, you just make a closure.  The
language just has to make sure that when that closure is applied to
arguments, it's in a position that only verbs, er, procedures that
don't return values, can take up.

For transforming a noun into a verb ... Assuming a Scheme-like
language where all verbs end in exclamation points, one could add
syntactic sugar so that

    (f! x . ys) ==> (set! x (f x . ys))

(Translate the above into your preferred syntax....)

   The meaning of parts of human language utterances depend usually on
   their context. (My linguistic vocabulary is rather rusty, so excuse any
   blunders) In languages with subject-verb-object sentence structures the
   distinction between subject and object is made on the position in the
   sentence (at least in languages like English, other languages put some
   affixes on the words and have no prescribed order).

If I see the English sentence "Colorless green ideas sleep furiously",
even if I don't know what the sentence means, I can tell that in that
sentence, "sleep" is being used as a verb and not as a noun.

(OK, there are sentences like "Time flies like an arrow", where you
have to make a theory about the meaning of the whole sentence in order
to know which word is the verb, but such sentences make up a very
small proportion of the speech we actually hear and read.)

   So the difference,
   if "a = 0" is a bug or not depends on the position in the utterance: "if
   (a=0) {..}" is an error, "if (b) {a=0}" probably not.

But if you have a statement "if (a = f(x)) { ... }", you have to know
a bit more about the intention of the programmer before you can mark
it as an error.  Maybe the programmer really did intend to assign f(x)
to a and skip over that block when f(x) was zero.  Or maybe that =
should have been a ==.

   This is something
   humans do a lot in speech understanding, so they are rather skilled in
   solving these problems.

Judging from how commonly the "if (a = 0) {...}" bug appears in C
programs, it seems that humans are *not* very skilled at solving this
sort of problem.

Cartman: Kyle, you know when I called you a dirty Jew?  I'm sorry, I
  didn't mean it--you're not a Jew. 
Kyle: What? Yes, I am a Jew!
Cartman: No, don't be so hard on yourself.
== Seth Gordon == sethg@ropine.com == http://ropine.com/ == std. disclaimer ==