Module in java and luan at the same time

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Module in java and luan at the same time

Hugo <Nabble>
We should be able to have a single module partly implemented in Java and and partly in Luan at the same time. For example, we could have a "Node" module implemented in Java (NodeLib.java) and still have some methods implemented in Luan in a file called Node.luan. Any code that requires the module "Node" would have access to all methods together. This simplifies the code organization. Right now I am creating files like "User_Utils.luan" just to add methods to the "User" module. So I have to require "User_Utils" and "User" wherever that code is needed. It would be simpler if I could require just "User" and have everything ready for use. What do you think?
Reply | Threaded
Open this post in threaded view
|

Re: Module in java and luan at the same time

fschmidt
Administrator
We don't want special rules that distinguish between Java and Luan modules.  So I think of this as "User_Utils" subclassing "User".  Let's change the names "User_Utils" to "User" and "User" to "Java_User" so that now "User" subclasses "Java_User".  The implementation of this is:
require "Java_User"
User = Java_User
Package.loaded.User = User
We can change the "module" command to take a second parameter to do this.
module("User","Java_User")
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: Module in java and luan at the same time

Hugo <Nabble>
fschmidt wrote
We can change the "module" command to take a second parameter to do this.
module("User","Java_User")
Yes. Maybe something more intuitive?
module "User" extends "Java_User"
Reply | Threaded
Open this post in threaded view
|

Re: Module in java and luan at the same time

fschmidt
Administrator
"module" is a function, so your syntax doesn't work.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: Module in java and luan at the same time

Hugo <Nabble>
Okay, let's use your syntax then.
Reply | Threaded
Open this post in threaded view
|

Re: Module in java and luan at the same time

fschmidt
Administrator
done in rev 97
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: Module in java and luan at the same time

fschmidt
Administrator
In reply to this post by Hugo <Nabble>
This can now be done like this in "User.luan":
_ENV = require "Java_User"

...
You can close this.
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: Module in java and luan at the same time

Hugo <Nabble>
Okay, closing thread.