It seems I cannot pass e.g. an int argument to a Variant function parameter. What's the simplest way to work around this restriction?
Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
February 02 Scripting with Variant from std.variant: parameter passing | ||||
---|---|---|---|---|
| ||||
February 02 Re: Scripting with Variant from std.variant: parameter passing | ||||
---|---|---|---|---|
| ||||
Posted in reply to Carl Sturtivant | On Friday, 2 February 2024 at 08:22:42 UTC, Carl Sturtivant wrote: >It seems I cannot pass e.g. an int argument to a Variant function parameter. What's the simplest way to work around this restriction? Just tell the compiler clearly what you want.
|
February 02 Re: Scripting with Variant from std.variant: parameter passing | ||||
---|---|---|---|---|
| ||||
Posted in reply to Carl Sturtivant | On Friday, 2 February 2024 at 08:22:42 UTC, Carl Sturtivant wrote: >It seems I cannot pass e.g. an int argument to a Variant function parameter. What's the simplest way to work around this restriction? The easiest thing would be to actually pass it a The more-involved thing would be to write a template constrained to non-
|
February 02 Re: Scripting with Variant from std.variant: parameter passing | ||||
---|---|---|---|---|
| ||||
Posted in reply to Carl Sturtivant | On Friday, 2 February 2024 at 08:22:42 UTC, Carl Sturtivant wrote: >It seems I cannot pass e.g. an int argument to a Variant function parameter. What's the simplest way to work around this restriction? You'd have to implement the function that accepts the parameters and wraps in a Variant. This is the best I can come up with, which should be copy/pasteable to other shims:
-Steve |
February 02 Re: Scripting with Variant from std.variant: parameter passing | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Friday, 2 February 2024 at 19:22:22 UTC, Steven Schveighoffer wrote: >
Thanks for this idea. I'll work on it. >-Steve |
February 02 Re: Scripting with Variant from std.variant: parameter passing | ||||
---|---|---|---|---|
| ||||
Posted in reply to Carl Sturtivant | On Friday, 2 February 2024 at 20:28:50 UTC, Carl Sturtivant wrote: >On Friday, 2 February 2024 at 19:22:22 UTC, Steven Schveighoffer wrote: >
Thanks for this idea. I'll work on it. Another variation on the same theme:
|
February 03 Re: Scripting with Variant from std.variant: parameter passing | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anonymouse | On Friday, 2 February 2024 at 11:31:09 UTC, Anonymouse wrote: >On Friday, 2 February 2024 at 08:22:42 UTC, Carl Sturtivant wrote: >It seems I cannot pass e.g. an int argument to a Variant function parameter. What's the simplest way to work around this restriction? The easiest thing would be to actually pass it a The more-involved thing would be to write a template constrained to non-
To be honest, this doesn't make sense.
Yes, it's nice that it works in this case. It's just not logical, it doesn't make sense because 42 just simply isn't a Variant, it's an |
February 03 Re: Scripting with Variant from std.variant: parameter passing | ||||
---|---|---|---|---|
| ||||
Posted in reply to Danilo | On Saturday, 3 February 2024 at 08:04:40 UTC, Danilo wrote: >To be honest, this doesn't make sense.
Yes, it's nice that it works in this case. It's just not logical, it doesn't make sense because 42 just simply isn't a Variant, it's an I read it several times but I don't think I understand what you mean. The constraint Is your argument that it's wrong to assume an
How is this different from the following?
And how is that different from the following?
Which is in what way different from the following?
And how is that not the same as my original example? |
February 03 Re: Scripting with Variant from std.variant: parameter passing | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Friday, 2 February 2024 at 20:58:12 UTC, Paul Backus wrote: >Another variation on the same theme:
Thanks, will study the library machinery you used here. |