I’m working ATM on support for sub components in Lucee 6.
With Lucee 5, you can only define one component in a .cfc file like this
component {
}
this component then get loaded via the name of the Template.
A sub component is any addional component defined in that Template like this
// Main component
component {
}
// Sub component 1
component SubZero {
}
// Sub component 2
component name="Fireball" {
}
Question is how to address this components, the main component is clear, you simply do
new Test(); // name of the template to load the main component
Now the idea is to load the sub components like this
new Test$SubZero(); // address component by given name
There are 3 reasons to use this syntax
- this syntax makes sense, because it is already used in CFML to load sub classes from java like this
createObject("java","lucee.runtime.type.Collection$Key");
- the chance of a conflict is minor, because it is not that often that $ is used as part of a component name
- it is easy to type because on most keyboard $ is easy to do
But yes the biggest downside with that syntax is, it will break all components using $ in the name, because Lucee will no longer allows this!
we did also consider this syntax
new Test.SubZero();
But this has a much bigger chance of conflict, taking the example above, it is also possible that the requested component is SubZero.cfc
in a folder with name Test
, that makes also the job for the runtime harder and it makes searching for components slower in general.
So what do you think, what syntax should we use to load sub components?
BTW we also working on inline components but i will do another thread for this.