Circular Aliases

74 views
Skip to first unread message

Francis Lalonde

unread,
May 27, 2017, 9:11:29 AM5/27/17
to ceylon-users
Coming back to ceylon after a year for a first real project, I've decided to write a TOML parser using parcey.

I'm trying to define the TOML model top-down using aliases, but I've hit my first bump trying to define the recursive structure of TOML values :

alias TOMLKey => String;

alias TOMLValue => String | Integer | Float | Boolean | Date | Time | DateTime | TOMLArray | TOMLMap;

alias TOMLMap => Map<TOMLKey, TOMLValue>;

alias TOMLArray => List<TOMLValue>;

I think I understand why, but I dont know know how to specify it another way.

John Vasileff

unread,
May 27, 2017, 11:59:49 AM5/27/17
to ceylon...@googlegroups.com
Yes, it's true that type aliases cannot be recursively defined. They are a compile time fiction and must ultimately simplify to non-alias types.

But, you should be able to use classes or interfaces to define TOMLMap and TOMLArray.
--
You received this message because you are subscribed to the Google Groups "ceylon-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-users...@googlegroups.com.
To post to this group, send email to ceylon...@googlegroups.com.
Visit this group at https://groups.google.com/group/ceylon-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-users/fb2dd5ba-ce56-4cbf-8255-3d8019e804d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lisi

unread,
May 28, 2017, 8:45:58 AM5/28/17
to ceylon-users
Investigate ceylon.json as example:



суббота, 27 мая 2017 г., 16:11:29 UTC+3 пользователь Francis Lalonde написал:

Nikolay Rychkov

unread,
Jul 6, 2017, 5:57:02 PM7/6/17
to ceylon-users
Ты что на цейлоне кодишь до сих пор?

воскресенье, 28 мая 2017 г., 15:45:58 UTC+3 пользователь Lisi написал:
Reply all
Reply to author
Forward
0 new messages