Thread overview | ||||||
---|---|---|---|---|---|---|
|
August 21, 2020 `with (TemplateInstance):` shoild work | ||||
---|---|---|---|---|
| ||||
I just tried this: template x() { void fun(int) {} } void main() { with (x!()) { 42.fun(); } } It works, and it's a great way to inject UFCS symbols. But at best it should work with the colon syntax so it applies through the end of scope/module: with (x!()): void main() { 42.fun(); } Once that is possible, you get to inject UFCS symbols into a module with ease. |
August 21, 2020 Re: `with (TemplateInstance):` shoild work | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Friday, 21 August 2020 at 05:10:14 UTC, Andrei Alexandrescu wrote:
>
> with (x!()):
>
> void main() {
> 42.fun();
> }
>
> Once that is possible, you get to inject UFCS symbols into a module with ease.
Would the following suit your needs ?
```
template x() {
void fun(int) {}
}
mixin x;
void main() {
42.fun();
}
```
|
August 21, 2020 Re: `with (TemplateInstance):` shoild work | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Friday, 21 August 2020 at 05:10:14 UTC, Andrei Alexandrescu wrote:
> I just tried this:
>
> template x() {
> void fun(int) {}
> }
>
> void main() {
> with (x!()) {
> 42.fun();
> }
> }
>
> It works, and it's a great way to inject UFCS symbols. But at best it should work with the colon syntax so it applies through the end of scope/module:
>
> with (x!()):
>
> void main() {
> 42.fun();
> }
>
> Once that is possible, you get to inject UFCS symbols into a module with ease.
You would need a DIP for the colon synatx.
I would be in support of with:
As for using template instances, yeah ...
maybe not
|
August 21, 2020 Re: `with (TemplateInstance):` shoild work | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mathias LANG | On 8/21/20 2:49 AM, Mathias LANG wrote:
> On Friday, 21 August 2020 at 05:10:14 UTC, Andrei Alexandrescu wrote:
>>
>> with (x!()):
>>
>> void main() {
>> 42.fun();
>> }
>>
>> Once that is possible, you get to inject UFCS symbols into a module with ease.
>
> Would the following suit your needs ?
>
> ```
> template x() {
> void fun(int) {}
> }
>
> mixin x;
>
> void main() {
> 42.fun();
> }
> ```
Ah, nice. Thanks!
|
Copyright © 1999-2021 by the D Language Foundation