Re: (How) can reflection recoginzie `extern` variables?

2024-10-11 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 11 October 2024 at 17:58:00 UTC, Salih Dincer wrote: There is no __traits mechanism to directly determine ... ```d extern int x; int y; pragma(msg, __traits(isSame, y, x)); ``` I tried it now, but as I said, it wouldn't be unreasonable: SDB@79

Re: (How) can reflection recoginzie `extern` variables?

2024-10-11 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 11 October 2024 at 16:33:55 UTC, Quirin Schroll wrote: ```d extern int x; // int y; ``` (How) can I get the information that `x` is `extern` and `y` is not? There seems to be no `__traits` for it. There is no __traits mechanism to directly determine whether a symbol is extern.

(How) can reflection recoginzie `extern` variables?

2024-10-11 Thread Quirin Schroll via Digitalmars-d-learn
```d extern int x; // int y; ``` (How) can I get the information that `x` is `extern` and `y` is not? There seems to be no `__traits` for it.

Re: How to do reflection on alias symbols

2023-11-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 17, 2023 2:11:30 AM MST Arafel via Digitalmars-d-learn wrote: > I mean, in order to know if something is an `enum`, I need to do: > > ```d > enum isEnum(alias a) = is(typeof(a)) && !is(typeof(&a)); > ``` > > which feels like the wrong approach, and too much error-prone. I also

Re: How to do reflection on alias symbols

2023-11-17 Thread Arafel via Digitalmars-d-learn
looks it's one of those that's gone under the radar. - Jonathan M Davis Thanks for finding it! I think that in general D could do with a more systematic approach to reflection. For me, it's one of its greatest features, and it's a bit of a pity that it needs to be done

Re: How to do reflection on alias symbols

2023-11-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 16, 2023 6:04:43 PM MST Jonathan M Davis via Digitalmars-d-learn wrote: > I would suggest that you open up a bug report for it - > https://issues.dlang.org - and certainly, there's a good argument that what > you're seeing here is a bug. I fully expect that what you're trying

Re: How to do reflection on alias symbols

