caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Maxence Guesdon <Maxence.Guesdon@inria.fr>
To: Alain Frisch <alain.frisch@lexifi.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Changing precedence and placement of attributes
Date: Mon, 9 Mar 2015 14:57:29 +0100	[thread overview]
Message-ID: <20150309145729.6e5d0cf0@alcazar2> (raw)
In-Reply-To: <54FDA20D.1000503@lexifi.com>

On Mon, 09 Mar 2015 14:37:17 +0100
Alain Frisch <alain.frisch@lexifi.com> wrote:

> On 03/09/2015 02:16 PM, Maxence Guesdon wrote:
> > I'm quite "shocked" as it becomes inconsistent with other precedences
> > in type definitions. By now
> >    int * int list
> > is parsed as
> >    int * (int list)
> > and not as
> >    (int * int) list
> >
> > I would expect attributes to be associated the same way.
> 
> Attributes really don't behave as type constructors; for instance,
> 
>     (int, int) [@foo]
> 
> is not allowed in type expressions.

Of course.

> I'd be more concerned about how attributes behave across various 
> syntactic categories for similarly looking fragments.  For instance, in 
> expressions
> 
>    x * y [@foo]
> 
> is already currently parsed as
> 
>    (x * y) [@foo]
> 
> 
> But
>   - "x, y [@foo]" is parsed as "x, (y [@foo])"
>   - "x * y [@foo] * z" is accepted as an expression, and parsed as "(x * 
> y)[@foo] * z".

This looks more intuitive/natural to me and more consistent with the
rest of the language.

I'm thinking about newcomers, when I'll have to explain them that rather
than writing "int * int list", they'll need parentheses in "(int * int)
list" to talk about list of pairs, but when it comes to attributes it's
the contrary. Sure, the language was not complicated enough :) Even if
attributes are not type constructors, one would expect some consistent
"feeling".

> > How would be parsed the following:
> >    int * int [@foo] * int
> > ?
> 
> This would be rejected.  Doing the same as for expression would be 
> weird, since * is a n-ary construction in types, not a binary operator.

If I understand, you mean that
  type t = int * int [@foo] * int
would be rejected and we use instead:
  type t = int * (int [@foo]) * int

Again, it's really not natural to me.
- m

> (Note: Jérémie prepared a nice table in his pull request 152 on Github; 
> it shows how various forms are interpreted currently and after the change.)
> 
> 
> Alain

  reply	other threads:[~2015-03-09 13:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-09 11:27 Alain Frisch
2015-03-09 13:16 ` Maxence Guesdon
2015-03-09 13:37   ` Alain Frisch
2015-03-09 13:57     ` Maxence Guesdon [this message]
2015-03-09 14:27       ` Leo White
2015-03-09 16:22         ` Ben Millwood

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=20150309145729.6e5d0cf0@alcazar2 \
    --to=maxence.guesdon@inria.fr \
    --cc=alain.frisch@lexifi.com \
    --cc=caml-list@inria.fr \
    /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).