Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
December 16, 2016 concepts v0.0.1 | ||||
---|---|---|---|---|
| ||||
Since my phobos PR for better static assertions was clearly never getting merged (https://github.com/dlang/phobos/pull/3677), I moved the code to dub instead: http://code.dlang.org/packages/concepts Basically, as long as you pair up your template constraints (e.g. isFoo) with a suitably named function that should compile (e.g. checkFoo, not a lambda), then you can write this: @models!(Foo, isFoo) struct Foo { //... } And in the case that isFoo is false, you'll get to know _why_ it didn't compile instead of an AssertError that leaves you confused. At least it used to and the unit tests pass so I'm assuming it still does :P Atila |
December 16, 2016 Re: concepts v0.0.1 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Atila Neves | On Friday, 16 December 2016 at 20:51:19 UTC, Atila Neves wrote:
> Atila
Surprisingly little code. Thx.
|
December 16, 2016 Re: concepts v0.0.1 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Atila Neves | On Friday, 16 December 2016 at 20:51:19 UTC, Atila Neves wrote:
> @models!(Foo, isFoo)
What happened to the __UDA_ATTACHMENT__ proposal?
|
December 17, 2016 Re: concepts v0.0.1 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicholas Wilson | On Friday, 16 December 2016 at 23:49:18 UTC, Nicholas Wilson wrote:
> On Friday, 16 December 2016 at 20:51:19 UTC, Atila Neves wrote:
>> @models!(Foo, isFoo)
>
>
> What happened to the __UDA_ATTACHMENT__ proposal?
Also are UDAs legal after the symbol? i.e. with __UDA_ATTACHMENT__ could you do struct Foo @models!isFoo
{
void foo();
}
?
|
December 17, 2016 Re: concepts v0.0.1 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Atila Neves | On 2016-12-16 21:51, Atila Neves wrote: > Since my phobos PR for better static assertions was clearly never > getting merged (https://github.com/dlang/phobos/pull/3677), I moved the > code to dub instead: > > http://code.dlang.org/packages/concepts > > Basically, as long as you pair up your template constraints (e.g. isFoo) > with a suitably named function that should compile (e.g. checkFoo, not a > lambda), then you can write this: > > @models!(Foo, isFoo) > struct Foo { > //... > } > > And in the case that isFoo is false, you'll get to know _why_ it didn't > compile instead of an AssertError that leaves you confused. > > At least it used to and the unit tests pass so I'm assuming it still > does :P It's not very well tested ;). When a check fails I get this error: Error: can only import from a module, not from package std.algorithm.searching.countUntil After fixing that to a proper selective import I get: Error: template instance moduleName!P template 'moduleName' is not defined Adding an import for std.traits will fix that. Then after fixing all that it seems to work properly :) Asserting that something does not compile is very risky because it does not tell you why it didn't compile. One should always first compile without __traits(compiles) to verify that the correct error is reported. -- /Jacob Carlborg |
December 19, 2016 Re: concepts v0.0.1 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Saturday, 17 December 2016 at 14:58:24 UTC, Jacob Carlborg wrote:
> On 2016-12-16 21:51, Atila Neves wrote:
>> [...]
>
> It's not very well tested ;). When a check fails I get this error:
Oops!
Fixed it now. Look, now it's version 0.0.2! :P
Atila
|
December 19, 2016 Re: concepts v0.0.1 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicholas Wilson | On Saturday, 17 December 2016 at 04:00:32 UTC, Nicholas Wilson wrote: > On Friday, 16 December 2016 at 23:49:18 UTC, Nicholas Wilson wrote: >> On Friday, 16 December 2016 at 20:51:19 UTC, Atila Neves wrote: >>> @models!(Foo, isFoo) >> >> >> What happened to the __UDA_ATTACHMENT__ proposal? Nothing AFAIK. > > Also are UDAs legal after the symbol? i.e. with __UDA_ATTACHMENT__ could you do struct Foo @models!isFoo > { > void foo(); > } > > ? Nope. |
Copyright © 1999-2021 by the D Language Foundation