Re: extern(C++) in win32.mak

2018-02-07 Thread Paul D Anderson via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 08:28:23 UTC, Seb wrote: On Wednesday, 7 February 2018 at 06:05:54 UTC, Paul D Anderson wrote: Is there anyone who knows the ins and outs of the makefile that can shed some light? Thanks, Paul I recommend cloning DMD directly from git if you want to compile

Re: extern(C++) in win32.mak

2018-02-07 Thread Paul D Anderson via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 06:18:04 UTC, rikki cattermole wrote: On 07/02/2018 6:05 AM, Paul D Anderson wrote: I don't understand the following line in dmd/src/win32.mak: extern (C++) __gshared const(char)* ddoc_default = import ("default_ddoc_theme.ddoc"); That is a st

extern(C++) in win32.mak

2018-02-06 Thread Paul D Anderson via Digitalmars-d-learn
I don't understand the following line in dmd/src/win32.mak: extern (C++) __gshared const(char)* ddoc_default = import ("default_ddoc_theme.ddoc"); What does the word "import" mean in this context? I can't find any documentation on the use of import in this way, and the line fails to compile

Re: DMD win32.mak error

2017-03-11 Thread Paul D Anderson via Digitalmars-d-learn
On Saturday, 11 March 2017 at 18:02:00 UTC, Stefan Koch wrote: On Saturday, 11 March 2017 at 02:25:15 UTC, Paul D Anderson wrote: On Saturday, 11 March 2017 at 00:34:03 UTC, Paul D Anderson wrote: On Friday, 10 March 2017 at 22:04:23 UTC, Paul D Anderson wrote: [...] I see John Colvin has

Re: DMD win32.mak error

2017-03-10 Thread Paul D Anderson via Digitalmars-d-learn
On Saturday, 11 March 2017 at 00:34:03 UTC, Paul D Anderson wrote: On Friday, 10 March 2017 at 22:04:23 UTC, Paul D Anderson wrote: While building DMD -- "make -fwin32.mak release" -- I received the following error message: echo "2.073.2" > verstr.h Error: don

Re: DMD win32.mak error

2017-03-10 Thread Paul D Anderson via Digitalmars-d-learn
On Friday, 10 March 2017 at 22:04:23 UTC, Paul D Anderson wrote: While building DMD -- "make -fwin32.mak release" -- I received the following error message: echo "2.073.2" > verstr.h Error: don't know how to make '../res/default_ddoc_theme/ddoc' --- err

DMD win32.mak error

2017-03-10 Thread Paul D Anderson via Digitalmars-d-learn
While building DMD -- "make -fwin32.mak release" -- I received the following error message: echo "2.073.2" > verstr.h Error: don't know how to make '../res/default_ddoc_theme/ddoc' --- error level 1 I'm guessing it might be a build configuration problem on my end, but what is the problem? Pa

Re: bigint compile time errors

2015-07-07 Thread Paul D Anderson via Digitalmars-d-learn
On Sunday, 5 July 2015 at 20:35:03 UTC, Kai Nacke wrote: On Friday, 3 July 2015 at 04:08:32 UTC, Paul D Anderson wrote: On Friday, 3 July 2015 at 03:57:57 UTC, Anon wrote: On Friday, 3 July 2015 at 02:37:00 UTC, Paul D Anderson wrote: [...] Should be plusTwo(in BigInt n) instead. Yes

Re: bigint compile time errors

2015-07-03 Thread Paul D Anderson via Digitalmars-d-learn
On Friday, 3 July 2015 at 02:37:00 UTC, Paul D Anderson wrote: The following code fails to compile and responds with the given error message. Varying the "plusTwo" function doesn't work; as long as there is an arithmetic operation the error occurs. [...] https://i

Re: bigint compile time errors

2015-07-02 Thread Paul D Anderson via Digitalmars-d-learn
On Friday, 3 July 2015 at 03:57:57 UTC, Anon wrote: On Friday, 3 July 2015 at 02:37:00 UTC, Paul D Anderson wrote: enum BigInt test1 = BigInt(123); enum BigInt test2 = plusTwo(test1); public static BigInt plusTwo(in bigint n) Should be plusTwo(in BigInt n) instead. Yes, I had aliased

bigint compile time errors

