Re: Compile time opAssign/@property constraints

2019-01-05 Thread Jacob Shtokolov via Digitalmars-d-learn
On Friday, 4 January 2019 at 14:36:16 UTC, Mike Parker wrote: v is a run-time value, not available at compile time. Sorry about that, looks like if I edit the text in the run.dlang.io editor, the link also gets updated. I was using "void opAssign(T)(T v)" in the initial example, but it seems

Re: Compile time opAssign/@property constraints

2019-01-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 4, 2019 4:50:30 AM MST Jacob Shtokolov via Digitalmars-d- learn wrote: > On Friday, 4 January 2019 at 11:41:59 UTC, Simen Kjærås wrote: > > The thing is, compile-time tests like static if and static > > assert can only test values that are known at compile-time, and > > are for

Re: Compile time opAssign/@property constraints

2019-01-04 Thread Mike Parker via Digitalmars-d-learn
On Friday, 4 January 2019 at 11:53:41 UTC, Jacob Shtokolov wrote: On Friday, 4 January 2019 at 11:45:24 UTC, Jacob Shtokolov wrote: Here is the simple example: https://run.dlang.io/gist/1a06dd703bea5548ee72b4713a7ce5f6 Sorry, invalid link. Here is a new one: https://run.dlang.io/is/QZ5hLV

Re: Compile time opAssign/@property constraints

2019-01-04 Thread Jacob Shtokolov via Digitalmars-d-learn
On Friday, 4 January 2019 at 11:45:24 UTC, Jacob Shtokolov wrote: Here is the simple example: https://run.dlang.io/gist/1a06dd703bea5548ee72b4713a7ce5f6 Sorry, invalid link. Here is a new one: https://run.dlang.io/is/QZ5hLV

Re: Compile time opAssign/@property constraints

2019-01-04 Thread Jacob Shtokolov via Digitalmars-d-learn
On Friday, 4 January 2019 at 11:41:59 UTC, Simen Kjærås wrote: The thing is, compile-time tests like static if and static assert can only test values that are known at compile-time, and are for the most part useful only in templates. Thanks for this answer! That's sad to hear. But, is there

Re: Compile time opAssign/@property constraints

2019-01-04 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 4 January 2019 at 11:45:24 UTC, Jacob Shtokolov wrote: On Friday, 4 January 2019 at 10:34:07 UTC, Basile.B wrote: Show us some code. Here is the simple example: https://run.dlang.io/gist/1a06dd703bea5548ee72b4713a7ce5f6 The thing I'm trying to do is to make an experimental port

Re: Compile time opAssign/@property constraints

2019-01-04 Thread Jacob Shtokolov via Digitalmars-d-learn
On Friday, 4 January 2019 at 10:34:07 UTC, Basile.B wrote: Show us some code. Here is the simple example: https://run.dlang.io/gist/1a06dd703bea5548ee72b4713a7ce5f6 The thing I'm trying to do is to make an experimental port (for education purposes) of https://github.com/fthomas/refined

Re: Compile time opAssign/@property constraints

2019-01-04 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 4 January 2019 at 09:54:25 UTC, Jacob Shtokolov wrote: Hi, I'd like to implement some compile time constraints for a struct (though not sure if that's possible). I already tried to place "static assert" or any kind of static condition into a body of @property and opAssign(), but

Re: Compile time opAssign/@property constraints

2019-01-04 Thread Basile.B via Digitalmars-d-learn
On Friday, 4 January 2019 at 09:54:25 UTC, Jacob Shtokolov wrote: Hi, I'd like to implement some compile time constraints for a struct (though not sure if that's possible). I already tried to place "static assert" or any kind of static condition into a body of @property and opAssign(), but

Compile time opAssign/@property constraints

2019-01-04 Thread Jacob Shtokolov via Digitalmars-d-learn
Hi, I'd like to implement some compile time constraints for a struct (though not sure if that's possible). I already tried to place "static assert" or any kind of static condition into a body of @property and opAssign(), but every time it shows the error "variable cannot be read at compile