Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: John Prevost <prevost@maya.com>
To: Markus Mottl <mottl@miss.wu-wien.ac.at>
Cc: caml-list@inria.fr
Subject: Re: Labels and operators
Date: 24 Jun 2000 14:03:10 -0400	[thread overview]
Message-ID: <87zoob7y8x.fsf@isil.localdomain> (raw)
In-Reply-To: Markus Mottl's message of "Sat, 24 Jun 2000 16:44:20 +0200"

>>>>> "mm" == Markus Mottl <mottl@miss.wu-wien.ac.at> writes:

    mm> Well, sometimes we are really struck by the only
    mm> "two-dimensional" way in which we can write our sources
    mm> (top-down + left-right). If we could write into the depth,
    mm> there would be an elegant solution for adding arguments to
    mm> infix operators...

    >> The only solution I can think of is something like:
    mm> [snip]
    >> # "foo" =~ re "f";; - : bool = true # "foo" =~ re "f" ~pos:1;;
    >> - : bool = false
    >> 
    >> Which, well, works, but seems kind of nasty.

    mm> I normally try to avoid new operators, but if I wanted to have
    mm> a somewhat "powered up" version of "=~", your version here
    mm> would look fine to me - just read every piece aloud:

    mm>   "foo" =~ re "f" ~pos:1 "foo" - is matched by - regular
    mm> expression - "f" - at position one

    mm> This is pretty close to the human way of expressing
    mm> things. (Larry Wall, the linguist, would be proud of you! ;-)

Honestly, lingustics is a hobby of mine, and Larry (whom I've met)
doesn't impress me much.  ;>

    >> since the labelled args could not in any way shape or form be
    >> thought to go with either expr1 or expr2.  This would lead to
    >> things like:
    >> 
    >> # "foo" =~ ~pos:1 "f";; - : bool = false
    >> 
    >> being possible.  Don't know whether it's a great idea, though.

    mm> I prefer your first version: "subject", "verb" and "object"
    mm> are close together, the additional modifiers only follow
    mm> afterwards. To my knowledge, most natural languages would
    mm> order expressions like this.

This is a good point, which I'd forgotten.  Natural languages have the
habit of ordering things so that the main arguments of a word
(whatever sort of word that may be) are always closer to the word than
any optional hangers on.  Essentially, this is to avoid problems like:

I gave the mayor of the northernmost city of the northernmost province
of the northernmost nation a token.

If you draw a picture of the structure of this sentence, you end up
with a big deep tree in between the verb "gave" and "a token", which
is the primary argument of that verb.  If you shift things around a
little, you don't get the problem:

I gave a token to the mayor of ...

So your assertion that most natural languages would order expressions
this way is well founded, unless you happen to know that R->L
languages are actually statistically more common than L->R languages
in the world, and therefore we should be writing:

~pos:1 "f" re =~ "foo";

;>

Anyway, the current syntax is enough.  =~ re ... also means that you
could have =~ other things, which might be useful.  And, if I really
cared, camlp4 could give me the full horror of things like:

"foo" =~ /f/i

John.



      reply	other threads:[~2000-06-26 10:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-06-19  4:14 John Prevost
2000-06-22  1:48 ` Ken Wakita
2000-06-22  5:19 ` Jacques Garrigue
2000-06-24 14:44 ` Markus Mottl
2000-06-24 18:03   ` John Prevost [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zoob7y8x.fsf@isil.localdomain \
    --to=prevost@maya.com \
    --cc=caml-list@inria.fr \
    --cc=mottl@miss.wu-wien.ac.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox