Enumerations

Hello,

Is it possible to declare an enumeration of a given size, whose enumerators are not necessarily sequential from 0 to the top? For example, can I declare an enumeration Foo the size of an int, whose only valid values are Bar, Baz, and Qux, where Bar is represented by 1, Baz by 30, and Qux by 16?

Thanks,
Shea

Ah, and how does the preprocessor know not to substitute in Bar in the LHS of the macdef?> On Nov 15, 2014, at 6:59 PM, gmhwxi gmh...@gmail.com wrote:

How about:

#define Bar 1
#define Baz 30
#define Quz 16

abst@ype Foo(i:int) = int

macdef Bar = $extval (Foo(Bar), “1”)

fun
foo{i:int | i != Bar} (x: Foo(i)): void = …

On Saturday, November 15, 2014 6:50:03 PM UTC-5, Shea Levy wrote:
Ah, yes that will do. Followup question: is it possible to use Foo in existentials/constraints? Can I for example write a function that takes any Foo except Baz?

On Nov 15, 2014, at 6:43 PM, gmhwxi <gmh...@gmail.com <javascript:>> wrote:

How about the following approach:

abst@ype Foo = int
macdef Bar = $extval (Foo, “1”)
macdef Baz = $extval (Foo, “30”)
macdef Quz = $extval (Foo, “16”)

On Saturday, November 15, 2014 6:16:58 PM UTC-5, Shea Levy wrote:
Hello,

Is it possible to declare an enumeration of a given size, whose enumerators are not necessarily sequential from 0 to the top? For example, can I declare an enumeration Foo the size of an int, whose only valid values are Bar, Baz, and Qux, where Bar is represented by 1, Baz by 30, and Qux by 16?

Thanks,
Shea


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...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com <javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/10dcc58a-76cd-45a4-add9-706218ee6895%40googlegroups.com https://groups.google.com/d/msgid/ats-lang-users/10dcc58a-76cd-45a4-add9-706218ee6895%40googlegroups.com?utm_medium=email&utm_source=footer.


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-user...@googlegroups.com mailto:ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com mailto:ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/15632e9d-6077-4919-ac84-6665e1b07f77%40googlegroups.com https://groups.google.com/d/msgid/ats-lang-users/15632e9d-6077-4919-ac84-6665e1b07f77%40googlegroups.com?utm_medium=email&utm_source=footer.

Ah, I should probably read up on stadef :slight_smile: Thank you!> On Nov 15, 2014, at 7:04 PM, gmhwxi gmh...@gmail.com wrote:

Actually, I was not sure myself. I had to try it :slight_smile:

The following style is probably better:

stadef Bar = 1 // Bar is static

abst@ype Foo(i:int) = int

macdef Bar = $extval (Foo(Bar), “1”) // Bar is dynamic

fun
foo{i:int | i != Bar} (x: Foo(i)): void = …

On Saturday, November 15, 2014 7:01:10 PM UTC-5, Shea Levy wrote:
Ah, and how does the preprocessor know not to substitute in Bar in the LHS of the macdef?

On Nov 15, 2014, at 6:59 PM, gmhwxi <gmh...@gmail.com <javascript:>> wrote:

How about:

#define Bar 1
#define Baz 30
#define Quz 16

abst@ype Foo(i:int) = int

macdef Bar = $extval (Foo(Bar), “1”)

fun
foo{i:int | i != Bar} (x: Foo(i)): void = …

On Saturday, November 15, 2014 6:50:03 PM UTC-5, Shea Levy wrote:
Ah, yes that will do. Followup question: is it possible to use Foo in existentials/constraints? Can I for example write a function that takes any Foo except Baz?

On Nov 15, 2014, at 6:43 PM, gmhwxi <gmh...@gmail.com <>> wrote:

How about the following approach:

abst@ype Foo = int
macdef Bar = $extval (Foo, “1”)
macdef Baz = $extval (Foo, “30”)
macdef Quz = $extval (Foo, “16”)

On Saturday, November 15, 2014 6:16:58 PM UTC-5, Shea Levy wrote:
Hello,

Is it possible to declare an enumeration of a given size, whose enumerators are not necessarily sequential from 0 to the top? For example, can I declare an enumeration Foo the size of an int, whose only valid values are Bar, Baz, and Qux, where Bar is represented by 1, Baz by 30, and Qux by 16?

Thanks,
Shea


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...@googlegroups.com <>.
To post to this group, send email to ats-l...@googlegroups.com <>.
Visit this group at http://groups.google.com/group/ats-lang-users http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/10dcc58a-76cd-45a4-add9-706218ee6895%40googlegroups.com https://groups.google.com/d/msgid/ats-lang-users/10dcc58a-76cd-45a4-add9-706218ee6895%40googlegroups.com?utm_medium=email&utm_source=footer.


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...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com <javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/15632e9d-6077-4919-ac84-6665e1b07f77%40googlegroups.com https://groups.google.com/d/msgid/ats-lang-users/15632e9d-6077-4919-ac84-6665e1b07f77%40googlegroups.com?utm_medium=email&utm_source=footer.


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-user...@googlegroups.com mailto:ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com mailto:ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/a462e06e-a55a-463e-950e-1ac4010efdc9%40googlegroups.com https://groups.google.com/d/msgid/ats-lang-users/a462e06e-a55a-463e-950e-1ac4010efdc9%40googlegroups.com?utm_medium=email&utm_source=footer.