2023-11-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 16, 2023 3:03:25 AM MST Arafel via Digitalmars-d-learn wrote: > Hi all, > > Please consider the following currently non-working code: > > ```d > struct bar { > public alias pubInt = int; > private alias privInt = int; > } > > static foreach(member ; __traits(allMemb

How to do reflection on alias symbols

2023-11-16 Thread Arafel via Digitalmars-d-learn
Hi all, Please consider the following currently non-working code: ```d struct bar { public alias pubInt = int; private alias privInt = int; } static foreach(member ; __traits(allMembers, bar)) { // Error: argument `int` has no visibility pragma(msg, __traits(getVisibility, __tra

Re: Reflection on the book D web development.

2020-11-28 Thread Alaindevos via Digitalmars-d-learn
& Golang has Martini which is quite easy to use, https://www.youtube.com/watch?v=tUFzdUIjVRg

Re: Reflection on the book D web development.

2020-11-25 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 25 November 2020 at 17:26:44 UTC, Alaindevos wrote: hunt-http has no documentation and does not looks usable to me. What looks usable is kemal & the crystal language, https://kemalcr.com/guide/ Looks like Sinatra. That makes sense given the relationship of Crystal to Ruby. Many l

Re: Reflection on the book D web development.

2020-11-25 Thread Alaindevos via Digitalmars-d-learn
hunt-http has no documentation and does not looks usable to me. What looks usable is kemal & the crystal language, https://kemalcr.com/guide/

Re: Reflection on the book D web development.

2020-11-23 Thread bachmeier via Digitalmars-d-learn
ethod. Then it stops. What I find too complex: - Sessions, session data , session variables - Handler functions and delegates, compile-time reflection, prefixes, annotation. - Authentication - Validating user input This can be improved by improving documentation in very small steps. As comparison

Re: Reflection on the book D web development.

2020-11-21 Thread Alaindevos via Digitalmars-d-learn
data , session variables - Handler functions and delegates, compile-time reflection, prefixes, annotation. - Authentication - Validating user input This can be improved by improving documentation in very small steps. As comparison here a tutorial of ruby-flask which uses only small ste

Re: Reflection on the book D web development.

2020-11-21 Thread aberba via Digitalmars-d-learn
On Friday, 20 November 2020 at 19:12:38 UTC, Alaindevos wrote: I bought the book "D Web Development". I understand only 20% of the book,the other 80% is way above my head. Compare, I own a book on flask development, and I understand 100% of it. Which means I can use dlang for anything except QT

Re: Reflection on the book D web development.

2020-11-20 Thread CraigDillabaugh via Digitalmars-d-learn
On Friday, 20 November 2020 at 19:12:38 UTC, Alaindevos wrote: I bought the book "D Web Development". I understand only 20% of the book,the other 80% is way above my head. Compare, I own a book on flask development, and I understand 100% of it. Which means I can use dlang for anything except QT

Reflection on the book D web development.

2020-11-20 Thread Alaindevos via Digitalmars-d-learn
I bought the book "D Web Development". I understand only 20% of the book,the other 80% is way above my head. Compare, I own a book on flask development, and I understand 100% of it. Which means I can use dlang for anything except QT and serious web development ...

Re: Run-time reflection for class inheritance

2019-12-02 Thread Michael Green via Digitalmars-d-learn
On Sunday, 1 December 2019 at 14:42:46 UTC, Adam D. Ruppe wrote: You can get the type at runtime by simply casting it... if(auto c = cast(EventSocket) event) { // is an event socket } Thanks. I guess you need to be careful about which order you do those tests so as not to cast to more gen

Re: Run-time reflection for class inheritance

2019-12-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 1 December 2019 at 12:26:03 UTC, Michael Green wrote: I don't know if this would be a sensible approach to try and get at the actual class types for objects stored in some container at runtime? You can get the type at runtime by simply casting it... if(auto c = cast(EventSocket) ev

Re: Run-time reflection for class inheritance

2019-12-01 Thread Michael Green via Digitalmars-d-learn
On Sunday, 1 December 2019 at 12:26:03 UTC, Michael Green wrote: interface Event { [note to self - shouldn't make last minute checks and reverse them by hand before posting] That should of course read: class Event {

Run-time reflection for class inheritance

2019-12-01 Thread Michael Green via Digitalmars-d-learn
I don't know if this would be a sensible approach to try and get at the actual class types for objects stored in some container at runtime? I have noticed that this approach doesn't work if Event is an interface rather than a ancestor class. ``` import std.stdio; import std.string; import s

Re: Blog Post #0039 - File Dialog V - Adding SaveAs and Titlebar Filename Reflection

2019-05-28 Thread Ron Tarrant via Digitalmars-d-learn
Hi WebFreak. I'm glad you're getting something out of it. I started this because it's the kind of thing I wished was out there. It's good to know I'm not the only one. On Tuesday, 28 May 2019 at 12:58:12 UTC, WebFreak001 wrote: Could you maybe add screenshots to each blog post? I've had a t

Re: Blog Post #0039 - File Dialog V - Adding SaveAs and Titlebar Filename Reflection

2019-05-28 Thread WebFreak001 via Digitalmars-d-learn
On Tuesday, 28 May 2019 at 09:47:23 UTC, Ron Tarrant wrote: Good day to you all. 'Tis another Tuesday and time for a new blog post. This is a continuation of the series on Dialogs and further, a continuation of the mini-series-within-a-series on file Dialogs. The subject is in the title as is

Blog Post #0039 - File Dialog V - Adding SaveAs and Titlebar Filename Reflection

2019-05-28 Thread Ron Tarrant via Digitalmars-d-learn
Good day to you all. 'Tis another Tuesday and time for a new blog post. This is a continuation of the series on Dialogs and further, a continuation of the mini-series-within-a-series on file Dialogs. The subject is in the title as is fitting for a blog post about putting things in the titleba

Re: Derived classes? Reflection

2019-03-29 Thread Alex via Digitalmars-d-learn
On Saturday, 13 April 2013 at 17:50:00 UTC, Tofu Ninja wrote: On Saturday, 13 April 2013 at 17:45:12 UTC, Tofu Ninja wrote: Maybe this is helpfully: http://forum.dlang.org/thread/scgjnudclnwlbdqqd...@forum.dlang.org Oddly enough, I found that at about the same time you posted it. Sadly this

Re: Converting member variables to strings with using reflection from base class

2017-12-22 Thread Mengu via Digitalmars-d-learn
On Friday, 22 December 2017 at 22:09:05 UTC, H. S. Teoh wrote: On Fri, Dec 22, 2017 at 09:13:31PM +, kerdemdemir via Digitalmars-d-learn wrote: I want to make a logging function for member variables by using reflection. [...] class B { void Log() { auto a = [__traits

Re: Converting member variables to strings with using reflection from base class

2017-12-22 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Dec 22, 2017 at 09:13:31PM +, kerdemdemir via Digitalmars-d-learn wrote: > I want to make a logging function for member variables by using reflection. [...] > class B > { > void Log() > { > auto a = [__traits(derivedMembers, D)]; >

Converting member variables to strings with using reflection from base class

2017-12-22 Thread kerdemdemir via Digitalmars-d-learn
I want to make a logging function for member variables by using reflection. import std.stdio; class D : B { override void foo() { a = 4.0; b = 3.0; } double a; double b; } class B { void Log() { auto a = [__traits(derivedMembers, D

Re: learning reflection in D

2017-10-05 Thread drug via Digitalmars-d-learn
05.10.2017 18:04, Adam D. Ruppe пишет: On Thursday, 5 October 2017 at 14:59:10 UTC, drug wrote: 1) why .stringof and typeid() is equal logically and different in fact? What is difference between them? Is it that stringof compile time and typeid runtime things? Anyway wouldn't it be better they

Re: learning reflection in D

2017-10-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 5 October 2017 at 14:59:10 UTC, drug wrote: 1) why .stringof and typeid() is equal logically and different in fact? What is difference between them? Is it that stringof compile time and typeid runtime things? Anyway wouldn't it be better they will equal both logically and literally

learning reflection in D

2017-10-05 Thread drug via Digitalmars-d-learn
https://run.dlang.io/is/8LbmzG 1) why .stringof and typeid() is equal logically and different in fact? What is difference between them? Is it that stringof compile time and typeid runtime things? Anyway wouldn't it be better they will equal both logically and literally? 2) Where do these attri

Re: Deduplicating template reflection code

2017-04-14 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 14 April 2017 at 17:57:49 UTC, Johannes Pfau wrote: Am Fri, 14 Apr 2017 13:41:45 + schrieb Moritz Maxeiner : [...] Great, thanks that's exactly the solution I wanted. Figuring this out by myself is a bit above my template skill level ;-) -- Johannes No problem, I often e

Re: Deduplicating template reflection code

2017-04-14 Thread Johannes Pfau via Digitalmars-d-learn
Am Fri, 14 Apr 2017 13:41:45 + schrieb Moritz Maxeiner : > On Friday, 14 April 2017 at 11:29:03 UTC, Johannes Pfau wrote: > > > > Is there some way to wrap the 'type selection'? In pseudo-code > > something like this: > > > > enum FilteredOverloads(API) = ... > > > > foreach(Overload, Filtere

Re: Deduplicating template reflection code

2017-04-14 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 14 April 2017 at 11:29:03 UTC, Johannes Pfau wrote: Is there some way to wrap the 'type selection'? In pseudo-code something like this: enum FilteredOverloads(API) = ... foreach(Overload, FilteredOverloads!API) { } Sure, but that's a bit more complex: --- [...] // Igno

Re: Deduplicating template reflection code

2017-04-14 Thread Johannes Pfau via Digitalmars-d-learn
Am Fri, 14 Apr 2017 08:55:48 + schrieb Moritz Maxeiner : > > mixin Foo!(API, (MethodType) { > // function dependent code here > }); > foo(); > --- > > Option 2: Code generation using CTFE > > --- > string genFoo(alias API, string justDoIt) > { > import std.array : appender; > auto

Re: Deduplicating template reflection code

2017-04-14 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 14 April 2017 at 08:24:00 UTC, Johannes Pfau wrote: I've got this code duplicated in quite some functions: - [...]1 foreach (MethodType; overloads) { // function dependent code here } [...]2

Re: Deduplicating template reflection code

2017-04-14 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 14 April 2017 at 08:24:00 UTC, Johannes Pfau wrote: I've got this code duplicated in quite some functions: - foreach (member; __traits(derivedMembers, API)) { // Guards against private members static if (__traits(compiles, __traits(getMember, API, member))

Deduplicating template reflection code

2017-04-14 Thread Johannes Pfau via Digitalmars-d-learn
I've got this code duplicated in quite some functions: - foreach (member; __traits(derivedMembers, API)) { // Guards against private members static if (__traits(compiles, __traits(getMember, API, member))) { static if (isSomeFunction!(__traits(getMember, API

Re: Reflection in D

2017-01-28 Thread medhi558 via Digitalmars-d-learn
thank you, the second method works perfectly. I have one last problem, I start thread and in thread Protocol.GetInstance(id) return null while in main thread it works. My class : class ProtocolMessageManager { private static TypeInfo_Class[uint] m_types; shared static this()

Re: Reflection in D

2017-01-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 28 January 2017 at 07:10:27 UTC, medhi558 wrote: I have a last question, currently i use : if(lc.name.indexOf("protocol.messages") != -1) If they're all in the same module, you can also use the compile time reflection to scan the module for classes. That's

Re: Reflection in D

2017-01-28 Thread medhi558 via Digitalmars-d-learn
On Saturday, 28 January 2017 at 09:05:13 UTC, rumbu wrote: As long as your class has a default constructor, you can use directly Object.factory(id): public static NetworkMessage GetInstance(string id) { return cast(NetworkMessage)(Object.factory(id)); } It isn't possible. My function when I

Re: Reflection in D

2017-01-28 Thread medhi558 via Digitalmars-d-learn
abstract class NetworkMessage { uint MessageId; // } override class QueueStatusUpdateMessage : NetworkMessage { uint MessageId = 1; // } override class Message2 : NetworkMessage { uint MessageId = 2; // } override class Message3 : NetworkMessage { uint Me

Re: Reflection in D

2017-01-28 Thread rumbu via Digitalmars-d-learn
On Saturday, 28 January 2017 at 07:03:51 UTC, medhi558 wrote: public static NetworkMessage GetInstance(string id) { auto v = (id in ProtocolMessageManager.m_types); if (v !is null) return cast(NetworkMessage)ProtocolMessageManager.m_types[id].create(); else

Re: Reflection in D

2017-01-28 Thread rumbu via Digitalmars-d-learn
On Saturday, 28 January 2017 at 08:18:15 UTC, medhi558 wrote: On Saturday, 28 January 2017 at 07:39:51 UTC, rumbu wrote: On Saturday, 28 January 2017 at 07:10:27 UTC, medhi558 wrote: I have a last question, currently i use : if(lc.name.indexOf("protocol.messages") != -1) To know if the class i

Re: Reflection in D

2017-01-28 Thread medhi558 via Digitalmars-d-learn
On Saturday, 28 January 2017 at 07:39:51 UTC, rumbu wrote: On Saturday, 28 January 2017 at 07:10:27 UTC, medhi558 wrote: I have a last question, currently i use : if(lc.name.indexOf("protocol.messages") != -1) To know if the class is a NetworkMessage, Would be possible to do this if(lc is Ne

Re: Reflection in D

2017-01-27 Thread rumbu via Digitalmars-d-learn
On Saturday, 28 January 2017 at 07:10:27 UTC, medhi558 wrote: I have a last question, currently i use : if(lc.name.indexOf("protocol.messages") != -1) To know if the class is a NetworkMessage, Would be possible to do this if(lc is NetworkMessage) Sorry for my English, i speak french. if (

Re: Reflection in D

2017-01-27 Thread medhi558 via Digitalmars-d-learn
I have a last question, currently i use : if(lc.name.indexOf("protocol.messages") != -1) To know if the class is a NetworkMessage, Would be possible to do this if(lc is NetworkMessage) Sorry for my English, i speak french.

Re: Reflection in D

2017-01-27 Thread medhi558 via Digitalmars-d-learn
I develop a game server. Currently I use a switch : import protocol.messages.connection.Message1; import protocol.messages.connection.Message2; import protocol.messages.queues.Message3; import .. import protocol.messages.NetworkMessage; class ProtocolMessageManager { public static N

Re: Reflection in D

2017-01-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 27 January 2017 at 21:02:13 UTC, medhi558 wrote: Hello, I would like to know if it is possible to recover all classes in the project in D. Yes, `foreach(mod; ModuleInfo) foreach(lc; mod.localClasses)`... but why do you want it? That facility is kinda limited in doing many things wi

Reflection in D

2017-01-27 Thread medhi558 via Digitalmars-d-learn
Hello, I would like to know if it is possible to recover all classes in the project in D. Example in c# : Assembly asm = Assembly.GetAssembly(typeof(MyClass)); foreach (Type type in asm.GetTypes()) { }

Re: Reflection: Order of fields guaranteed?

2016-10-22 Thread Michael Coulombe via Digitalmars-d-learn
On Friday, 21 October 2016 at 01:51:44 UTC, Stefan Koch wrote: On Friday, 21 October 2016 at 01:34:44 UTC, Nick Sabalausky wrote: When using reflection to obtain the fields of a class/struct, is there any guarantee that the order is the same as the order the fields are defined? Yes they

Re: Reflection: Order of fields guaranteed?

2016-10-21 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 21 October 2016 at 01:34:44 UTC, Nick Sabalausky wrote: When using reflection to obtain the fields of a class/struct, is there any guarantee that the order is the same as the order the fields are defined? Yes they should always come in lexical order.

Reflection: Order of fields guaranteed?

2016-10-21 Thread Nick Sabalausky via Digitalmars-d-learn
When using reflection to obtain the fields of a class/struct, is there any guarantee that the order is the same as the order the fields are defined?

Re: Probably a real simple compile-time reflection question?

2016-07-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 9 July 2016 at 21:12:24 UTC, WhatMeWorry wrote: foreach( i, str; myClassMembers) What are you doing to get myClassMembers? If it is __traits(allMembers), it just gives you the *names* of the members. To get the actual thing, you then do __traits(getMember, object, str) and can c

Probably a real simple compile-time reflection question?

2016-07-09 Thread WhatMeWorry via Digitalmars-d-learn
class C { this(){ _i = 0; _j = 0; } void setVar(int i) { _i = i; } int getVar() { return _i; } int _i; int _j; } writeln("C"); foreach( i, str; myClassMembers) { writeln("member ", i, " = ", str); TypeInfo ti = typeid(str); writeln("type id is ", ti);

Request for feedback on reflection based module

2016-01-18 Thread Ross Harrison via Digitalmars-d-learn
Hi I'm trying out D and wanted to try some features cpp doesn't have yet. So I put together a small json parsing, generating looking based on reflection. Is there anything wrong with how I'm working with it in the module? https://github.com/rharriso/JSONInflater.d Thanks in advance

Re: package reflection

2014-06-22 Thread Shammah Chancellor via Digitalmars-d-learn
On 2014-06-22 14:11:58 +, sigod said: In the video "Case Studies In Simplifying Code With Compile-Time Reflection" [was pointed out][0] that it is possible to reflect on imported packages. So, I tried: reflection.d: ``` import std.stdio; import test.module1; import test.modu

package reflection

2014-06-22 Thread sigod via Digitalmars-d-learn
In the video "Case Studies In Simplifying Code With Compile-Time Reflection" [was pointed out][0] that it is possible to reflect on imported packages. So, I tried: reflection.d: ``` import std.stdio; import test.module1; import test.module2; void main() { foreach (m

Re: Class Data Members Name Reflection

2014-06-10 Thread Kapps via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 20:01:37 UTC, Nordlöw wrote: Notice that A.init.tupleof segfaults for classes so that is _not_ an adviced solution in a generic solution! There's no need to use .init: import std.stdio; struct Foo { int a, b; } void main() { writeln(__traits(id

Re: Class Data Members Name Reflection

2014-06-10 Thread Kapps via Digitalmars-d-learn
On Tuesday, 10 June 2014 at 16:13:31 UTC, Adam D. Ruppe wrote: Two options: do allMembers and filter it out to only be data members, or do some slicing of tupleof.stringof: S s; foreach(idx, member; s.tupleof) { writeln("Name: ", s.tupleof[idx].stringof[2..$]); } The tupleof[idx] inside th

Re: Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
ement pretty printing to multiple backends (currently testing HTML) using as much of D's compile time reflection as possible: https://github.com/nordlow/justd/blob/master/pprint.d I've currently defined mappings from InputRanges of Aggregates (tuples, structs, and classes) to HTML table

Re: Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
BTW: Can DMD serve use file and line location of user defined type aswell? Thx! Correction: I mean serve *us*

Re: Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
I am not sure I understand the question. Does this help? struct A { int x; double y; } void main() { foreach (idx, elem; A.init.tupleof) { pragma(msg, __traits(identifier, A.tupleof[idx])); } } // output: // x // y Exactly what I wanted!

Re: Class Data Members Name Reflection

2014-06-10 Thread Dicebot via Digitalmars-d-learn
HTML) using as much of D's compile time reflection as possible: https://github.com/nordlow/justd/blob/master/pprint.d I've currently defined mappings from InputRanges of Aggregates (tuples, structs, and classes) to HTML tables where - the aggregate members are mapped to table col

Re: Class Data Members Name Reflection

2014-06-10 Thread Adam D. Ruppe via Digitalmars-d-learn
book talks about reflection, I think I talked about some of this in there: http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book ) foreach (ix, memb; arg.args[0].front.tupleof) Eeek, I actually used s for a reason there - it gives you a simple name that is easily

Re: Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
On Tuesday, 10 June 2014 at 16:13:31 UTC, Adam D. Ruppe wrote: Two options: do allMembers and filter it out to only be data members, or do some slicing of tupleof.stringof: What trait should I use to filter out data members? S s; foreach(idx, member; s.tupleof) { writeln("Name: ", s.tupleo

Re: Class Data Members Name Reflection

2014-06-10 Thread Adam D. Ruppe via Digitalmars-d-learn
Two options: do allMembers and filter it out to only be data members, or do some slicing of tupleof.stringof: S s; foreach(idx, member; s.tupleof) { writeln("Name: ", s.tupleof[idx].stringof[2..$]); } The tupleof[idx] inside the loop is important instead of just using member because then y

Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
Is there a way to iterate over the symbolic names of the data members of a class instance? I'm currently using .tupleof to get its values (and in turn types) to implement pretty printing to multiple backends (currently testing HTML) using as much of D's compile time reflection a

Re: DMD fail when using both reflection and UDA

2014-06-01 Thread bioinfornatics via Digitalmars-d-learn
On Sunday, 1 June 2014 at 16:18:45 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: In any case, it's an internal compiler error, so it's a bug. Users should never see ICEs. Could you please report it, with the entire error message? Ok thanks is don at https://issues.dlang.org/show_bug.cgi?

Re: DMD fail when using both reflection and UDA

2014-06-01 Thread Philippe Sigaud via Digitalmars-d-learn
In any case, it's an internal compiler error, so it's a bug. Users should never see ICEs. Could you please report it, with the entire error message?

Re: DMD fail when using both reflection and UDA

2014-06-01 Thread bioinfornatics via Digitalmars-d-learn
stupid me bug was at the end a[0] = 1; become a[0] = "1"; but error error was so stnange to me i though that was a bug

Re: DMD fail when using both reflection and UDA

2014-06-01 Thread bioinfornatics via Digitalmars-d-learn
On Sunday, 1 June 2014 at 16:02:47 UTC, bioinfornatics wrote: DMD (dmdfe 2.066) fail when i use UDA which store a delegate code below works if i remove @section UDA otheswise it give this error: dmd: statement.c:714: ErrorStatement::ErrorStatement(): Assertion `global.gaggedErrors || global.

DMD fail when using both reflection and UDA

2014-06-01 Thread bioinfornatics via Digitalmars-d-learn
DMD (dmdfe 2.066) fail when i use UDA which store a delegate code below works if i remove @section UDA otheswise it give this error: dmd: statement.c:714: ErrorStatement::ErrorStatement(): Assertion `global.gaggedErrors || global.errors' failed. is a bug ? --- CODE also on dpaste http

Re: templates, enums, CT reflection: compiler bug or not?

2014-04-06 Thread captaindet
no one any ideas? well, i filed two bug reports for now: https://d.puremagic.com/issues/show_bug.cgi?id=12532 https://d.puremagic.com/issues/show_bug.cgi?id=12533

Does D have reflection?

2014-04-05 Thread dnspies
Is there a way to obtain field and method names (as strings) or assign to fields (of structs or classes) if the string is a name which is only known at runtime? For instance, could I write a generic function to reconstruct any object of any type from a JSON object?

Re: Does D have reflection?

2014-04-05 Thread Adam D. Ruppe
On Sunday, 6 April 2014 at 02:25:32 UTC, dnspies wrote: For instance, could I write a generic function to reconstruct any object of any type from a JSON object? Yes, you can use __traits(allMembers) at compile time to build a runtime function that does the setting. .tupleof can do it too, whi

templates, enums, CT reflection: compiler bug or not?

2014-04-04 Thread captaindet
i stumbled upon something strange while wondering around meta/codegen-lands. it took me almost a week to reduce it to the following test case. i have no clue what is going on, whether i have entered bug territory or just encountered my own limitations mind you, i have 2 issues with the cod

Re: reflection over templates

2014-03-19 Thread simendsjo
On 03/19/2014 05:34 PM, Adam D. Ruppe wrote: On Wednesday, 19 March 2014 at 16:10:52 UTC, Dicebot wrote: Wait just a bit more https://github.com/D-Programming-Language/dmd/pull/3380 :) megarox. Make it so. Nice. I have some ugly hacks that's probably full of bugs for this (look at the botto

Re: reflection over templates

2014-03-19 Thread Andrej Mitrovic
On 3/19/14, Adam D. Ruppe wrote: > Is there anything we can do with static if to identify it as a > template? https://github.com/D-Programming-Language/dmd/pull/3380 > And after we determine it is a template, can we extract the > required arguments list like we can with a regular function at > a

reflection over templates

2014-03-19 Thread Adam D. Ruppe
Given: template Foo(string T) { enum Foo = to!int(T); } (or anything else, really) Is there anything we can do with static if to identify it as a template? I tried: static if(is(Foo == template)) {} // nope, basic type expected, not template Note that is(typeof(Foo) == function) {} is ho

Re: reflection over templates

2014-03-19 Thread Adam D. Ruppe
On Wednesday, 19 March 2014 at 16:10:52 UTC, Dicebot wrote: Wait just a bit more https://github.com/D-Programming-Language/dmd/pull/3380 :) megarox. Make it so.

Re: reflection over templates

2014-03-19 Thread Dicebot
Wait just a bit more https://github.com/D-Programming-Language/dmd/pull/3380 :)

Re: reflection over templates

2014-03-19 Thread Dicebot
As a workaround one can use set of relevant trait checks: 1) type is void 2) is not a variable or callable 3) .stringof fits "NAME(ARGS)" pattern

Re: reflection over templates

2014-03-19 Thread Dicebot
On Wednesday, 19 March 2014 at 16:18:17 UTC, Andrej Mitrovic wrote: And after we determine it is a template, can we extract the required arguments list like we can with a regular function at all? Well there's TemplateArgsOf for *instantiations*, but I'm not sure how one would do it with non-in

DLL's reflection and Exceptions

2013-12-28 Thread TheFlyingFiddle
Hello everyone! I'm currently working on a run-time reflection module. The intent of this module is to simplify the process of loading functions / classes / structs from DLL's loaded at run-time. It works something like this ATM: //In pluggin.d (A dll module) void foo() { ... }

Re: Is it possible using reflection or similar to extract only public method names from classes?

2013-08-07 Thread Adam D. Ruppe
On Wednesday, 7 August 2013 at 11:47:27 UTC, Gary Willoughby wrote: I thought using __traits(...) was frowned upon? They want to give them phobos wrappers that might be a little prettier, but other than beauty/ugliness there's no reason not to use it.

Re: Is it possible using reflection or similar to extract only public method names from classes?

2013-08-07 Thread Gary Willoughby
On Tuesday, 6 August 2013 at 22:55:49 UTC, Marek Janukowicz wrote: Gary Willoughby wrote: Is it possible using reflection or similar to extract only public method names from classes? I'm thinking how i would go about writing a unit test/mocking framework, investigating how i can g

Re: Is it possible using reflection or similar to extract only public method names from classes?

2013-08-07 Thread Jacob Carlborg
On 2013-08-07 00:57, Marek Janukowicz wrote: See traits: http://dlang.org/traits.html Look for: getProtection, getVirtualFunctions, getVirtualMethods. And "allMembers" and "derivedMembers". -- /Jacob Carlborg

Re: Is it possible using reflection or similar to extract only public method names from classes?

2013-08-06 Thread H. S. Teoh
On Tue, Aug 06, 2013 at 11:41:35PM +0200, Gary Willoughby wrote: > Is it possible using reflection or similar to extract only public > method names from classes? I'm thinking how i would go about writing > a unit test/mocking framework, investigating how i can gather > infor

Re: Is it possible using reflection or similar to extract only public method names from classes?

2013-08-06 Thread Marek Janukowicz
Gary Willoughby wrote: > Is it possible using reflection or similar to extract only public > method names from classes? I'm thinking how i would go about > writing a unit test/mocking framework, investigating how i can > gather information about such things before i manipulate

Is it possible using reflection or similar to extract only public method names from classes?

2013-08-06 Thread Gary Willoughby
Is it possible using reflection or similar to extract only public method names from classes? I'm thinking how i would go about writing a unit test/mocking framework, investigating how i can gather information about such things before i manipulate them.

Re: Derived classes? Reflection

2013-04-14 Thread Benjamin Thaut
Am 13.04.2013 19:49, schrieb Tofu Ninja: On Saturday, 13 April 2013 at 17:45:12 UTC, Tofu Ninja wrote: Maybe this is helpfully: http://forum.dlang.org/thread/scgjnudclnwlbdqqd...@forum.dlang.org Oddly enough, I found that at about the same time you posted it. Sadly this does not provide a co

Re: Derived classes? Reflection

2013-04-13 Thread Tofu Ninja
On Saturday, 13 April 2013 at 17:45:12 UTC, Tofu Ninja wrote: Maybe this is helpfully: http://forum.dlang.org/thread/scgjnudclnwlbdqqd...@forum.dlang.org Oddly enough, I found that at about the same time you posted it. Sadly this does not provide a compile time solution, only runtime.

Re: Derived classes? Reflection

2013-04-13 Thread Tofu Ninja
Maybe this is helpfully: http://forum.dlang.org/thread/scgjnudclnwlbdqqd...@forum.dlang.org Oddly enough, I found that at about the same time you posted it.

Re: Derived classes? Reflection

2013-04-13 Thread Namespace
On Saturday, 13 April 2013 at 16:16:03 UTC, Tofu Ninja wrote: Currently is there a way to get all of the subclasses of a class at compile time? It seems like something that should be possible using traits but I can't seems to see how. Something like class A{...} class B:A{...} class C:A{...}

Re: Derived classes? Reflection

2013-04-13 Thread Andrej Mitrovic
On 4/13/13, Tofu Ninja wrote: > Currently is there a way to get all of the subclasses of a class > at compile time? There might be things like using .moduleinfo and traversing imports to find all classes, but I think separate compilation makes this unreliable. There is however BaseClassTuple in

Derived classes? Reflection

2013-04-13 Thread Tofu Ninja
Currently is there a way to get all of the subclasses of a class at compile time? It seems like something that should be possible using traits but I can't seems to see how. Something like class A{...} class B:A{...} class C:A{...} ... foreach(auto t ; getsubclass(A)) { ... } Any help wou

Re: question with compile-time reflection

2013-03-10 Thread Rob T
On Monday, 11 March 2013 at 00:26:25 UTC, anonymous wrote: On Monday, 11 March 2013 at 00:10:46 UTC, Rob T wrote: template NDimensionalArrayType(T,alias size) I'm wondering what "alias size" does? I can't find that form documented anywhere, but it seems to be valid. http://dlang.org/template

Re: question with compile-time reflection

2013-03-10 Thread anonymous
On Monday, 11 March 2013 at 00:10:46 UTC, Rob T wrote: template NDimensionalArrayType(T,alias size) I'm wondering what "alias size" does? I can't find that form documented anywhere, but it seems to be valid. http://dlang.org/template.html#TemplateAliasParameter

Re: question with compile-time reflection

2013-03-10 Thread Zhenya
And since alias can represent any symbol,i think that it's correct usage.

Re: question with compile-time reflection

2013-03-10 Thread Zhenya
On Monday, 11 March 2013 at 00:10:46 UTC, Rob T wrote: template NDimensionalArrayType(T,alias size) I'm wondering what "alias size" does? I can't find that form documented anywhere, but it seems to be valid. Thanks. --rt It's just a little hack for known bug - only string and integer valu

  1   2   >