[nem-en] recursive types
Wiktor Zychla
wzychla at vulcan.edu.pl
Wed Sep 22 16:30:04 CEST 2004
Hello there,
I've finally put my hands on Nemerle compiler (2.1) and try to get familiar with the language. After a few hours I have few observations and few questions to ask.
1. The binary modules produced by ncc compiler are dependent of Nemerle.dll library. From the perspective of an experienced developer this could be a major inconvenience for many reasons. Would it be possible to add an option to link the contents of the library with the binaries?
2. In my opinion, 'module' and 'variant' keywords are redundant and could be dropped from the language (thus following Ockham's Razor Rule). Especially in the case of "variants", is there a sensible explanation why the "class" keyword could not be used in case of recursive types?
Several issues about recursive types.
3. Why following declarations are not equivalent:
class Base {
public ID : int;
}
variant Tree : Base {
| Node { left : Tree; right : Tree; v : object; }
| Empty
public override ToString() : string
{
match( this ) {
| Node( left, right, v ) =>
string.Format( "[{0} {1} {2}]", left, v, right );
| Empty =>
string.Empty;
}
}
}
and
variant Tree : Base {
| Node { left : Tree; right : Tree; v : object; }
| Empty
public ID : int;
public override ToString() : string
{
match( this ) {
| Node( left, right, v ) =>
string.Format( "[{0} {1} {2}]", left, v, right );
| Empty =>
string.Empty;
}
}
}
in the former case we got Tree() public constructor while in the latter we got Tree( int ) public constructor that forces the client code to initialize the ID field. Could you explain it?
4. What's wrong with this code (does not compile with "unbounded type name Term" message):
variant Lambda {
| Abs { Name : Id; Term : Lambda; }
| App { Term1 : Lambda; Term2 : Lambda; }
| Id { Name : string; }
public override ToString() : string
{
match( this ) {
| Abs( Name, Term ) =>
string.Format( "%{0}.{1}", Name, Term );
| App ( Term1, Term2 ) =>
string.Format( "({0})({1})", Term1, Term2 );
| Id ( Name ) =>
Name;
}
}
}
Kind regards,
Wiktor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /mailman/pipermail/devel-en/attachments/20040922/d6d78d23/attachment-0002.html
More information about the devel-en
mailing list