Import Java library in Frege -
i'm trying out frege, , i'm struggling try use native java libraries.
i'm trying out leiningen plugin, , joda time. apparently lein plugin doesn't take care of correctly seeting classpath fregec, or maybe it's related difference:
java -jar ~/downloads/frege3.22.524-gcc99d7e.jar -fp ~/.m2/repository/joda-time/joda-time/2.7/joda-time-2.7.jar src/hello.fr
will able find joda, expected, while
java -cp ~/.m2/repository/joda-time/joda-time/2.7/joda-time-2.7.jar -jar ~/downloads/frege3.22.524-gcc99d7e.jar src/hello.fr
will fail
`org.joda.time.years` not known java class
this shouldn't happen since, according the wiki
the current class path of running jvm plus target directory on class path.
still, after manually setting -fp
, code fails compile:
module hello data jodayears = native org.joda.time.years pure native years :: int -> jodayears pure native getyears org.joda.time.years.getyears :: jodayears -> int -- ^ tried both , without
the error is
instance method or getter must applied java reference type.
but instance method i'm using (getyears), takes reference type input (jodayears
)... tried org.joda.time.years
, compilation still fails
thanks might shed light on this
brief answer, since using mobile.
you can't invoke java both -cp , -jar
obviously, class path ignored in case. can try giving both jars in -cp need class run. frege compiler frege.compiler.main
concerning other error think related "years" taken instance method because of simple name. whereas other method taken class method because of qualified name.
the rules defining native function foo thus:
[pure] native foo xxx :: frege type
- for instance methods, xxx must simple name. can leave xxx out, in case same frege name you're defining (e.g. foo).
- for class methods, xxx must qualified name of method.
- for constructors, xxx must "new"
- for member access, xxx must ".member" member actual member name.
Comments
Post a Comment