2015-07-02 Thread Paul D Anderson via Digitalmars-d-learn
The following code fails to compile and responds with the given error message. Varying the "plusTwo" function doesn't work; as long as there is an arithmetic operation the error occurs. It seems to mean that there is no way to modify a BigInt at compile time. This seriously limits the usabilit

Re: function default parameters lost

2015-06-26 Thread Paul D Anderson via Digitalmars-d-learn
On Thursday, 25 June 2015 at 14:17:13 UTC, Paul D Anderson wrote: On Thursday, 25 June 2015 at 07:10:57 UTC, tcak wrote: On Thursday, 25 June 2015 at 04:43:51 UTC, Paul D Anderson wrote: I'm trying to pass a function pointer while keeping the default parameter values intact. Give

Re: function default parameters lost

2015-06-25 Thread Paul D Anderson via Digitalmars-d-learn
On Thursday, 25 June 2015 at 07:10:57 UTC, tcak wrote: On Thursday, 25 June 2015 at 04:43:51 UTC, Paul D Anderson wrote: I'm trying to pass a function pointer while keeping the default parameter values intact. Given the following: [...] I filed a bug about 2-3 months ago about de

function default parameters lost

2015-06-24 Thread Paul D Anderson via Digitalmars-d-learn
I'm trying to pass a function pointer while keeping the default parameter values intact. Given the following: import std.traits; import std.stdio; int foo(int a, int b = 1) { return a; } alias FOOP = int function(int, int = 1); struct ST(POOF) { FOOP fctn; this(POOF fctn) { this.

Re: Compiles but does not link

2015-06-24 Thread Paul D Anderson via Digitalmars-d-learn
On Thursday, 25 June 2015 at 00:24:23 UTC, Paul D Anderson wrote: The code snippet below compiles but the linker fails with Error 42: Symbol undefined. What am I doing wrong? void main() { int foo(int a); alias FP = int delegate(int); FP fp = &foo; } Paul Uh, n

Compiles but does not link

2015-06-24 Thread Paul D Anderson via Digitalmars-d-learn
The code snippet below compiles but the linker fails with Error 42: Symbol undefined. What am I doing wrong? void main() { int foo(int a); alias FP = int delegate(int); FP fp = &foo; } Paul

Re: mixin template question

2015-04-11 Thread Paul D Anderson via Digitalmars-d-learn
On Sunday, 12 April 2015 at 04:04:43 UTC, lobo wrote: On Sunday, 12 April 2015 at 03:51:03 UTC, Paul D Anderson wrote: I don't understand why the following code compiles and runs without an error: import std.stdio; mixin template ABC(){ int abc() { return 3; } } mixin ABC; in

mixin template question

2015-04-11 Thread Paul D Anderson via Digitalmars-d-learn
I don't understand why the following code compiles and runs without an error: import std.stdio; mixin template ABC(){ int abc() { return 3; } } mixin ABC; int abc() { return 4; } void main() { writefln("abc() = %s", abc()); } Doesn't the mixin ABC create a function with the same signatu

Re: Function name from function pointer

2015-04-11 Thread Paul D Anderson via Digitalmars-d-learn
On Saturday, 11 April 2015 at 19:08:50 UTC, Marco Leise wrote: Am Sat, 11 Apr 2015 18:28:35 + schrieb "Paul D Anderson" : Is there a way to return the name of a function (a string) from a pointer to that function? Function pointer example from D Reference: --- int function()

Function name from function pointer

2015-04-11 Thread Paul D Anderson via Digitalmars-d-learn
Is there a way to return the name of a function (a string) from a pointer to that function? Function pointer example from D Reference: --- int function() fp; void test() { static int a = 7; static int foo() { return a + 3; } fp = &foo; } void bar() { test(); int i = fp();

Re: Template Parameter Deduction

2015-03-12 Thread Paul D Anderson via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 23:04:15 UTC, Ali Çehreli wrote: On 03/11/2015 03:44 PM, Paul D Anderson wrote: This used to work in D2.065: given 1) public T mul(T)(in T x, in T y, Context context = T.context) if (isDecimal!T) // one template parameter for the two input values and 2

Re: Template Parameter Deduction

2015-03-11 Thread Paul D Anderson via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 22:44:12 UTC, Paul D Anderson wrote: This used to work in D2.065: given 1) public T mul(T)(in T x, in T y, Context context = T.context) if (isDecimal!T) // one template parameter for the two input values and 2) public T mul(T, U)(in T x, U n, Context

