-
Notifications
You must be signed in to change notification settings - Fork 62
redefine named arg lists in terms of let #3850
Comments
[@gavinking] Note: this idea kinda depends on #3604. |
[@FroMage] See the differences between let and letrec. Also, I don't see this nearly useful enough without if/else expressions. |
Do we need letrec for some reason? In all the examples I'm thinking about, let is sufficient.
WDYM, that's a key feature #3609 of 1.1, already promised in §6.7.1 of the language spec. |
[@quintesse] In this code: Panel {
value label = Label { size = Size(50,10); }; isn't there a problem that you can't choose your own name for |
[@gavinking] huh? In that example we are choosing our own name... |
(See the Note in §6.6.8 of the latest spec and the recent mailing list discussion with @loicrouchon.) |
[@quintesse] Ok, so what if I want to refer to the value of a named argument? How would that work? For example: Panel {
value label = Label { size = Size(50,10); };
value button = Button {
label = "Click me";
size = Size(50,10);
onClick() => label.text="Hello!"; // How do I refer to the button's label?
};
} |
Probably just use the parameter name. |
Ok, so we'd need some way to refer to elements in enclosing scopes and such. |
[@gavinking] In this case, the "inheriting" scope, i.e. the named arg list inherits names from the "inherited" scope, in this case the parameter list, and also adds its own local names. |
[@quintesse] Sure, but there could be several layers of those, with local names hiding outer scopes etc. We'd probably want some way to access those, right? Or would you expect people to go FQN starting from the outermost object in those cases? |
Hrm, perhaps that's wrong. If we want to support freely-form cross-references within argument bodies (rather than just to previous arguments, we would need something a bit like letrec I guess. We also run into evaluation-ordering problems, of course, but we could resolve them either using the approach we use for class bodies or the approach we use for toplevels. |
Sure, and exactly the same is true of inheritance.
Well with the case of classes we let you use
I have no idea what the FQN of an argument would be. |
[@gavinking] OK, I mean, I suppose your point, @quintesse, is that you're going to typically get a lot more nesting in a UI definition than you get in regular class definition. This is true. I still think it's going to turn out OK because in a UI definition most args are in the ordinary list of arguments of §6.6.8, and they get their own names, according to #3855. |
[@quintesse] And by FQN I tried to refer to some way of going from the toplevel element (for example |
[@gavinking] We've occasionally discussed introducing some kind of
let
construct (though we might actually use the keywordgiven
). It might be possible to define named argument lists in terms of positional arguments and this newlet
construct, at least at the specification level. That is:Would mean:
This would further help us conceptualize "id" in UIs and build scripts:
Would mean something like:
(Thanks to @loicrouchon having part of this idea.)
[Migrated from ceylon/ceylon-spec#744]
The text was updated successfully, but these errors were encountered: