Hi Igor,

Thank you a lot for clarifying the details about this subject.

At a certain point in future I will possibly apply this idea.
I have a lot of code in Java which is 'more or less' prepared for 
JSR-308 but it's something which will only be applied in future.

Not only with my code in Java... but also now with X10, this subject is 
low priority again cos there are lots of features offered by X10 which I 
still need to understand and are of higher priority.

Anyway, it's good to know that X10 addresses such subject, which may 
become eventually important when we need to provide additional semantics 
to certain blocks of code. I've seen that it happens in regards to CUDA 
programming.

Thanks a lot.

Richard Gomes
M: +44(77)9955-6813
http://tinyurl.com/frgomes
twitter: frgomes

JQuantLib is a library for Quantitative Finance written in Java.
http://www.jquantlib.org/
twitter: jquantlib

On 12/11/10 04:27, Igor Peshansky wrote:
> Richard Gomes<rgomes1...@yahoo.co.uk>  wrote on 11/11/2010 10:52:05 PM:
>
>> Hi guys,
>>
>> I was wondering if it would be possible to assign annotations to types
>> and employ an annotation processor in order to detect the situation
>> below which tries to detect if parametres were passed in wrong order.
>>
>>
>> public class Hello {
>>
>>       static type Left  = Double;
>>       static type Right = Double;
>>
>>       public static def main(Array[String]) {
>>
>>           val left  : Left  = 2.2;
>>           val right : Right = 2.5;
>>
>>           val o = new Hello();
>>
>>           val pass = o.f(left, right); // compiles OK
>>
>>           val fail = o.f(right, left); // should not compile !!!!!
>>
>>       }
>>
>>       def f(l : Left, r : Right) : Double = { ... }
>>
>> }
>
> Hi, Richard,
>
> Well, typedefs in X10 are real aliases, and don't define new types,
> so the above will not work as written.  However, annotations on
> types like those proposed in JSR-308 are permitted in X10, so one
> can write:
>
>      val left : Double @Left = 2.2;
>      val right : Double @Right = 2.5;
>      ...
>      val pass = o.f(left, right);
>      val fail = o.f(right, left);
>      ...
>      def f(l: Double @Left, r: Double @Right) : Double = ...;
>
> and create a checker that would ensure that the second invocation
> fails to compile.  One could also write a compiler plugin to
> generate code on casts, so that the following would perform the
> necessary conversions, if any:
>
>      val right : Double @Right = (left + .3) as Double @Right;
>
> Let us know if you're interested in this functionality, and we
> can expand on this.
>          Igor

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to