Re: Re: suggestions for newbee

David Bernard <[email protected]> Wed, 06 Jul 2005 22:50:35 +0200
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
Daniel Bonniot wrote:

> Hi David, and welcome in the community!
>
> Some answers in addition to Artem's ones.
>
>> * remove 'var' and 'let'. If 'let' is to define constantes (!= 
>> immutable) then every constantes have name in uppercase (only), and 
>> variable start by lowercase. Compiler could automaticaly detect this 
>> and choose internaly between 'var' and 'let' rules.
>
>
> One of the benefits of 'var' and 'let' is to allow local variable 
> definitions where the compiler automatically guesses the variable's 
> type (a form of type inference). You couldn't have that with the 
> lowercase/uppercase convention only.

??
Why 'Type inference' couldn't be use without "var" or "let" ? Compiler 
could detect first usage of a local variable ?

>
>> * Why 'Type Inference' isn't systematic, and can't be use for arrays 
>> ? Could you give me samples ?
>
>
> Type inference means that the compiler "guesses" a type, instead of 
> requiring it to specify it. It happens in several situations in Nice:
>
> let x = "..."; // x has type String
>
> let l = new ArrayList();
> // l has type ArrayList<T> for some T which will be discovered later

details ?

>
> let f = int x => x.toString();
> // f is a function of type int->String
>
> Where did you read it cannot be used for arrays? This should be fixed, 
> because you can:
>
> let a = [1, 2, 3];
> // a is an int[]


Sorry I misunderstood, it's not arrays it's parameterized type. Does it 
mean "let I = new ArrayList<T>()" doesn't work.

>
>
>> * like generate a default Constructor, why not generate default 
>> implementation for toString() (e.g. generate a string following the 
>> format of JSON http://www.json.org) and equals() comparison by fields 
>> (usefull for test) ?
>
>
> Given the somewhat arbitary default implementation of toString, and 
> that it is commonly used for debugging, I suppose a more friendly 
> implementation of toString would be useful. The only downside could be 
> slightly larger classes, but the overhead should be pretty small.
>
> equals is a bit more tricky, because it is more likely to change the 
> behaviour of the program. There are also decisions to make like 
> shallow vs deep comparison (and with deep, there is the use of 
> cycles). So maybe this could be done only explicitely, for instance if 
> the class implements a certain flag interface (ShallowEquals, 
> DeepEquals, ...).
>
>> I'm a newbee in compilation and language developpement, but I could 
>> try to help you develop nice.
>
>
> Thanks! Have a look at 
> http://nice.sourceforge.net/cgi-bin/twiki/view/Doc/GetInvolved and let 
> us know if you have ideas what you would like to work on. The default 
> implementation of toString you proposed could be another good way to 
> get started.

Thanks for your answers, starting with toString is a good idea, I'll 
investigate. I also interesting by NiceDoc. I've already download the 
zip linked in the wiki. But I've not start to learn.
May be I could better understand some choice with more pratical of Nice.

> In any case, please keep in touch, so that we know how you are doing 
> and so that we can help.
>
> Daniel
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> Nice-info mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/nice-info



-- 
--------------------------------------------------------------
David "Dwayne" Bernard             Freelance Developer (Java)
                                   mailto:[email protected]
      \|/                          http://dwayne.java-fan.com
--o0O @.@ O0o-------------------------------------------------



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click