[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Array casts
From: |
Mark Taylor |
Subject: |
Array casts |
Date: |
Thu, 22 Apr 2021 11:28:10 +0100 (BST) |
User-agent: |
Alpine 2.21 (DEB 202 2017-01-01) |
Dear Konstantin,
me again. It seems like it's not possible to cast to array types
in JEL expressions; see the following code:
import gnu.jel.CompilationException;
import gnu.jel.Evaluator;
import gnu.jel.Library;
public class Cast {
public static void main( String[] args ) throws CompilationException {
Library lib = new Library(new Class[] {Cast.CLib.class},
null, null, null, null);
Evaluator.compile("iValue(3)", lib, null);
Evaluator.compile("(double) iValue(3)", lib, null);
Evaluator.compile("dArray(3)", lib, null);
Evaluator.compile("(double[]) dArray(3)", lib, null); // error here
}
public static class CLib {
public static int iValue(int i) {
return i;
}
public static Object dArray(int n) {
return new double[n];
}
}
}
which gives me (JEL 2.1.2):
gnu.jel.CompilationException: Encountered unexpected character ']'
Is there some good reason for this? Could it be fixed so that
array casts are possible?
Many thanks,
Mark
--
Mark Taylor Astronomical Programmer Physics, Bristol University, UK
m.b.taylor@bristol.ac.uk http://www.star.bristol.ac.uk/~mbt/
- Array casts,
Mark Taylor <=