MiniD 2 - Tentative Release Candidate 1

davidl davidl at 126.com
Wed Dec 10 23:06:19 PST 2008


在 Thu, 11 Dec 2008 12:45:19 +0800,Jarrett Billingsley <jarrett.billingsley at gmail.com> 写道:

> On Wed, Dec 10, 2008 at 10:21 PM, davidl <davidl at 126.com> wrote:
>> That's not true. All about compiler is easeing developers. Why not issue a compiler
>> error/warning when it reaches some code like:
>>
>> function opApply(m) = coroutine function opApply(m)
>>
>> 1. the local var m shadows the arg m _in 1 declaration_
>> 2. this could be a general mistake which could possibly be made by people with
>>   a strong type programming background
>>
>> Probing this kind of code seems troublesome, I will be glad to see MiniD can give an error
>> on this kind of code someday.
>
> I'm not sure that's a good idea.  The compiler does already issue an
> error if you declare a local multiple times in the same function:
>
> local x
>
> {
>     local x // error, shadows previous declaration
> }
>
> But if that is generalized to disallowing local variable declarations
> that shadow locals in any enclosing functions as well, .. ech.  It
> seems a bit much.  I might implement it, I might not.
>

Umm, I misunderstood the function expression system in MiniD. I didn't expect a
function expression system just thinking that the assignment is just assign a func
literal to the left hand side as a declaration. 

Because in D you can do a lot coding like following:

void delegate() f= void delegate(){
}

It's obvious for you as the MiniD creator to distinguish the difference. But I doubt
for normal developer, they could be somewhat confused.

I think a little bit special rule should be added:

function f() = function f(){}   ///disallowed
function f() = function f_exp(){} // allowed

It's a safer rule for people to rename the function with another name, this is 
more clear that for a developer realizing that, he's not doing something like 
I had thought "I assigned a named func literal to the l-value in the declaration,
which is similar to the D code style". 

And I can hardly see any very bad restriction this could result. And in my opinion
such function expression literal can even be restricted that it doesn't own a name. 
Because in such case a name doesn't do any good. For people want to return a named
literal, they just simply rewrite it to:

function f()
{
   return function f_exp(){}   // allow the named function expressoin literal here
}

function f() = function f_exp(){} // under stricter rule, f_exp is not allowed. you write
it:
function f() = function (){}

Please correct me here, if I'm wrong. 

Another thing is I really didn't pay attention to parallel in MiniD. So , the thread
is not tradition thread in D? It's actually just a coroutine?

I just thought that coroutine was implemented as several different MiniD interpret 
context for each coroutine, and resume a coroutine just simply resuming that interpret
context which could be very costless. 

And the thread I though could be some native threads with several MiniD interpreters working.



More information about the Digitalmars-d-announce mailing list