Integrate "Bean(...)" Functionality in "include(...)"
madoar opened this issue · 6 comments
After our latest changes to the include(...)
operation the syntax of Bean(...)
and include(...)
are very similar to each other. Both operations take an id string and return an object containing the loaded functionality.
The only difference between both operations seems to be the composition of the passed id string and whether the returned object was defined in Java or JavaScript. Because of this I think we can integrate the functionality of Bean
in the include
operation. To help include
decide whether the to be included script is defined in Java or JS we can add a bean.
prefix to the passed id.
So if you want to include the extractor
bean you would need to call:
const Extractor = include("bean.extractor");
instead of:
const Extractor = Bean("extractor");
@plata @qparis @ImperatorS79 what do you think?
Fine for me.
One thing that might be a bit confusing: Normally, the Bean gives you an object while the include gives you a class.
Normally, the Bean gives you an object while the include gives you a class.
This is actually not the case, include
gives you an object. This object can be a class, an array a string or anything else. In JS every class is an object.
I think I prefer const Extractor = Bean("extractor");
because you directly see what it is.
This is actually not the case, include gives you an object. This object can be a class, an array a string or anything else. In JS every class is an object.
I was referring to the way you use the returned object. For include, you usually call new...
before you do something.
@ImperatorS79 the question is: do we really want to see that it's a difference? Actually, you might very well implement the beans in JS directly. So maybe we should not even use that term at all and rather call it something like "built-ins".
For include, you usually call new... before you do something.
We have also included scripts that are used differently. For example our file utilities or the wine engine version strings.
That's true.