|Re: Using B3 language with Java classes [message #606390 is a reply to message #606388]
||Mon, 10 May 2010 14:29
| Henrik Lindberg
Registered: July 2009
An example with a square function for Number would look like this:
function main(List argv) : square(3) ;
function square(Number n) : n * n;
Will check that the documentation shows this correctly.
(A note, type inference is not that smart yet, and as a result, a bit
more typing than what the finished b3 will have is required).
Regarding access to classes.
The b3 environment sees classes from all bundles that are visible from
the OSGi managed classpath. To make b3 see more things, a bundle needs
to declare itself to be a buddy of b3.
So, if you want to call java code from B3, create a bundle, and add the
following to the MANIFEST.MF of the bundle where you have the classes
you want to expose to b3.
This is done in the org.eclipse.b3.beelang.tests project/bundle.
On 5/10/10 3:46 PM, jeremie wrote:
> I just manage to launch an eclipse workbench with the B3 language.
> I try to create a simple example.
> My workspace look like it :
> A java package called "test1",
> In this package, to Class called "A.java" and "B,java",
> A folder called ''B3Files';
> In this folder, a b3 file called test1.B3.
> in test.b3 I try to import the package test1, but I don't manage to do it.
> I also implement the method : function square(Number x) : x * x ;
> As written in the B3Book manual page 24.
> but B3 don't recognize the class "Number"
> I think it miss an import
Powered by FUDForum
. Page generated in 0.13270 seconds