Template Parameter Deduction

2015-03-11 Thread Paul D Anderson via Digitalmars-d-learn
This used to work in D2.065: given 1) public T mul(T)(in T x, in T y, Context context = T.context) if (isDecimal!T) // one template parameter for the two input values and 2) public T mul(T, U)(in T x, U n, Context context = T.context) if (isDecimal!T && isIntegral!U) // two dif

Re: new error message in 2.066, type bool (const)

2014-08-21 Thread Paul D Anderson via Digitalmars-d-learn
On Friday, 22 August 2014 at 01:25:05 UTC, Paul D Anderson wrote: On Wednesday, 20 August 2014 at 20:46:20 UTC, Paul D Anderson I don't know if this is expected behavior that just wasn't enforced before, or if this is something new. Either way I don't like it. And I'm a

Re: new error message in 2.066, type bool (const)

2014-08-21 Thread Paul D Anderson via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 20:46:20 UTC, Paul D Anderson wrote: Re-compiling existing code with version 2.066 generates a lot of errors complaining about implicit conversion to const. Typical is this call (inside a struct with properties 1 & 2): z.sign = x.sign ^ y.sign; E

Re: new error message in 2.066, type bool (const)

2014-08-20 Thread Paul D Anderson via Digitalmars-d-learn
What changed? It ran okay with early beta versions, but not with the release. Paul It compiles in beta-5 but not beta-6. Is the list of changes in the beta testing wiki complete? None seem pertinent. monarch_dodra: Thanks for checking. I was trying to avoid tearing everything down. I was

new error message in 2.066, type bool (const)

2014-08-20 Thread Paul D Anderson via Digitalmars-d-learn
Re-compiling existing code with version 2.066 generates a lot of errors complaining about implicit conversion to const. Typical is this call (inside a struct with properties 1 & 2): z.sign = x.sign ^ y.sign; Error: None of the overloads of 'sign' are callable using argument types bool

Re: Templates and function parametes

2014-08-09 Thread Paul D Anderson via Digitalmars-d-learn
On Saturday, 9 August 2014 at 07:07:42 UTC, Rikki Cattermole wrote: Cannot reproduce on either 2.065 or git head (according to dpaste). You are right. I had the functions in a unittest block that got executed more than once so the second execution was a redefinition. Thanks for taking the

Templates and function parametes

2014-08-08 Thread Paul D Anderson via Digitalmars-d-learn
When I try to compile these two functions, the second function is flagged with an already defined error: bool testRoundTrip(T, U)(T first, U second) if (isIntegral!T && isFloatingPoint!U) { return false; } bool testRoundTrip(U, T)(U first, T second) if (isIntegral!T && isFloatingPoint!U)

Re: template mixins for boilerplate

2014-06-21 Thread Paul D Anderson via Digitalmars-d-learn
On Saturday, 21 June 2014 at 11:12:18 UTC, Artur Skawina via Digitalmars-d-learn wrote: On 06/21/14 05:32, Paul D Anderson via Digitalmars-d-learn wrote: I can't use a template mixin: mixin template Function(string name) { const char[] Function = "public static in

enum functions

