Re: Extracting user defined attributes on function parameters

2020-04-18 Thread Simen Kjærås via Digitalmars-d-learn
On Saturday, 18 April 2020 at 09:19:48 UTC, Simen Kjærås wrote: On Wednesday, Friday, 17 Apr 2020 17:45:47 UTC, H. S. Teoh wrote: I wonder if the ultimate cause of the above case is ultimately caused by the change to import semantics that hid private symbols from outside the module. Perhaps

Re: Extracting user defined attributes on function parameters

2020-04-18 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, Friday, 17 Apr 2020 17:45:47 UTC, H. S. Teoh wrote: I wonder if the ultimate cause of the above case is ultimately caused by the change to import semantics that hid private symbols from outside the module. Perhaps something, somewhere, is triggering an illegal access of a

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 April 2020 at 18:05:39 UTC, Jean-Louis Leroy wrote: Interesting example, but all hope is not lost. `a` could (should?) be passed as an alias in __parameters. Well, __parameters itself actually kinda works. The compiler knows it is an expression and can stringify it or evaluate

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Jean-Louis Leroy via Digitalmars-d-learn
On Friday, 17 April 2020 at 18:05:39 UTC, Jean-Louis Leroy wrote: Interesting example, but all hope is not lost. `a` could (should?) be passed as an alias in __parameters. Okay I take this back...

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Jean-Louis Leroy via Digitalmars-d-learn
On Friday, 17 April 2020 at 17:48:06 UTC, Adam D. Ruppe wrote: On Friday, 17 April 2020 at 17:31:32 UTC, Jean-Louis Leroy wrote: Well, can't do. I need this purely at compile time, and cross-module. And the CTFE engine gets weird with it too dmd will have to fix this. But default

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 April 2020 at 17:31:32 UTC, Jean-Louis Leroy wrote: Well, can't do. I need this purely at compile time, and cross-module. And the CTFE engine gets weird with it too dmd will have to fix this. But default parameters might not be possible in general at CT anyway... it is

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Apr 17, 2020 at 05:33:23PM +, Simen Kjærås via Digitalmars-d-learn wrote: > On Friday, 17 April 2020 at 16:54:42 UTC, Adam D. Ruppe wrote: [...] > > So pragma(msg) is doing something really weird, the bug doesn't > > appear to be in Phobos per se, I think it is the compiler doing the

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Jean-Louis Leroy via Digitalmars-d-learn
On Friday, 17 April 2020 at 16:54:42 UTC, Adam D. Ruppe wrote: void main() { import std.stdio; writeln(ParameterDefaults!f.stringof); } and it is fine. Well, can't do. I need this purely at compile time, and cross-module. That's for supporting UDAs and default parameter

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Simen Kjærås via Digitalmars-d-learn
On Friday, 17 April 2020 at 16:54:42 UTC, Adam D. Ruppe wrote: This part seems fine... pragma(msg, ParameterDefaults!f.stringof); It is this, specifically, that causes the problem. Replace it with: void main() { import std.stdio; writeln(ParameterDefaults!f.stringof); }

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 April 2020 at 16:40:15 UTC, Jean-Louis Leroy wrote: Alas the presence of parameter UDAs breaks std.traits.ParameterDefaults: import std.traits; struct attr; void f(@attr int); This part seems fine... pragma(msg, ParameterDefaults!f.stringof); It is this, specifically,

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Jean-Louis Leroy via Digitalmars-d-learn
Alas the presence of parameter UDAs breaks std.traits.ParameterDefaults: import std.traits; struct attr; void f(@attr int); pragma(msg, ParameterDefaults!f.stringof); Error: dmd -c bug.d bug.d(4): Error: undefined identifier `attr`, did you mean variable `ptr`?

Re: Extracting user defined attributes on function parameters

2020-04-15 Thread Jean-Louis Leroy via Digitalmars-d-learn
Thanks to both of you! As part of implementing full support for attributes in openmethods, I am developing a reflection library. That helped a lot. is() is a bit weird, but I described it in my "D Cookbook" to some success... I am going to order it...even though it is not available on

Re: Extracting user defined attributes on function parameters

2020-04-14 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Apr 15, 2020 at 12:01:51AM +, Adam D. Ruppe via Digitalmars-d-learn wrote: [...] > is() is a bit weird, but I described it in my "D Cookbook" to some > success... and writing that description helped me make sense of it. > The docs list like seven forms of it, but they are mostly just

Re: Extracting user defined attributes on function parameters

2020-04-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 14 April 2020 at 21:54:14 UTC, Jean-Louis Leroy wrote: O.kay. It looks like `is` is D's Swiss army chainsaw. Aye, is and __traits are the two built-in compile-time reflection avenues. The phobos std.traits things (for the most part, look at the source for the default

Re: Extracting user defined attributes on function parameters

2020-04-14 Thread Jean-Louis Leroy via Digitalmars-d-learn
On Tuesday, 14 April 2020 at 21:44:51 UTC, Adam D. Ruppe wrote: On Tuesday, 14 April 2020 at 21:35:12 UTC, Jean-Louis Leroy wrote: I can see them: There's some weird tricks to it. Check out my old blog sidebar about it here:

Re: Extracting user defined attributes on function parameters

2020-04-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 14 April 2020 at 21:35:12 UTC, Jean-Louis Leroy wrote: I can see them: There's some weird tricks to it. Check out my old blog sidebar about it here: http://dpldocs.info/this-week-in-d/Blog.Posted_2019_02_11.html#how-to-get-uda-on-a-function-param

Extracting user defined attributes on function parameters

2020-04-14 Thread Jean-Louis Leroy via Digitalmars-d-learn
I can see them: import std.traits; struct foo; struct bar; void f(@foo int, @foo @bar @("baz") real); pragma(msg, Parameters!f); // (@(foo) int, @(tuple(tuple(foo), tuple(bar)), tuple("baz")) real) ...but I cannot find how to get hold of them: pragma(msg,