-
Over many years I have thought about how QML could be improved upon. One of the ideas that stuck with me was How would it look?Before
After
DetailsThe SignalsSignals would need to change to be just data. I suggest that it can be done with a data type called Signal which would
Here I think the rule could be to simply allow access inside of signal-property expressions to properties of signals which triggered status is used in the own triggered expression. Not fully thought out, but not making an exception would make the above very ugly and repetitive. Advantages
Disadvantages
More ideasOne idea could be to make signals directly usable as a boolean, by designating the SummaryI think a core deciding factor between memory cells and event handlers is if you prioritize being able to scale up in how many signals affect the value of a certain property (all signals being checked in one expression), or if you prioritize being able to scale up in how many properties can be affected by a single signal (all assignments in one handler). Actually now that I think about it, this should be able to be measured on existing code bases. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi, First, thanks for your suggestion, It really makes me happy to see people interested in our project. I think the problem of not knowing where a property is modified is a real problem and it is indeed worth trying to improve the situation. Personally, I prefer seeing the signal handler near the button so that one can "see what happens when one press the button" and the Here is another idea i think we could implement to make it easier to reason about the code. Add a
Me may also need to allow binding to be marked as mutable:
This syntax not so pretty so perhaps we could have a prettier syntax to mark a binding a mutable.
Another thing to take in account are the states Would that help mitigate the downside of having normal signal handler? |
Beta Was this translation helpful? Give feedback.
-
Ah, that fax example is indeed a problem for my idea. What you have there are anonymous UI elements generated by basically mapping a collection. Since my idea would change the data direction from a mix of pull and push to purely pull direction, then of course the problem becomes how to pull data from an non-named item? Ehh. Only thing I can think of is to pull it out using indexing into that generated array of UI elements. But it would surely not be elegant so I believe you found a very good challenge to my proposal. :-) I like your idea of marking properties mutable, because in practice my guess would be that it gives almost the same certainty about how and when a given property can change (when combined with IDE based cross references to write access locations, as you noted). Since it's a relatively simple modification it gives a lot of "bang for the buck". But how would it work together with libraries of components? If a library does not have the mutable keyword for a property then users of this component can't change it from event handlers? Library authors would have to remember to mark as mutable everything that a user might want to change. Perhaps the child class "override" can be allowed to change this mutability for any inherited property. Oh, and come to think of it, QML had that thing of read-only properties that only expose values from the host language, not allowed to be re-assigned. If you also plan to have that it might be a little confusing if non-mutable is not the same as read-only. Perhaps another idea is to skip any mutable keyword and make a specialized IDE or editor for this language, then simply add different visual markers based on if effectively the property is being changed by states or by event handlers or both. States have a similar trade-off as event handlers in that they scatter the logic for what values a property can take, but instead is able to collect all the effects of a certain condition being true into one place. In my head that classifies them bindings, not imperative assignments. So in that sense I agree with you not mark a mutable. But on the other hand the binding logic is now scattered. (My understanding is that the expression directly in a property declaration is not merely an initial value in this case since if no active state has an effect on this property it goes back to having that "direct" property binding active again). Having a second keyword, "statemut" , would be terrible. :) In the end I think I might be obsessing a bit too much about certainty for the reader/poor guy stuck debugging. I started my QML-replacement thoughts with how it could be useful for control systems... that could explain why. For user interfaces it could very well be that it's more important to prioritize easy and flexible development. Anyway, thanks for the kind and thoughtful answer. As you can see I was not completely convinced my idea was all that good but I thought I should mention it and get some criticism, toy around with it. |
Beta Was this translation helpful? Give feedback.
-
I think the key is that we would not mark the property itself as
This is planed #34
That is true. But on the other hand, states are quite declarative.
That's right. I remember an idea about not allowing bindings on property that are changed in the states. So that one must use a default state instead. But i'm not sure if this is a good idea. |
Beta Was this translation helpful? Give feedback.
I think the key is that we would not mark the property itself as
mutable
but the binding. Which is why the binding is on the right hand side.But perhaps we need both: a way to mark the property as const (so that nobody can change it) and a way to mark the binding as read-only (so that once assigned it can no longer change from the same component) and ideally const or read only would be a default unless specified otherwise. We just need to find a g…