caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <markus@oefai.at>
To: Oliver Bandel <oliver@first.in-berlin.de>
Cc: Oleg <oleg_inconnu@myrealbox.com>, caml-list@inria.fr
Subject: Re: [Caml-list] Calling a function with a self-defined type as argument
Date: Thu, 22 Aug 2002 15:15:20 +0200	[thread overview]
Message-ID: <20020822131519.GA32496@bach.ai.univie.ac.at> (raw)
In-Reply-To: <Pine.LNX.3.95.1020822143542.635A-100000@first.in-berlin.de>

Oliver Bandel schrieb am Thursday, den 22. August 2002:
> But the Line ("text")-argument is only complete as a Line(),
> if Line() has a higher priority than the function-call.
> I have *one* argument, which is complete if given EMPTY,
> and complete if given Line ("argument").

The parser attempts to parse arguments of a function call, all of
which must be expressions. "Line" is not an expression, it's just a
data constructor. To disambiguate things, you have to use parentheses.
Note that your proposal that the compiler should use type definitions
to see how many arguments constructors take would make sources really
unreadable for humans.  Things are perfect as they are.

> Shouldn't be types have a higher priority than calls
> in this case?

"Line" is not a type but a data constructor. It just allows you to
discriminate between values.

> Is Line() in this example handled like an ordinary function?

Even if it were a function, you'd still need parentheses, otherwise you'd
get into troubles with partial function applications, which sometimes
need disambiguation, because the semantics wouldn't be necessarily clear.

> But I want here a complete picture, and I thought
> the compiler would put the parts together: How to
> put them together is clear: I have said it him in the
> type-declaration.

It may be clear here but not always. Even if things can be tractably
analyzed by an intelligent compiler, you still need to enforce readability
of sources. It would be absolute hell to let people parse such programs,
because they'd constantly have to look up type definitions in other
places to parse things correctly. Not a problem for a compiler - huge
problem for humans!

LG,
Markus

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2002-08-22 13:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-22  1:11 Oliver Bandel
2002-08-22  1:43 ` SooHyoung Oh
2002-08-22  1:50 ` Oleg
2002-08-22  2:20   ` Pal-Kristian Engstad
2002-08-22  2:32     ` Dimitri Ara
2002-08-22 12:40   ` Oliver Bandel
2002-08-22 13:15     ` Markus Mottl [this message]
2002-08-22 20:40       ` Oliver Bandel
2002-08-22  2:04 ` Dimitri Ara
2002-08-22 12:47   ` Oliver Bandel
2002-08-22 13:13     ` Sven LUTHER
2002-08-22 14:07     ` Remi VANICAT
2002-08-22 14:15       ` Markus Mottl
2002-08-22 23:51   ` Pixel

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=20020822131519.GA32496@bach.ai.univie.ac.at \
    --to=markus@oefai.at \
    --cc=caml-list@inria.fr \
    --cc=oleg_inconnu@myrealbox.com \
    --cc=oliver@first.in-berlin.de \
    /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;
as well as URLs for NNTP newsgroup(s).