Re: Two questions

2019-01-02 Thread IM via Digitalmars-d-learn
On Wednesday, 2 January 2019 at 17:49:52 UTC, H. S. Teoh wrote: On Wed, Jan 02, 2019 at 05:38:41PM +, IM via Digitalmars-d-learn wrote: 1- How do I do in D the equivalent of the following C++ macro? #define OUT_VAL(val) (count << #val << " = " << val << endl) In particular the #val above

Re: Two questions

2019-01-02 Thread IM via Digitalmars-d-learn
On Wednesday, 2 January 2019 at 21:56:03 UTC, Steven Schveighoffer wrote: On 1/2/19 12:38 PM, IM wrote: [...] With those ... I have to guess. There are 2 possibilities. Possibility 1: there is a method named 'doSomeWork' which takes at least one parameter. This overrides the UFCS function

Re: Two questions

2019-01-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/2/19 12:38 PM, IM wrote: 2- Yesterday I was experimenting with something and I wrote something like the following: struct MyType {   ... } void doSomeWork(ref MyType o) {    ... } auto t = MyType(...); t.doSomeWork(); // <-- failed to compile. Why did the above UFCS call fail to

Re: two questions on enums

2014-04-04 Thread Chris Williams
On Thursday, 3 April 2014 at 23:16:14 UTC, Eric wrote: Okay - I'm new to D, and I'm comming from a java background. Suppose you are designing an API, and you want the user to supply arguments as an enum. But the user needs to define the enum, so how can the API know in advance what enum to

Re: two questions on enums

2014-04-04 Thread Eric
By using the interface, it also forces the user to include all of the attributes of each pin such as direction, max load, DC current, etc. Since class type enums are references, they are light, - and they should be immutable - so they are thread safe aslo. I'm not sure how you're using

Re: two questions on enums

2014-04-03 Thread bearophile
Eric: 1). Is there a way to import an enum so that you don't need to qualify each instance with the type name? Something like java does with its static import. In some cases you can use the handy with() statement for that purpose. One example usages: final switch (foo) with (MyEnum) {

Re: two questions on enums

2014-04-03 Thread Eric
In some cases you can use the handy with() statement for that purpose. One example usages: final switch (foo) with (MyEnum) { ... } Okay - the with statement may help in some cases. I'll have to try it out... Using an enumeration of class instances isn't a good idea, they are

Re: two questions on enums

2014-04-03 Thread bearophile
Eric: I disagree. If you just think of a class type enum as a class type, then what you say makes sense. But if you instead think of it as a more powerful enum then it can enhance data safety in a program. I was speaking about the current D enum, as implemented and as designed. Regarding

Re: two questions on enums

2014-04-03 Thread Eric
On Thursday, 3 April 2014 at 22:34:19 UTC, bearophile wrote: Eric: I disagree. If you just think of a class type enum as a class type, then what you say makes sense. But if you instead think of it as a more powerful enum then it can enhance data safety in a program. I was speaking about

Re: Two Questions about Linking to C libraries

2013-11-27 Thread Craig Dillabaugh
On Wednesday, 27 November 2013 at 07:30:58 UTC, Jacob Carlborg wrote: On 2013-11-27 02:26, Craig Dillabaugh wrote: 2. Once I think my bindings are stable I would like to add them to Deimos or DUB registries. Are there any recommendations for testing bindings? I checked through some other

Re: Two Questions about Linking to C libraries

2013-11-26 Thread Jesse Phillips
Don't have answers. Do you still get segfault removing SHPClose( hShp ); Other comment: writeln(Bounds = [ ~to!string(pad_min_bound) ~ , ~ to!string(pad_max_bound) ~ ]); writeln(Bounds = [, pad_min_bound, ,, pad_max_bound, ]);

Re: Two Questions about Linking to C libraries

