Array casts

Mark Taylor <[email protected]> Thu, 22 Apr 2021 11:28:10 +0100 (BST)
Newsgroups gmane.comp.java.jel.general
Message-ID <alpine.DEB.2.21.2104221121070.3259@IT076926>
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
[email protected]          http://www.star.bristol.ac.uk/~mbt/