Re: Precise types & retyping

Daniel Bonniot <[email protected]>
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
Isaac Gouy wrote:

>>Of course, you don't get the extra safety you get when using Nice
>>libraries, but there is no simple automatic way to do so. You can
>>get the safety back by writing the retypings.
>>    
>>
>
>Exactly, one of the benefits of Nice is precise typing, that's what I
>try to use.
>
>  
>
>>Seriously, you should not need to write retypings in most cases, so
>>wait to find a need for them. 
>>    
>>
>
>To use precise typing I need to write retypings, yes?
>  
>
I use precise typing myself, but that's not really a technical word, 
it's the idea that the type system of Nice is more powerful that Java's.

Retypings are needed when you want to override the default type that the 
Nice compiler assigns to Java methods.

So yes, if you want to assert that the parameter of such method cannot 
be null, or that the return type might be null (which will enable the 
Nice compiler to make sure that you use them properly), then you need a 
retyping. Or the "massive retypings" that I was speaking about.

>>How would it guess the type information that is not there (nullness, 
>>parameterized types)?
>>    
>>
>
>nullness is hard to guess from Java code, except for primitives ;-)
>  
>
Yes, primitives are taken as non-null. Furthermore, the compiler knows 
that 'this' arguments cannot be null.

>parameterized types seem to be more predictable.
>  
>
How? If you look at java.util.Map, for instance, there are two type 
parameters, and it's far from easy to find that out automatically.

>Just wondering about what can be generated from a jar file, as a
>starting point for retyping a Java library.
>  
>
Ha, I see. Yes, I guess you could write a utility that prints retyping 
templates for all methods in your library, and then you manually adjust 
them as needed.

Alternatively, it might be more efficient to use the retyping policy 
statements, and then go through the API docs, and only list those 
methods that need it.

What library are you working on? (asking, because Jason is working on 
NiceSWT, and I saw you wrote a SWT example. It would be silly to 
duplicate the work. But maybe you are working together ;-)

Daniel



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.