2013-11-26 Thread Craig Dillabaugh
On Wednesday, 27 November 2013 at 02:36:01 UTC, Jesse Phillips wrote: Don't have answers. Do you still get segfault removing SHPClose( hShp ); Yep. Other comment: writeln(Bounds = [ ~to!string(pad_min_bound) ~ , ~ to!string(pad_max_bound) ~ ]); writeln(Bounds

Re: Two Questions about Linking to C libraries

2013-11-26 Thread Jacob Carlborg
On 2013-11-27 02:26, Craig Dillabaugh wrote: 2. Once I think my bindings are stable I would like to add them to Deimos or DUB registries. Are there any recommendations for testing bindings? I checked through some other bindings on GitHub and didn't see any unit tests or the like. Are there any

Re: Two questions about assignments

2013-05-28 Thread bearophile
I will add it to Bugzilla then, if it's not already there. http://d.puremagic.com/issues/show_bug.cgi?id=10192 Bye, bearophile

Re: Two questions about assignments

2013-05-27 Thread Kenji Hara
On Monday, 27 May 2013 at 18:00:38 UTC, bearophile wrote: Do you know if it's OK to accept x3 assignment and refuse the a2 assignment? struct Foo { immutable(char)[4] bar; } Foo x1 = { AA };// No error. immutable(char)[4] a1 = AA; // No error. void main() { Foo x2 = { AA

Re: Two questions about assignments

2013-05-27 Thread bearophile
Kenji Hara: Thank you very much for your gentle and useful answers :-) struct Foo { immutable(char)[4] bar; } Foo x1 = { AA };// No error. immutable(char)[4] a1 = AA; // No error. void main() { Foo x2 = { AA };// No error. Foo x3 = Foo(AA); // No error.

Re: Two questions about assignments

2013-05-27 Thread Kenji Hara
On Tuesday, 28 May 2013 at 00:29:04 UTC, bearophile wrote: std.typecons.Tuple supports structural assignment before the change. The code also works with 2.062. I know it's not a regression. But you say: Named-field tuple should be a subtype of unnamed-field tuple. You can have sub-typing, or

Re: Two questions about %a

2011-03-04 Thread Magnus Lie Hetland
On 2011-03-04 03:16:50 +0100, Nick Sabalausky said: I'm no floating-point expert, but I would think that the only way to get an exact representation would be to output the raw data in hex (or binary, or octal, etc): writef(0x%X, cast(ulong)1.2); That's also an option, certainly. Then I

Re: Two questions about %a

2011-03-03 Thread Nick Sabalausky
Lars T. Kyllingstad public@kyllingen.NOSPAMnet wrote in message news:iknfsh$13ga$1...@digitalmars.com... On Wed, 02 Mar 2011 13:35:11 +0100, Magnus Lie Hetland wrote: First question: I just noticed that writefln(%a, 1.2) writes 0x1.3p+0, while writeln(format(%a, 1.2)) (that is,

Re: Two questions about %a

2011-03-02 Thread Lars T. Kyllingstad
On Wed, 02 Mar 2011 13:35:11 +0100, Magnus Lie Hetland wrote: First question: I just noticed that writefln(%a, 1.2) writes 0x1.3p+0, while writeln(format(%a, 1.2)) (that is, with std.string.format) writes 0x9.8p-3 ... wouldn't it be nice to be consistent here? (The

Re: Two questions about converting a C header file

2010-09-24 Thread Sean Kelly
Juanjo Alvarez Wrote: Hi, I'm converting a C header file but there are two things left: 1. If the header file contains some D reserved word (in my case, in and out in a struct) what is the best way to workaround it? Do you write another C file and link about it? The convention I use

Re: Two questions about converting a C header file

2010-09-23 Thread Juanjo Alvarez
Auto reply, found both: 1. Just rename the varname, stupid stupid stupid! 2. import std.c.stdarg On Thu, 23 Sep 2010 19:44:44 +, Juanjo Alvarez wrote: Hi, I'm converting a C header file but there are two things left: 1. If the header file contains some D reserved word (in my case,