Patterns and integer/float literals

19 views
Skip to first unread message

Yannick Duchêne

unread,
Jun 23, 2018, 7:20:30 PM6/23/18
to ats-lang-users
This is about a corner case, probably of no importance for normal ATS2 use, but I don’t know after all.

I noticed there is a distinction in JSON with the integer and float literal used in patterns: whether it is a direct literal or a literal from a `#define`.

An example will be more easy to understand.

        #define TWO 2

        val m = 1

        val a = case m of
           | 1 => 1
           | TWO => 2
           | _ => 3

For the pattern in the first clause, I get a `P2Ti0nt`, while for the pattern in the second clause, I get a `P2Tintrep`. Something similar happens with float, except it’s `P2Tf0loat` and `P2Tfloat` instead. It does not occur with other types (or I missed it).

Is this just a Postiats internal detail or does it mean something relevant?

Hongwei Xi

unread,
Jun 23, 2018, 7:34:53 PM6/23/18
to ats-lan...@googlegroups.com
Intrep allows you to use negative integers as patterns.

A bit of explanation can be found at the following link:





--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/4e0b1dd1-3441-4814-81d2-7506cf3ce424%40googlegroups.com.

Yannick Duchêne

unread,
Jun 23, 2018, 8:29:45 PM6/23/18
to ats-lang-users


Le dimanche 24 juin 2018 01:34:53 UTC+2, gmhwxi a écrit :
Intrep allows you to use negative integers as patterns.

A bit of explanation can be found at the following link:


Waw, thanks. There was more in this question than I though, it was really to ask. 
Reply all
Reply to author
Forward
0 new messages