Re: [Development] Redesigning QML value types

2022-09-26 Thread Ulf Hermann
Hi, after some more experimentation, I've realized the problem is actually of larger dimension. Since function signatures are ignored when interpreting or running JIT-compiled QML code, you already get divergent behavior without all the value type write back problems. Take for example the fol

Re: [Development] Redesigning QML value types

2022-09-21 Thread Ulf Hermann
This becomes more and more non-intuitive.   let a: font = f  // copy f because a is value-typed? That syntax doesn't exist in QML. You can only type-annotate function arguments and return types, but not locals.   let b = a        // copy because a is typed, and b's type is inferred from a

Re: [Development] Redesigning QML value types

2022-09-21 Thread Ulf Hermann
Should there be a way to pass by reference even when using type annotations? Providing a way to pass by reference for type annotated functions will probably in people expecting such code to be compiled to C++. I would only provide such syntax if qmlcachegen and qmlsc can deal with it. If it's

Re: [Development] Redesigning QML value types

2022-09-21 Thread Konstantin Ritt
This becomes more and more non-intuitive. let a: font = f // copy f because a is value-typed? let b = a// copy because a is typed, and b's type is inferred from a? let c = f// ref because f is JS-ish type function foo(arg) { return arg } let d = foo(b) // ref becau

Re: [Development] Redesigning QML value types

2022-09-21 Thread Ulf Hermann
Generally I feel that all the gritty details in what to do and what not do in qml to have efficient, compiled code, are more and more confusing. There is so much to consider and basically all the documentation about this is hidden in Qt blog posts. Well, yes. All of this is 10 years late and we

Re: [Development] Redesigning QML value types

2022-09-21 Thread Yuya Nishihara
On Wed, 21 Sep 2022 14:59:08 +0200, Ulf Hermann wrote: > If a function has type annotations, we pass its arguments and return > value by value (if they are value types). Otherwise we pass by > reference. Inside a function, everything is a reference. > > This makes some intuitive sense: The type an

Re: [Development] Redesigning QML value types

2022-09-21 Thread Shawn Rutledge
> On 2022 Sep 21, at 14:59, Ulf Hermann wrote: > > Thanks for the feedback! I've thought about it some more and done some > experiments and I think we can solve this in a way that makes everyone happy: > > If a function has type annotations, we pass its arguments and return value by > value (

Re: [Development] Redesigning QML value types

2022-09-21 Thread Nils Jeisecke via Development
Hi, Generally I feel that all the gritty details in what to do and what not do in qml to have efficient, compiled code, are more and more confusing. There is so much to consider and basically all the documentation about this is hidden in Qt blog posts. Anyway I'd just like to note that, as far as

Re: [Development] Redesigning QML value types

2022-09-21 Thread Ulf Hermann
Thanks for the feedback! I've thought about it some more and done some experiments and I think we can solve this in a way that makes everyone happy: If a function has type annotations, we pass its arguments and return value by value (if they are value types). Otherwise we pass by reference.

Re: [Development] Redesigning QML value types

2022-09-21 Thread Volker Hilsheimer
Thanks for writing this up, Ulf! Working on porting Qt Location to Qt 6 right now, I’m looking very much forward to the improved support for value types :) > On 20 Sep 2022, at 18:13, Ulf Hermann wrote: > > Hi, > > I'm currently trying to transform QML value types, such as font, rect, > size

Re: [Development] Redesigning QML value types

2022-09-21 Thread Richard Gustavsen
> 1. Value types are passed by value > 2. Everything is a reference Most languages have a way to specify this in the signature. Swift has the “inout” keyword, c# has “ref”. Have you considered this as an option as well? BR, Richard ___ Development mai

[Development] Redesigning QML value types

2022-09-20 Thread Ulf Hermann
Hi, I'm currently trying to transform QML value types, such as font, rect, size, etc, into something less random and more predictable. On that occasion I'm wondering what semantics people actually expect from value types. One thing you have to know in advance is that QML has this internal con