Closed lucaswerkmeister closed 11 years ago
Actually... FormattingOptions
should of course extend SparseFormattingOptions {optionX=defaultX; ... }
.
Which leaves FormattingOptions
' argument list open... I'm kinda in favour of "empty".
Well, seeing as apparently
shared actual TypeX optionX;
gives the error "forward declaration may not occur in declaration section: indentMode"I can't write extends SparseFormattingOptions { ... }
, but instead have to extends SparseFormattingOptions() { ... }
. Meh...
And given that, I have again two options for FormattingOptions
:
shared class FormattingOptions(
indentMode = Spaces(4)) extends SparseFormattingOptions() {
shared actual default IndentMode indentMode;
}
vs
shared class FormattingOptions() extends SparseFormattingOptions() {
shared actual default IndentMode indentMode = Spaces(4);
}
where the latter one obviously has the advantage that you can refine the default options (that would be FormattingOptions()
) without using CombinedOptions
, just like this:
FormattingOptions {
indentMode = Mixed(Tabs(8), Spaces(4));
// refine some other options
// keep the rest
}
I think I'm leaning towards the latter option.
This issue is tagged request for comments. If anyone else is reading this while the issue is still open, please comment! I feel lonely populating these issues all by myself... :-(
Currently,
FormattingOptions
andSparseFormattingOptions
are abstract. The intended use was to combine adefaultOptions
object with built-on-the-flySparseFormattingOptions
usingCombinedOptions
; however, I see now that this plan is in the current design impossible, because anyobject extends SparseFormattingOptions
would have to explicitly set each unused attribute tonull
, which was not the original intention.Instead, I propose the following:
shared class SparseFormattingOptions(optionX=null, optionY=null, ...) { shared TypeX? optionX; ... }
shared class FormattingOptions(optionX=defaultX, optionY=defaultY, ...) { shared TypeX optionX; ... }
CombinedOption
stays unchangeddefaultOptions
i.e. instead of a separate
defaultOptions
object, use Ceylon's built-in default attribute mechanism.This will also allow users to actually create sparse option objects like this:
and then combine them with default (e.g. company-issued) options, or just use the default options by using the
FormattingOptions
class instead of theSparseFormattingOptions
class.