Sub components in Lucee 6

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.


I think you’ve nailed it with the $ syntax. I’d just update the docs now to say “Deprecated: $ shoud not be used in component names, and *will not be supported in component names as of Lucee 6.x&”, and also post to the various community channels (here, slack, etc).

You’re not compelled to have major releases entirely backwards-compatible, this is a real edge-case, and provided you’re forewarning ppl I don’t see a problem.

People with $ in their component names are not compelled to upgrade to 6.x after all.

Do any common CFML apps use $ like this? That would be the chief thing I’d be thinking about, but again just tell them they will need to change that, and then you just do what’s best for Lucee, and let them worry about what’s best for their code.

1 Like