Date: Fri, 10 Apr 2026 12:15:40 +0200
On Wed, Apr 8, 2026 at 6:52 PM Simon Schröder <dr.simon.schroeder_at_[hidden]>
wrote:
>
>
> > On Apr 8, 2026, at 9:47 AM, Muneem <itfllow123_at_[hidden]> wrote:
> >
> > int^ x = {1,2.5,”C++”}.select(2); This would throw a huge error at
> compile time and is exactly why we need a new expression type T^. Not using
> T^ would give too much freedom that could backfire as shown in the example.
> In fact for T^, you cant even assign float^ to an int^.
>
> May bad, I wasn’t clear enough with my example. I do understand that with
> index=2 the compiler should use the compile time version and return the
> correct type. What my question actually is what would happen if the index
> is a runtime index that happens to be 2. How would the code be compiled to
> handle this case? What would happen to following source code lines that use
> ‘x’? Or would you just throw an exception?
>
>
> I am still trying to understand this part. Let me slightly rephrase my
example code:
int^ x = {1,2.5,"C++"}.select(runtime_index); // runtime_index happens to
be 2
x = 2;
How is this compiled? Are there exceptions involved? What should happen if
the runtime index does not fit the type T^ like in the example?
wrote:
>
>
> > On Apr 8, 2026, at 9:47 AM, Muneem <itfllow123_at_[hidden]> wrote:
> >
> > int^ x = {1,2.5,”C++”}.select(2); This would throw a huge error at
> compile time and is exactly why we need a new expression type T^. Not using
> T^ would give too much freedom that could backfire as shown in the example.
> In fact for T^, you cant even assign float^ to an int^.
>
> May bad, I wasn’t clear enough with my example. I do understand that with
> index=2 the compiler should use the compile time version and return the
> correct type. What my question actually is what would happen if the index
> is a runtime index that happens to be 2. How would the code be compiled to
> handle this case? What would happen to following source code lines that use
> ‘x’? Or would you just throw an exception?
>
>
> I am still trying to understand this part. Let me slightly rephrase my
example code:
int^ x = {1,2.5,"C++"}.select(runtime_index); // runtime_index happens to
be 2
x = 2;
How is this compiled? Are there exceptions involved? What should happen if
the runtime index does not fit the type T^ like in the example?
Received on 2026-04-10 10:16:20