2014-06-20 Thread Paul D Anderson via Digitalmars-d-learn
Does enum have any effect on functions? Is this: mixin (Constant!("ln2")); package enum T ln2(T)(Context context) { return log(T.TWO, context, false); } different from this: mixin (Constant!("ln2")); package /*enum*/ T ln2(T)(Context context) { return log(T.TWO, context, false)

template mixins for boilerplate

2014-06-20 Thread Paul D Anderson via Digitalmars-d-learn
I am misunderstanding something about using mixins for boilerplate code. I've got a set of functions all of which do the same thing: public static int fctn1() { return other.place.fctn1; } I can't use a string mixin to generate the code: template Function(string name) { const char[] Functio

Re: Casting Structs

2014-05-31 Thread Paul D Anderson via Digitalmars-d-learn
On Saturday, 31 May 2014 at 22:34:45 UTC, Timon Gehr wrote: On 06/01/2014 12:25 AM, Ali Çehreli wrote: dec10 little = cast(dec10(bingo)); You meant cast(dec10)(bingo). assert(little == dec10("123.45")); Is this expected behavior? Paul That is surprising. I've discovered that if the tem

Re: enums

2014-05-31 Thread Paul D Anderson via Digitalmars-d-learn
On Saturday, 31 May 2014 at 20:14:59 UTC, bearophile wrote: Miles Stoudenmire: In contrast to those two examples where immutable can be used at compile time, what are some other cases where it is necessary to use enum instead of immutable? By default use enum if you define a compile-time-kno

Casting Structs

2014-05-31 Thread Paul D Anderson via Digitalmars-d-learn
I'm working on the decimal number package for D. A decimal is a struct with precision, max exponent and rounding mode parameters: "Decimal!(PRECISION, MAX_EXPO, ROUNDING)". I was trying to overload the opCast operator for this struct and I found that it does not seem necessary. I can cast decim

Silent compile error

2013-05-08 Thread Paul D. Anderson
Changed compilers from dmd 2.060 to dmd 2.062, running on Windows 7. Got a couple of errors relating to imports that I fixed but now it crashes with no indication of what went wrong. A Windows message dialog pops up stating that dmd.exe has stopped working. The "details" are posted below. The

Re: bigint <-> python long

2012-09-05 Thread Paul D. Anderson
On Wednesday, 5 September 2012 at 19:23:11 UTC, Paul D. Anderson wrote: No, I don't believe so. AFAIK there is no public access to the underlying array, but I think it is a good idea. I meant to say I think that access to the array is a good idea, not the lack of access. Words are hard!

Re: How to have strongly typed numerical values?

2012-09-05 Thread Paul D. Anderson
On Wednesday, 5 September 2012 at 11:50:12 UTC, bearophile wrote: Don Clugston: I'd be interested to know if that idea is ever used in real code. I mean, it's a classic trendy template toy, but does anyone actually use it? As usual I don't have usage statistics. I like dynamic languages, li

Re: bigint <-> python long

2012-09-05 Thread Paul D. Anderson
On Wednesday, 5 September 2012 at 18:13:40 UTC, Ellery Newcomer wrote: Hey. Investigating the possibility of providing this conversion in pyd. Python provides an api for accessing the underlying bytes. std.bigint seemingly doesn't. Am I missing anything? No, I don't believe so. AFAIK there

Newbie Introduction (was Re: arrays and foreach)

2012-04-18 Thread Paul D. Anderson
SomeDude: Your outline and especially your emphasis on what a rank beginner needs to know is very good. Would you consider writing it up yourself? Not the whole thing, maybe but the beginner info and the compiler/linker appendices. You have a commendable prose style. There are tutorials avai

Re: FormatSpec struct

2012-04-13 Thread Paul D. Anderson
On Friday, 13 April 2012 at 09:10:37 UTC, James Miller wrote: So I made the pull request, the documentation you need to read is here: https://github.com/Aatch/phobos/commit/cda3c079ee32d98a017f88949c10097840baa075 Hopefully it helps. -- James Miller Thanks. That did the trick. Paul

FormatSpec struct

2012-04-12 Thread Paul D. Anderson
I'm trying to add formatted output to my decimal arithmetic module. Decimals should format like floating point, using 'E', 'F' and 'G', etc. I would expect a format string like "%9.6e" to parse as width = 9, precision = 6, using exponential notation. In std.format there is a FormatSpec struc

prettyprinter

2011-12-16 Thread Paul D. Anderson
Does anyone know of a prettyprint program for D code? I use a text editor rather than an IDE and it would be nice if I could standardize the format of my code. It's not onerous to do it by hand but it can be tedious. My text editor (Boxer) does pretty well on syntax highlighting (other than

Re: initializing immutable structs

2010-03-29 Thread Paul D. Anderson
ormance tradeoff is. Again, thanks Paul Simen kjaeraas Wrote: > On Fri, 26 Mar 2010 06:35:29 +0100, Paul D. Anderson > wrote: > > > I want to initialize an immutable struct but I'm encountering two > > difficulties and I can't find the answer in the documentat

initializing immutable structs

2010-03-25 Thread Paul D. Anderson
I want to initialize an immutable struct but I'm encountering two difficulties and I can't find the answer in the documentation. (Wouldn't it be nice if someone wrote a book?) The primary difficulty is that I can't use a static initializer but need to use a constructor instead. But the construc

Re: Confused about const

2010-03-20 Thread Paul D. Anderson
bearophile Wrote: > Paul D. Anderson: > > > After further review, I now realize that the right way (for me) to do this > > is to add a .dup property.< > > Steven Schveighoffer has given you quite good answers. > A dup is generally not enough, because what yo

Re: Confused about const

2010-03-20 Thread Paul D. Anderson
t S s) { S other = s.dup; return other; } which is ultimately an equivalent operation. Thanks again, everyone for taking the time to explain what was going on. Paul It just looks better to me. Paul D. Anderson Wrote: > bearophile Wrote: > > > The idea now is to find a way to

Re: Confused about const

2010-03-20 Thread Paul D. Anderson
bearophile Wrote: > Paul D. Anderson: > > My struct has a dynamic array as a member -- that seems to be the problem. > > This code doesn't compile: > > > > struct S { > > int x; > > int[] a; > > } > > > > S foo(const S b) {

Re: Confused about const

2010-03-20 Thread Paul D. Anderson
bearophile Wrote: > Paul D. Anderson: > > S x = cast(S) a; > > S y = cast(S) b; > > In Java (especially old Java) casts may be common, but in D they are > something that has to be used with care, don't cast away things carelessly :-) > > Bye, > b

Re: Confused about const

2010-03-20 Thread Paul D. Anderson
bearophile Wrote: > Paul D. Anderson: > > > I created a struct, call it "S", and some functions that operate on S. But > > I'm confused about when const is useful. > > > > Being an old Java programmer, I use 'const' the same as I used

Confused about const

2010-03-20 Thread Paul D. Anderson
I created a struct, call it "S", and some functions that operate on S. But I'm confused about when const is useful. Being an old Java programmer, I use 'const' the same as I used 'final' in Java. So most of my functions look like this: S for(const S a, const S b) { S x = a; S y = b;

Re: How to implement a copy

2010-03-18 Thread Paul D. Anderson
bearophile Wrote: > Paul D. Anderson: > > Or is this a distinction without a difference? > > For POD structs like this one I suggest to implement nothing, and just let > the compiler copy the struct by itself. > If the struct is not a POD then I like the dup property

How to implement a copy

2010-03-18 Thread Paul D. Anderson
If I'm implementing a struct and want to provide for duplication, is there a standard way to implement this? Here's an example: //--- struct S { // members of the struct -- three integer values int a; int b; int c; // here's a copy constructor

Re: max function

2009-06-19 Thread Paul D. Anderson
Jarrett Billingsley Wrote: > On Fri, Jun 19, 2009 at 5:05 PM, Paul D. > Anderson wrote: > > Okay, where is the max(a,b) function in phobos? > > > > I realize it's a dead simple template implementation but I thought it would > > be implemented somewhere. >

max function

2009-06-19 Thread Paul D. Anderson
Okay, where is the max(a,b) function in phobos? I realize it's a dead simple template implementation but I thought it would be implemented somewhere. Paul

Re: Expanded source code

2009-06-19 Thread Paul D. Anderson
Ary Borenszweig Wrote: > Paul D. Anderson wrote: > > Paul D. Anderson Wrote: > > > >> Is there a way to see the source for a D program after the mixins and > >> templates, etc., are expanded? > >> > >> I get occasional error messages saying

Re: Expanded source code

2009-06-18 Thread Paul D. Anderson
Paul D. Anderson Wrote: > Is there a way to see the source for a D program after the mixins and > templates, etc., are expanded? > > I get occasional error messages saying I've got incompatible types, for > example, but the error message only makes sense when I me

Expanded source code

2009-06-17 Thread Paul D. Anderson
Is there a way to see the source for a D program after the mixins and templates, etc., are expanded? I get occasional error messages saying I've got incompatible types, for example, but the error message only makes sense when I mentally instantiate a template. Is there a way to see this instant

Re: *this

2009-04-24 Thread Paul D. Anderson
Don Wrote: > Paul D. Anderson wrote: > > Looking at Don Clugston's BigInt code I see usage of "*this": > > > > BigInt opMulAssign(T: BigInt)(T y) { > >*this = mulInternal(*this, y); > > return *this; > > } > > &g

*this

2009-04-24 Thread Paul D. Anderson
Looking at Don Clugston's BigInt code I see usage of "*this": BigInt opMulAssign(T: BigInt)(T y) { *this = mulInternal(*this, y); return *this; } I think I know what it does (passes this by reference) but I can't find any documentation that explains the usage. Can anyone poi