Talk:Grok Base structure of programs
From Nemerle Homepage
In this code:
static reverse_array (ar : array [int]) : void
{
def loop (left, right) {
when ((left : int) < right) {
def tmp = ar[left];
ar[left] = ar[right];
ar[right] = tmp;
loop (left + 1, right - 1)
}
}
loop (0, ar.Length - 1)
}
Q: Is it actually necessary to state "(left : int)"? Couldn't you simply write "when(left < right)" and let the type inference engine figure it out, since the call to "loop()" provides an integer value? -- resuna@gmail.com
A: Yes, the inferencer can handle this code without type annotation. I guess it is here mainly because our earlier implemenation had problems with it. Maybe it should be removed - it looks a little bit superfluous here, but on the other hand it shows one of the ways of enforcing type of expression. --Nazgul 20:14, 22 Jun 2005 (CEST)
I have removed the type enforcement -- it wasn't explaining anything, since there was no mention of it in the description text anyway. --Malekith 21:00, 22 Jun 2005 (CEST)
Suggestion: You write that "If you have ever programmed in ... python ... , you know about string interpolation. Although python has string interpolation in the
%(variable_name)s interpolation" % {'variable_name': 'string'}
sense, it seems to be a *far* less common form than is the printf-style string interpolation. Thus, even moderately experienced Python programmers may not be familiar with string interpolation in the sense that you mean it here. My point is, it should probably be removed from that list, and the "any p-language" phrase removed.
Just a thought. --Llimllib 08:13, 14 August 2006 (CEST)
You write: "One interesting thing about this example is the usage of the type enforcement operator -- colon (:). We use it to enforce the left type to be int. We could have as well written def loop (left : int, right) {. This are simply two ways to achieve the same thing."
I have no idea what example you're talking about. I guess that it's the one from the previous section to this comment? If so, I don't see where the usage of the colon (:) operator is that this comment talks about. In fact, I'm quite confused about the meaning of this quotation. --Llimllib 08:21, 14 August 2006 (CEST)
One last kvetch
You write: "Type of two-dimensional integer array is array [2, int], while the expression constructing it is array .[2] [[1, 2], [3, 4]]. They are accessed using the comma-syntax: t[1,0]."
This section is too brief, and not very helpful. What does the .[2] mean? Show me some complete code examples of creating and using a multidimensional array. --Llimllib 08:28, 14 August 2006 (CEST)
Thanks, I have edited the text a bit. Hope this helps! --Malekith 11:16, 15 August 2006 (CEST)
protected visibility
Is the omission of the protected access attribute in the Methods section deliberate? I suppose it is more part of the whole "object oriented" thing than the base structure, but for completion's sake, it might as well be listed here, no?
Also, does Nemerle support access attributes for "top-level" types?
Ben 21:24, 18 September 2008 (CEST)
imperative loops
The section on imperative loops mainly explains the mutable attribute, are loops proper explained elsewhere in this tutorial? There are some mentions of foreach throughout the wiki, but I am not sure it is authoritatively explained, would it be appropriate to put that here?
Ben 21:34, 18 September 2008 (CEST)