Ah, yes that will do. Followup question: is it possible to use Foo in existentials/constraints? Can I for example write a function that takes any Foo except Baz?> On Nov 15, 2014, at 6:43 PM, gmhwxi gmh...@gmail.com wrote:

How about the following approach:

abst@ype Foo = int
macdef Bar = $extval (Foo, “1”)
macdef Baz = $extval (Foo, “30”)
macdef Quz = $extval (Foo, “16”)

On Saturday, November 15, 2014 6:16:58 PM UTC-5, Shea Levy wrote:
Hello,

Is it possible to declare an enumeration of a given size, whose enumerators are not necessarily sequential from 0 to the top? For example, can I declare an enumeration Foo the size of an int, whose only valid values are Bar, Baz, and Qux, where Bar is represented by 1, Baz by 30, and Qux by 16?

Thanks,
Shea


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-user...@googlegroups.com mailto:ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com mailto:ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/10dcc58a-76cd-45a4-add9-706218ee6895%40googlegroups.com https://groups.google.com/d/msgid/ats-lang-users/10dcc58a-76cd-45a4-add9-706218ee6895%40googlegroups.com?utm_medium=email&utm_source=footer.

Actually, I was not sure myself. I had to try it :slight_smile:

The following style is probably better:

stadef Bar = 1 // Bar is static

abst@ype Foo(i:int) = int

macdef Bar = $extval (Foo(Bar), “1”) // Bar is dynamic

fun
foo{i:int | i != Bar} (x: Foo(i)): void = …On Saturday, November 15, 2014 7:01:10 PM UTC-5, Shea Levy wrote:

Ah, and how does the preprocessor know not to substitute in Bar in the LHS
of the macdef?

On Nov 15, 2014, at 6:59 PM, gmhwxi <gmh...@gmail.com <javascript:>> wrote:

How about:

#define Bar 1
#define Baz 30
#define Quz 16

abst@ype Foo(i:int) = int

macdef Bar = $extval (Foo(Bar), “1”)

fun
foo{i:int | i != Bar} (x: Foo(i)): void = …

On Saturday, November 15, 2014 6:50:03 PM UTC-5, Shea Levy wrote:

Ah, yes that will do. Followup question: is it possible to use Foo in
existentials/constraints? Can I for example write a function that takes any
Foo except Baz?

On Nov 15, 2014, at 6:43 PM, gmhwxi gmh...@gmail.com wrote:

How about the following approach:

abst@ype Foo = int
macdef Bar = $extval (Foo, “1”)
macdef Baz = $extval (Foo, “30”)
macdef Quz = $extval (Foo, “16”)

On Saturday, November 15, 2014 6:16:58 PM UTC-5, Shea Levy wrote:

Hello,

Is it possible to declare an enumeration of a given size, whose
enumerators are not necessarily sequential from 0 to the top? For example,
can I declare an enumeration Foo the size of an int, whose only valid
values are Bar, Baz, and Qux, where Bar is represented by 1, Baz by 30, and
Qux by 16?

Thanks,
Shea


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...@googlegroups.com.
To post to this group, send email to ats-l...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/10dcc58a-76cd-45a4-add9-706218ee6895%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/10dcc58a-76cd-45a4-add9-706218ee6895%40googlegroups.com?utm_medium=email&utm_source=footer
.


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...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/15632e9d-6077-4919-ac84-6665e1b07f77%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/15632e9d-6077-4919-ac84-6665e1b07f77%40googlegroups.com?utm_medium=email&utm_source=footer
.

How about the following approach:

abst@ype Foo = int
macdef Bar = $extval (Foo, “1”)
macdef Baz = $extval (Foo, “30”)
macdef Quz = $extval (Foo, “16”)On Saturday, November 15, 2014 6:16:58 PM UTC-5, Shea Levy wrote:

Hello,

Is it possible to declare an enumeration of a given size, whose
enumerators are not necessarily sequential from 0 to the top? For example,
can I declare an enumeration Foo the size of an int, whose only valid
values are Bar, Baz, and Qux, where Bar is represented by 1, Baz by 30, and
Qux by 16?

Thanks,
Shea

How about:

#define Bar 1
#define Baz 30
#define Quz 16

abst@ype Foo(i:int) = int

macdef Bar = $extval (Foo(Bar), “1”)

fun
foo{i:int | i != Bar} (x: Foo(i)): void = …On Saturday, November 15, 2014 6:50:03 PM UTC-5, Shea Levy wrote:

Ah, yes that will do. Followup question: is it possible to use Foo in
existentials/constraints? Can I for example write a function that takes any
Foo except Baz?

On Nov 15, 2014, at 6:43 PM, gmhwxi <gmh...@gmail.com <javascript:>> wrote:

How about the following approach:

abst@ype Foo = int
macdef Bar = $extval (Foo, “1”)
macdef Baz = $extval (Foo, “30”)
macdef Quz = $extval (Foo, “16”)

On Saturday, November 15, 2014 6:16:58 PM UTC-5, Shea Levy wrote:

Hello,

Is it possible to declare an enumeration of a given size, whose
enumerators are not necessarily sequential from 0 to the top? For example,
can I declare an enumeration Foo the size of an int, whose only valid
values are Bar, Baz, and Qux, where Bar is represented by 1, Baz by 30, and
Qux by 16?

Thanks,
Shea


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...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/10dcc58a-76cd-45a4-add9-706218ee6895%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/10dcc58a-76cd-45a4-add9-706218ee6895%40googlegroups.com?utm_medium=email&utm_source=footer
.