LEONID ILYEVSKY <leonidilyev...@yahoo.com> wrote on 04/04/2012 08:51:32 AM:
>
> I tried an example directly from the language specification:
>
> val n = 3;
> val f : (x:Int){x != n} => Int
> = (x:Int){x != n} => (12/(n-x));
> Console.OUT.println("f(5)=" + f(5));
>
> Then I modified it, using "f(3)" instead of "f(5)". I expected it to
> stop me right at the entrance of the function body, but instead I
> got the "division by zero" exception. I tried both Java and C++ backend.
>
> Is it a bug or the feature not implemented yet?


It appears that guards on function literals are not properly implemented.
I opened a JIRA to track this:
http://jira.codehaus.org/browse/XTENLANG-3039

A similar piece of code with a guard on a method (testit in the code below)
does behave correctly.

thanks for reporting the problem,

--dave

class ConTest {
  public static def testit(x:int, n:int){x != n}:int = 12 / (n - x);

  public static def main(Rail[String]) {
    val n = 3;
    val f : (x:Int){x != n} => Int = (x:Int){x != n} => (12/(n-x));
    Console.OUT.println("f(5)=" + f(5));
    Console.OUT.println("f(3)=" + f(3));
    Console.OUT.println("testit(5)=" + testit(5, 3));
    Console.OUT.println("testit(3)=" + testit(3, 3));
  }
}
------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to