Talk:First Tutorial

From Nemerle Homepage

 <quote>
 In (6) we call the read_lines nested method, with initial line number of 0 to read the file and print out line count.
 </quote>

Shouldn't be possible to define a default value for this parameter in the function prototype ?
Wikisearching the site with Default value didn't give any clue if this feature is supported or not.

As this parameter is an implementation only parameter, it should not clutter client code.

--Sebastien 00:13, 4 Aug 2005 (CEST)


Well you're right, that it is a implementation detail. Default parameters are supported, but only for global functions (it is described in http://nemerle.org/svn/nemerle/trunk/NEWS only). It would be nice to have it supported for local functions (exactly for the scenario above), I'll file a suggestion report for it.

--Malekith 13:53, 7 Aug 2005 (CEST)

Why not a simplier/shorter Hello World ?

I'm refering to this code:

 
 class Hello
 {
   static Main () : void
   {
     System.Console.WriteLine ("Hello world!");
   }
 }

Why can't it be written as follow ?

 
 System.Console.WriteLine ("Hello world!");

I known the first code maps as-is with C# and Java equivalent but what's the point of declaring a class and a satic method in the sole purpose to indicate the entry point of the program ?
In Python, there is a default entry point created when the first non declarative statement is encountered.
You can however specify explicitely your entry point.

Some .NET languages supply a default entry point like this and behind the scenes the same kind of class explicely defined above is generated in the IL.
Is there a design choice or implementation issue that has dictated this ?

--Sebastien 14:29, 19 Aug 2005 (CEST)


The short answer is that you can ;)

From the NEWS file:

   * Code can be entered at the top level, without a class and the Main
     method. So the classic example becomes:
       System.Console.Write ("Hello marry world!\n");
     That is, it put alone in the file will just compile. You can define
     classes, issue using declarations before the actual code. You can also
     define local functions with def (which gives you type inference).
     Yeah, we know this is only useful in write-once-run-once-throw-away
     kind of programs and testing, but it is nice anyway :-)

--Malekith 09:33, 21 Aug 2005 (CEST)

tree
  • First Tutorial
remember
You are very welcome to contribute to the documentation here!