Re: CTFE write message to console

2024-04-05 Thread Carl Sturtivant via Digitalmars-d-learn
On Friday, 5 April 2024 at 07:37:20 UTC, Paolo Invernizzi wrote: pragma(msg, x) ? No. `__ctfeWrite(x)` is executed inside an executing function like any other statement in it, and can have an argument `x` computed during that execution. It is defined to output the computed text `x` to

Re: CTFE write message to console

2024-04-04 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 4 April 2024 at 15:47:53 UTC, Richard (Rikki) Andrew Cattermole wrote: Oh hey! https://github.com/dlang/dmd/pull/16250 It was implemented literally 2 weeks ago! Nightly should have it https://github.com/dlang/dmd/releases/tag/nightly Wow! Happy that's in. It was a bit

Re: CTFE write message to console

2024-04-04 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 4 April 2024 at 15:07:21 UTC, Richard (Rikki) Andrew Cattermole wrote: Ah yes, I forgot about that particular thing, doesn't see much use as far as I'm aware. It should be working though. ```D enum X = computeX("A message"); string computeX(string msg) { auto s = "CTFE

Re: CTFE write message to console

2024-04-04 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 4 April 2024 at 14:06:19 UTC, Richard (Rikki) Andrew Cattermole wrote: ```d static assert(0, "message"); ``` Or if it is known to be CTFE'd ```d assert(0, "message"); ``` Just a warning, its a one time use only for both. No other way to do it. That's ... unfortunate. Some

Re: std.traits.ParameterIdentifierTuple problem

2024-04-02 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 1 April 2024 at 18:28:16 UTC, Nick Treleaven wrote: On Sunday, 31 March 2024 at 23:05:44 UTC, Carl Sturtivant wrote: Yes, it's not possible to instantiate a function type. But with extern it seems the semantics is fine as a function is not being instantiated. It is merely

Re: std.traits.ParameterIdentifierTuple problem

2024-03-31 Thread Carl Sturtivant via Digitalmars-d-learn
On Sunday, 31 March 2024 at 11:35:39 UTC, Nick Treleaven wrote: If a function type does include identifiers, then would two function types with the same argument types but different identifiers compare equal using `is`? Yes. That is the idea. Define `is` to work this way. Yes, it's not

Re: std.traits.ParameterIdentifierTuple problem

2024-03-30 Thread Carl Sturtivant via Digitalmars-d-learn
On Saturday, 30 March 2024 at 22:37:53 UTC, Carl Sturtivant wrote: Incidentally, I tried ```D extern typeof(foo) func; ``` to say that func was an actual function (`extern` so defined elsewhere) whose type was the type of the function `int foo(int num, string name, int);` so I can then use

Re: std.traits.ParameterIdentifierTuple problem

2024-03-30 Thread Carl Sturtivant via Digitalmars-d-learn
On Saturday, 30 March 2024 at 21:07:35 UTC, Nick Treleaven wrote: Although `.stringof` on a function type does include the parameter names, the names are not really part of the type - see: https://github.com/dlang/phobos/pull/3620#issuecomment-288469685 Perhaps `ParameterIdentifierTuple`

Re: std.traits.ParameterIdentifierTuple problem

2024-03-30 Thread Carl Sturtivant via Digitalmars-d-learn
On Saturday, 30 March 2024 at 21:51:34 UTC, Nick Treleaven wrote: On Saturday, 30 March 2024 at 21:45:34 UTC, Nick Treleaven wrote: On Saturday, 30 March 2024 at 21:25:45 UTC, Carl Sturtivant wrote: OK, so how can I get them? Am I forced to take that string and parse it with CTFE? Lookup

Re: std.traits.ParameterIdentifierTuple problem

2024-03-30 Thread Carl Sturtivant via Digitalmars-d-learn
On Saturday, 30 March 2024 at 21:07:35 UTC, Nick Treleaven wrote: On Saturday, 30 March 2024 at 19:23:07 UTC, Carl Sturtivant wrote: $ dmd -c bug1.d int(int num, string name, int) ["", "", ""] bug1.d(9): Error: static assert: "wrong!" ``

std.traits.ParameterIdentifierTuple problem

2024-03-30 Thread Carl Sturtivant via Digitalmars-d-learn
Using the [ParameterIdentifierTuple](https://dlang.org/phobos/std_traits.html#ParameterIdentifierTuple) example just there, with one more step stops working. Details: ```D import std.traits; int foo(int num, string name, int); static assert([ParameterIdentifierTuple!foo] == ["num", "name",

Re: Hidden members of Class objects

2024-03-26 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 7 March 2024 at 00:38:30 UTC, Richard (Rikki) Andrew Cattermole wrote: Yes its opt-in. https://dlang.org/spec/statement.html#synchronized-statement As you mentioned in another thread there's handy ABI documentation for classes and interfaces just here

Re: DFLAGS and DMD Windows

2024-03-21 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 21 March 2024 at 18:17:00 UTC, Carl Sturtivant wrote: On Wednesday, 20 March 2024 at 22:53:13 UTC, Carl Sturtivant wrote: Is it me, or does the [DFLAGS environment variable](https://dlang.org/dmd-windows.html#environment) have no effect on DMD. ``` dmd --version DMD64 D Compiler

Re: ImportC GUID compilation problem with some Windows headers

2024-03-21 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 21 March 2024 at 22:33:17 UTC, Dave P. wrote: I filed a bug for this: https://issues.dlang.org/show_bug.cgi?id=24447 I haven’t tried on a windows box and this is just from me grepping through header files, but maybe try to `#define EXTERN_C` as nothing in the meantime? I'll

Re: DFLAGS and DMD Windows

2024-03-21 Thread Carl Sturtivant via Digitalmars-d-learn
On Wednesday, 20 March 2024 at 22:53:13 UTC, Carl Sturtivant wrote: Is it me, or does the [DFLAGS environment variable](https://dlang.org/dmd-windows.html#environment) have no effect on DMD. ``` dmd --version DMD64 D Compiler v2.107.0 ``` Anyone?

Re: ImportC GUID compilation problem with some Windows headers

2024-03-21 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 21 March 2024 at 00:06:56 UTC, Carl Sturtivant wrote: ```C EXTERN_GUID(IID_IBlahBlahBlah, 0xabcdef12, 0x11d2, 0xab3a, 0xc0, 0x4f, [...] ); ``` Has anyone successfully compiled an EXTERN_GUID declaration like this in a Windows header with ImportC using some C macro trickery

ImportC GUID compilation problem with some Windows headers

2024-03-20 Thread Carl Sturtivant via Digitalmars-d-learn
I'm running into this COM related issue with some Windows headers, in the case when each GUID is declared in such a file as follows. ```C EXTERN_GUID(IID_IBlahBlahBlah, 0xabcdef12, 0x11d2, 0xab3a, 0xc0, 0x4f, [...] ); ``` and ImportC which is compiling `blah.c` containing only a few macro

Re: Need help with Windows linkage ( DMD using ImportC)

2024-03-20 Thread Carl Sturtivant via Digitalmars-d-learn
I found a way to make a solution for 64 bit Windows mechanically with many MSVC intrinsics, using only mingw64. Here's an [MSYS2](https://www.msys2.org/) bash script. ```bash gcc -E -P intrin.c -o vcintrinsics.c sed -i 's/extern __inline__ __attribute__((__always_inline__,__gnu_inline__))//g'

DFLAGS and DMD Windows

2024-03-20 Thread Carl Sturtivant via Digitalmars-d-learn
Is it me, or does the [DFLAGS environment variable](https://dlang.org/dmd-windows.html#environment) have no effect on DMD. ``` dmd --version DMD64 D Compiler v2.107.0 ```

Re: Need help with Windows linkage ( DMD using ImportC)

2024-03-10 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 7 March 2024 at 18:14:32 UTC, Gregor Mückl wrote: 2. C code referring to MSVC-specific compiler intrinsics. At least InterlockedExchangeAdd, InterlockedExchangeAdd64 and _stosb are such intrinsics. This is harder to resolve. There are two ways forward here: either implement a shim

Re: DMD windows and Clang's llvm-link.exe

2024-03-09 Thread Carl Sturtivant via Digitalmars-d-learn
On Sunday, 10 March 2024 at 04:22:20 UTC, Richard (Rikki) Andrew Cattermole wrote: On 10/03/2024 4:46 PM, Carl Sturtivant wrote: suggesting that there's a reason version 9 instead of 17 of lld is being used in the latest DMD installation, that may be relevant what I'd like to try. Any idea

Re: DMD windows and Clang's llvm-link.exe

2024-03-09 Thread Carl Sturtivant via Digitalmars-d-learn
On Saturday, 9 March 2024 at 22:07:05 UTC, Richard (Rikki) Andrew Cattermole wrote: lld is used and distributed with dmd and ldc. That is known to work. If you have MSVC, it'll prefer that however. Interesting, perhaps I should have known that, though I have not used DMD on Windows for many

DMD windows and Clang's llvm-link.exe

2024-03-09 Thread Carl Sturtivant via Digitalmars-d-learn
I'd like to see if I can get dmd to work correctly with Clang rather than MS tools. Can anyone share any experience they've had with this or any understanding of the situation?

Re: Need help with Windows linkage ( DMD using ImportC)

2024-03-09 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 7 March 2024 at 18:14:32 UTC, Gregor Mückl wrote: 1. Missing import libraries for Win32 API functions. Anything starting with `__imp_` is a symbol that should be provided by a DLL import library. MapViewOfFileNuma2 for example is provided by onecore.lib in the Windows SDK,

Re: Hidden members of Class objects

2024-03-06 Thread Carl Sturtivant via Digitalmars-d-learn
On Wednesday, 6 March 2024 at 23:45:00 UTC, H. S. Teoh wrote: In D, there's a pointer to the vtable and another pointer to a Monitor object (used for synchronized methods). There was talk about getting rid of the Monitor field years ago, but nothing has happened yet. Very interesting: is

Hidden members of Class objects

2024-03-06 Thread Carl Sturtivant via Digitalmars-d-learn
I notice that a class with no data members has a size of two words (at 64 bits). Presumably there's a pointer to a table of virtual functions, and one more. Is the Vtable first? A COM class that inherits from IUnknown and has no data members has a size of three words, presumably as before

Re: Need help with Windows linkage ( DMD using ImportC)

2024-03-04 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 4 March 2024 at 21:21:20 UTC, Carl Sturtivant wrote: ``` blah.obj: error LNK2019: unresolved external symbol _mul128 referenced in function MultiplyExtract128 blah.obj: error LNK2019: unresolved external symbol __shiftright128 referenced in function MultiplyExtract128 blah.obj

Re: Using ImportC to augment a big C project with D

2024-02-21 Thread Carl Sturtivant via Digitalmars-d-learn
On Tuesday, 20 February 2024 at 18:33:42 UTC, Carl Sturtivant wrote: 1. When the resulting executable runs it will have D call C which in turn calls D. In that last D (the D files replacing some C files), if I throw an exception and don't catch it in the D files that replace some C files

Re: Using ImportC to augment a big C project with D

2024-02-21 Thread Carl Sturtivant via Digitalmars-d-learn
On Wednesday, 21 February 2024 at 12:45:50 UTC, Bastiaan Veelo wrote: What do you mean by "need"? You can call https://dlang.org/phobos/core_stdc_stdlib.html#.exit from D: Of course, but does it respect D shutdown? Output: ``` onlineapp._sharedStaticDtor_L11_C1 ``` So it does run module

Using ImportC to augment a big C project with D

2024-02-20 Thread Carl Sturtivant via Digitalmars-d-learn
I just saw the announcement that macros with parameters are now translated into D by ImportC. Incredible! Congratulations to all involved. As an occasional D user, I have long wanted a fast route to using D with an existing large C project (100K lines approximately). I want to replace the C

Re: std.uni.CodepointSet from range of pairs of integers

2024-02-19 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 19 February 2024 at 04:47:07 UTC, Richard (Rikki) Andrew Cattermole wrote: On 19/02/2024 5:33 PM, Carl Sturtivant wrote: On Monday, 19 February 2024 at 01:42:03 UTC, Richard (Rikki) Andrew Cattermole wrote: Indeed, nothing in that function body would suggest it needs

Re: std.uni.CodepointSet from range of pairs of integers

2024-02-19 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 19 February 2024 at 01:42:03 UTC, Richard (Rikki) Andrew Cattermole wrote: I can understand ``pure``. https://github.com/dlang/phobos/blob/master/std/uni/package.d#L2075 It is literally on the constructor. I should have noticed this!

Re: std.uni.CodepointSet from range of pairs of integers

2024-02-18 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 19 February 2024 at 01:42:03 UTC, Richard (Rikki) Andrew Cattermole wrote: I can understand ``pure``. https://github.com/dlang/phobos/blob/master/std/uni/package.d#L2075 It is literally on the constructor. Now @safe I don't know. My best guess would be for some reason the

std.uni.CodepointSet from range of pairs of integers

2024-02-18 Thread Carl Sturtivant via Digitalmars-d-learn
I wanted to construct a CodepointSet from a string, so I used the constructor here. https://dlang.org/phobos/std_uni.html#.InversionList.this.2 I wrote a range of pairs (CodepointIntervals) of integers consisting of each codepoint in the string paired with that plus one. This did solve the

Re: std.uni CodepointSet toString

2024-02-08 Thread Carl Sturtivant via Digitalmars-d-learn
On Wednesday, 7 February 2024 at 17:11:30 UTC, H. S. Teoh wrote: Do we know why the compiler isn't getting it right? Shouldn't we be fixing it instead of just turning off elision completely? This matter seems to have been an issue for some time.

Re: std.uni CodepointSet toString

2024-02-07 Thread Carl Sturtivant via Digitalmars-d-learn
On Wednesday, 7 February 2024 at 11:49:20 UTC, Richard (Rikki) Andrew Cattermole wrote: ``` undefined reference to `_D4core9exception__T15__switch_errorTZQsFNaNbNiNeAyamZv' collect2: error: ld returned 1 exit status Error: linker exited with status 1 ``` Use ``-allinst``, that is a template

std.uni CodepointSet toString

2024-02-06 Thread Carl Sturtivant via Digitalmars-d-learn
Need help working around a linkage problem. ```d import std.uni, std.conv, std.stdio, std.format; void main() { //auto c1 = unicode.InBasic_latin; auto c1 = CodepointSet('a','z'+1); writeln(c1.to!string); writeln(format("%d", c1)); writeln(format("%#x",

Re: Scripting with Variant from std.variant: parameter passing

2024-02-03 Thread Carl Sturtivant via Digitalmars-d-learn
On Friday, 2 February 2024 at 20:58:12 UTC, Paul Backus wrote: Another variation on the same theme: ```d /// map over a variadic argument list template mapArgs(alias fun) { auto mapArgs(Args...)(auto ref Args args) { import std.typecons: tuple;

Re: Scripting with Variant from std.variant: parameter passing

2024-02-02 Thread Carl Sturtivant via Digitalmars-d-learn
On Friday, 2 February 2024 at 19:22:22 UTC, Steven Schveighoffer wrote: ```d void foo(Variant x, Variant y) { ... } import std.meta : allSatisfy; enum isVariant(T) = is(T == Variant); // this is going to suck at CTFE but... string argsAsVariants(size_t count) { import std.format; import

Scripting with Variant from std.variant: parameter passing

2024-02-02 Thread Carl Sturtivant via Digitalmars-d-learn
It seems I cannot pass e.g. an int argument to a Variant function parameter. What's the simplest way to work around this restriction?

Re: import locality with function parameters

2024-02-01 Thread Carl Sturtivant via Digitalmars-d-learn
On Friday, 2 February 2024 at 01:23:11 UTC, Steven Schveighoffer wrote: Are you thinking of this? https://dlang.org/phobos/object.html#.imported -Steve Yes! Glad it's now part of D. Thank you.

import locality with function parameters

2024-02-01 Thread Carl Sturtivant via Digitalmars-d-learn
Hello, I seem to recall that there is surprising template to import a module and get a type from it inside the declaration of the type of a parameter to a function, so that the module need not be imported outside of the function definition. I think there was a blog article some years ago

Re: compute from a string the text of a string literal

2024-01-17 Thread Carl Sturtivant via Digitalmars-d-learn
On Wednesday, 17 January 2024 at 18:53:48 UTC, Paul Backus wrote: There's a function that does this in Phobos, but it's `private`. Currently, the only way to access it is by calling `to!string` or `format` on a range that contains the string you want to convert as an element: ```d void

compute from a string the text of a string literal

2024-01-17 Thread Carl Sturtivant via Digitalmars-d-learn
Hello, I'd like a function like this, ``` string image(string s) ``` that maps any string s into the doubly quoted backslash escaped text that would be a string literal for s were it pasted into a program. Perhaps with a second parameter with detailed options. Is there something out there I

Re: Anyway to achieve the following

2021-08-15 Thread Carl Sturtivant via Digitalmars-d-learn
On Sunday, 15 August 2021 at 07:10:17 UTC, JG wrote: Hi, This is exactly the behaviour I was trying to obtain. It however comes with a fair amount of overhead, as can be seen in the following llvm ir: [...] What you are asking for are reference variables. C++ has them: the example here

Re: Anyway to achieve the following

2021-08-14 Thread Carl Sturtivant via Digitalmars-d-learn
``` struct S { int x = 1234; } void main() { import std.stdio; S s; //construction of a using &(s.x) auto a = Ref!(int)(); writeln(a); //displays 1234 s.x += 1; writeln(a); //displays 1235 a += 1; writeln(s.x); //displays 1236 } struct Ref(T) { T* ptr; this(T* p)

Re: alias restriction??!

2020-07-20 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 20 July 2020 at 17:24:56 UTC, Carl Sturtivant wrote: Well perhaps you do parse a "constant-offset expression" i.e. syntactically dotted with constant indexes, like name1.name2[constant].name3 and then later there's a semantic check that the "constant-offset expre

Re: alias restriction??!

2020-07-20 Thread Carl Sturtivant via Digitalmars-d-learn
On Sunday, 19 July 2020 at 20:46:19 UTC, Steven Schveighoffer wrote: On 7/19/20 4:21 PM, Carl Sturtivant wrote: Perhaps what's needed is something more that is less than allowing aliases for expressions in the wide sense you suggest here. I agree. Something not yet mentioned

Re: alias restriction??!

2020-07-19 Thread Carl Sturtivant via Digitalmars-d-learn
On Sunday, 19 July 2020 at 17:06:14 UTC, Paul Backus wrote: Also, letting aliases refer to expressions essentially allows AST macros in through the back door. Consider the following example: [...] Perhaps what's needed is something more that is less than allowing aliases for expressions in

Re: alias restriction??!

2020-07-19 Thread Carl Sturtivant via Digitalmars-d-learn
On Sunday, 19 July 2020 at 12:08:07 UTC, Paul Backus wrote: On Saturday, 18 July 2020 at 18:46:16 UTC, Carl Sturtivant wrote: Here's a toy version of a problem in the wild. struct S { long first; union T { long one; double two; } T second; alias First

alias restriction??!

2020-07-18 Thread Carl Sturtivant via Digitalmars-d-learn
Here's a toy version of a problem in the wild. struct S { long first; union T { long one; double two; } T second; alias First = first; alias Second = second.one; } void main() { S x; x.First = 4; x.Second = 5; // compilation error: "Error:

Re: How do I display unicode characters in D on standard (english) Windows 10 console window?

2019-07-31 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 29 July 2019 at 22:17:55 UTC, WhatMeWorry wrote: This is a very stupid question but from Ali's book, I took this segment: writeln("Résumé preparation: 10.25€"); writeln("\x52\sum\u00e9 preparation: 10.25\"); and after running it all I get is the following: R├⌐sum├⌐ preparation:

Re: opDispatch doesn't play nice with inheritance

2018-11-17 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 15 November 2018 at 19:01:45 UTC, Ali Çehreli wrote: On 11/15/2018 09:14 AM, Carl Sturtivant wrote: > opDispatch is special in that it allows for functions to be added to a > class or struct when undefined overtly but used elsewhere but it seems > those functions sadly

Re: opDispatch doesn't play nice with inheritance

2018-11-15 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 15 November 2018 at 18:04:42 UTC, Adam D. Ruppe wrote: Right, all templates are final, including opDispatch. What I've done in the past is to forward them to a virtual function with runtime arguments instead of compile time arguments. Kinda like: void opDispatch(string name)()

opDispatch doesn't play nice with inheritance

2018-11-15 Thread Carl Sturtivant via Digitalmars-d-learn
//Consider this: import std.stdio; void main() { X obj = new Y; writeln( obj._f() ); } class Proxy { X x; this(X x) { this.x = x; } string _f() { return "Proxy._f called"; } } class X { auto opDispatch(string f, Args...)(Args args) { Proxy p = new Proxy(this);

Re: custom sorting of lists ?

2018-10-19 Thread Carl Sturtivant via Digitalmars-d-learn
On Friday, 19 October 2018 at 17:53:58 UTC, Stanislav Blinov wrote: On Friday, 19 October 2018 at 17:40:59 UTC, Carl Sturtivant wrote: If we imagine an Ordered Range being a finite Range of some kind with the additional property that its values are ordered (--- exact definition needed

Re: custom sorting of lists ?

2018-10-19 Thread Carl Sturtivant via Digitalmars-d-learn
On Wednesday, 17 October 2018 at 19:02:00 UTC, Steven Schveighoffer wrote: On 10/17/18 2:03 PM, Carl Sturtivant wrote: On Monday, 15 October 2018 at 13:39:59 UTC, Steven Schveighoffer wrote: But that's just the thing -- merge sort *does* depend on the container type. It requires the ability

Re: custom sorting of lists ?

2018-10-17 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 15 October 2018 at 13:39:59 UTC, Steven Schveighoffer wrote: But that's just the thing -- merge sort *does* depend on the container type. It requires the ability to rearrange the elements structurally, since you merge the sets of items together. This requires making another list

std.process.pipeProcess stalls (linux)

2018-06-01 Thread Carl Sturtivant via Digitalmars-d-learn
A computationally intensive process run from the command line works fine, runs to completion after several minutes, writing a few hundred lines of text to standard output and creating, writing to and closing around 200 files of size around 20KB. Now run from std.process.pipeProcess and

Re: Initialization of struct containing anonymous union

2017-08-14 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 14 August 2017 at 15:11:35 UTC, Steven Schveighoffer wrote: On 8/14/17 10:57 AM, Carl Sturtivant wrote: On Monday, 14 August 2017 at 14:49:57 UTC, Steven Schveighoffer wrote: On 8/14/17 10:36 AM, Carl Sturtivant wrote: On Monday, 14 August 2017 at 14:24:40 UTC, Steven Schveighoffer

Re: Initialization of struct containing anonymous union

2017-08-14 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 14 August 2017 at 14:49:57 UTC, Steven Schveighoffer wrote: On 8/14/17 10:36 AM, Carl Sturtivant wrote: On Monday, 14 August 2017 at 14:24:40 UTC, Steven Schveighoffer wrote: I think what the docs mean is that as soon as an anonymous union is present, you can't initialize anything

Re: Initialization of struct containing anonymous union

2017-08-14 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 14 August 2017 at 14:24:40 UTC, Steven Schveighoffer wrote: I think what the docs mean is that as soon as an anonymous union is present, you can't initialize anything further than the first union field. I understood that, hence my remark that "this is not helpful". So it seems I

Initialization of struct containing anonymous union

2017-08-14 Thread Carl Sturtivant via Digitalmars-d-learn
struct mess { union { int i; string s; } double x; } How do I cleanly initialize this, assuming it's i that I want to give an overt value to? The docs say "If there are anonymous unions in the struct, only the first member of the anonymous union can be

Re: subtlety or bug?

2017-05-10 Thread Carl Sturtivant via Digitalmars-d-learn
Aha, https://dlang.org/spec/struct.html#struct-destructor says that An identity assignment overload is required for a struct if one or more of these conditions hold: * it has a destructor so this is the above condition coming into play.

subtlety or bug?

2017-05-10 Thread Carl Sturtivant via Digitalmars-d-learn
The following compiles and runs correctly. https://forum.dlang.org/post/tzwsohkcqrkqotbwn...@forum.dlang.org But if I add a destructor to the reference struct template as follows, it no longer compiles, and the complaints are not about the destructor. ``` ~this() { ptr = null;

Re: alias can't find symbol or can't use symbol

2017-05-06 Thread Carl Sturtivant via Digitalmars-d-learn
On Wednesday, 3 May 2017 at 09:04:07 UTC, Jonathan M Davis wrote: I believe that the core problem is that an alias declaration just aliases a symbol - i.e. it just creates a new name for the symbol. And as far as I can tell, alias n2 = x2.n; is actually equivalent to alias n2 = member.n;

Re: alias can't find symbol or can't use symbol

2017-05-04 Thread Carl Sturtivant via Digitalmars-d-learn
On Wednesday, 3 May 2017 at 09:04:07 UTC, Jonathan M Davis wrote: I believe that the core problem is that an alias declaration just aliases a symbol - i.e. it just creates a new name for the symbol. And as far as I can tell, alias n2 = x2.n; is actually equivalent to alias n2 = member.n;

Re: alias can't find symbol or can't use symbol

2017-04-30 Thread Carl Sturtivant via Digitalmars-d-learn
On Sunday, 30 April 2017 at 02:19:29 UTC, bauss wrote: What exactly did you expect here? 'n' is not in the scope of 'outer'. 'n' is in the scope of 'member'. Of course it works with 'x.n' since 'x' points to the 'member' declared inside 'outer'. I mean it would have worked with classes,

alias can't find symbol or can't use symbol

2017-04-29 Thread Carl Sturtivant via Digitalmars-d-learn
Consider the following. struct member { int n; } struct outer { member x; alias x this; alias n2 = n; } This does not compile: alias n2 = n; Error: undefined identifier 'n' On the other hand if change that into alias n2 = x.n; then it does compile. void main() { outer

Re: std.digest toHexString

2017-03-16 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 16 March 2017 at 18:51:45 UTC, Adam D. Ruppe wrote: Phobos could have been written to avoid this problem too, there's a few solutions that work, but right now, using the standard library in a way people expect to work will be silently disastrous. Yes, and as an outsider I find

Re: std.digest toHexString

2017-03-16 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 16 March 2017 at 17:20:45 UTC, H. S. Teoh wrote: I'm not convinced casting static array to immutable is OK. Check this out: import std.stdio; char[32] func() { char[32] staticArr = "A123456789abcdefB123456789abcdef"; return staticArr; //

Re: std.digest toHexString

2017-03-16 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 16 March 2017 at 17:18:30 UTC, Adam D. Ruppe wrote: On Thursday, 16 March 2017 at 17:12:08 UTC, Carl Sturtivant wrote: I did that, and it made no difference. :( wait a minute i just realized: toHexString.d(11) in the error message You named the file toHexString which means

Re: std.digest toHexString

2017-03-16 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 16 March 2017 at 16:59:40 UTC, Adam D. Ruppe wrote: Yet the documentation says there's a toHexString that returns a string. Yes, indeed, it returns a string if it is passed a dynamic array. Ah, that's the distinction, should have noticed. Remember though, like I warned on my

Re: std.digest toHexString

2017-03-16 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 16 March 2017 at 17:01:56 UTC, Adam D. Ruppe wrote: On Thursday, 16 March 2017 at 16:56:11 UTC, Carl Sturtivant wrote: "toHexString.d(11): Error: function expected before (), not module toHexString of type void" Module??? huh idk. use my search engine btw! http://dp

Re: std.digest toHexString

2017-03-16 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 16 March 2017 at 16:21:08 UTC, Adam D. Ruppe wrote: If I replace md5Of(arg).toHexString() with toHexString(md5Of(arg)) That works for me though... maybe it is just a version mismatch or something, since toHexString is in a different module than md5of. I have this problem

Re: std.digest toHexString

2017-03-16 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 16 March 2017 at 16:21:08 UTC, Adam D. Ruppe wrote: On Thursday, 16 March 2017 at 16:13:33 UTC, Carl Sturtivant wrote: string ans = md5Of(arg).toHexString(); That is a major D design flaw biting you the same way it has bitten so many others. See the red box in my

std.digest toHexString

2017-03-16 Thread Carl Sturtivant via Digitalmars-d-learn
What's going on here? ``` import std.digest.md, std.stdio; void main() { string ans = hex("qwertyuiop"); writeln(ans); } string hex(string arg) { string ans = md5Of(arg).toHexString(); writeln(ans); return ans; } ``` This compiles, and when run writes out corrupt nonsense

Part of D available to run at compile time

2016-03-29 Thread Carl Sturtivant via Digitalmars-d-learn
is there documentation on which parts of D are available to compile time execution?

Re: link to C function whose name is a D keyword

2016-01-06 Thread Carl Sturtivant via Digitalmars-d-learn
On Wednesday, 6 January 2016 at 15:42:34 UTC, Adam D. Ruppe wrote: On Wednesday, 6 January 2016 at 15:41:27 UTC, Carl Sturtivant wrote: //D that doesn't work: extern(C) int try(int x); Try: pragma(mangle, "try") extern(C) int try_(int x); then call it with the udnerscore in D,

link to C function whose name is a D keyword

2016-01-06 Thread Carl Sturtivant via Digitalmars-d-learn
Hello, Is there a way from D to do this, without writing a C wrapper? e.g. I want to call a C function named 'try'. /* C prototype */ int try(int x); //D that doesn't work: extern(C) int try(int x);

link to C++ function in a namespace whose name is a D keyword

2016-01-06 Thread Carl Sturtivant via Digitalmars-d-learn
Hello, From D I want to call e.g. /* C++ prototype */ namespace ns { int try(int x); } without writing a C or C++ wrapper. Presumably the following D doesn't work, because it doesn't mangle the name as if it's in the namespace ns. pragma(mangle, "try") extern(C++, ns) int try_(int x);

Re: DFLAGS ignored. How to get a dmd installation on windows that is 64 bit only

2015-11-22 Thread Carl Sturtivant via Digitalmars-d-learn
If you must force dmd to be only 64bit, use sc.ini file to do so and not rely on your environment variables. OK, why? (This does work, so thank you.) Also why do you not want 32-bit support? It's not like it won't work on a 64bit computer, it will. I've used 32-bit D and DMC a lot on real

DFLAGS ignored. How to get a dmd installation on windows that is 64 bit only

2015-11-21 Thread Carl Sturtivant via Digitalmars-d-learn
The docs for dmd for windows say that the DFLAGS environment variable's value will be appended to the dmd command line. I tried this with -m64 as the value and this is ignored. http://dlang.org/dmd-windows.html#environment More generally, is there a standard rearrangement of files and

cast(T) documentation

2015-11-05 Thread Carl Sturtivant via Digitalmars-d-learn
Hello, Is cast(T) documented all in one place somewhere? I'd like to understand exactly what it does and does not do.

Re: cast(T) documentation

2015-11-05 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 5 November 2015 at 18:52:05 UTC, Ali Çehreli wrote: On 11/05/2015 07:51 AM, Carl Sturtivant wrote: Hello, Is cast(T) documented all in one place somewhere? I'd like to understand exactly what it does and does not do. This is what I can find: http://dlang.org

trouble compiling Fiber example code from docs dmd linux v2.067.1

2015-08-06 Thread Carl Sturtivant via Digitalmars-d-learn
I took the example code from here, http://dlang.org/phobos/core_thread.html#.Fiber and wrapped the statements at the bottom inside main() and put import core.thread and std.stdio at the top, and the compiler gave me the following. /usr/include/dmd/druntime/import/core/thread.d(3894): Error:

Re: Seems core.thread.Fiber is broken dmd windows 64-bit build

2015-03-09 Thread Carl Sturtivant via Digitalmars-d-learn
Please confirm or deny that this is a real bug, as its getting in the way of a genuine project. How should I proceed? I'm working on a 64-bit Windows port of the following. http://www.cs.arizona.edu/icon/ Here's the 32-bit Windows port. http://www.cs.arizona.edu/icon/v95w.htm Among other

Re: Seems core.thread.Fiber is broken dmd windows 64-bit build

2015-03-09 Thread Carl Sturtivant via Digitalmars-d-learn
I can reproduce this issue with dmd 2.066.1, please go forward and open a issue on https://issues.dlang.org/ Kind Regards Benjamin Thaut Thank you; will do.

Re: Seems core.thread.Fiber is broken dmd windows 64-bit build

2015-03-09 Thread Carl Sturtivant via Digitalmars-d-learn
http://forum.dlang.org/thread/md5kq0$8au$1...@digitalmars.com Got a working build at 64 bits using the 2.067 beta 3. Delighted.

Re: Seems core.thread.Fiber is broken dmd windows 64-bit build

2015-03-09 Thread Carl Sturtivant via Digitalmars-d-learn
IIRC there are some fixes to the Win64 context switching code in the 2.067 or master druntime. You might want to try those first before spending more time tracking this down. Great, and thanks.

Re: Seems core.thread.Fiber is broken dmd windows 64-bit build

2015-03-09 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 9 March 2015 at 17:00:38 UTC, Jacques Müller wrote: With the newest beta everything seems to work fine. http://forum.dlang.org/thread/md5kq0$8au$1...@digitalmars.com That's great news! Thank you.

Re: core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-15 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 14 August 2014 at 18:52:00 UTC, Sean Kelly wrote: On 64 bit, reserve a huge chunk of memory, set a SEGV handler and commit more as needed. Basically how kernel thread stacks work. I've been meaning to do this but haven't gotten around to it yet. Very nice; the hardware VM

Re: core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-15 Thread Carl Sturtivant via Digitalmars-d-learn
On Friday, 15 August 2014 at 08:41:30 UTC, Kagamin wrote: On Thursday, 14 August 2014 at 07:46:29 UTC, Carl Sturtivant wrote: The default size of the runtime stack for a Fiber is 4*PAGESIZE which is very small, and a quick test shows that a Fiber suffers a stack overflow that doesn't lead

Re: core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-15 Thread Carl Sturtivant via Digitalmars-d-learn
On Friday, 15 August 2014 at 20:11:43 UTC, Carl Sturtivant wrote: On Friday, 15 August 2014 at 08:41:30 UTC, Kagamin wrote: On Thursday, 14 August 2014 at 07:46:29 UTC, Carl Sturtivant wrote: The default size of the runtime stack for a Fiber is 4*PAGESIZE which is very small, and a quick test

Re: core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-15 Thread Carl Sturtivant via Digitalmars-d-learn
On Friday, 15 August 2014 at 15:40:35 UTC, Sean Kelly wrote: On Friday, 15 August 2014 at 15:25:23 UTC, Dicebot wrote: No, I was referring to the proposal to supply bigger stack size to Fiber constructor - AFAIR it currently does allocate that memory eagerly (and does not use any OS CoW

core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-14 Thread Carl Sturtivant via Digitalmars-d-learn
The default size of the runtime stack for a Fiber is 4*PAGESIZE which is very small, and a quick test shows that a Fiber suffers a stack overflow that doesn't lead to a clean termination when this limit is exceeded. This makes it difficult to simulate deterministic alternation where the

Re: Linux Dynamic Loading of shared libraries

2014-07-29 Thread Carl Sturtivant via Digitalmars-d-learn
Can't retrieve the archive from that URL. britseyeview.com/plugin101.tar.bz2 Interested, so can you please fix? On Monday, 10 March 2014 at 11:59:20 UTC, Steve Teale wrote: On Sunday, 9 March 2014 at 12:07:22 UTC, Steve Teale wrote: Now suppose that my D shared library contains a class, rather

Re: D may disappoint in the presence of an alien Garbage Collector?

2014-07-29 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 28 July 2014 at 21:33:54 UTC, Rene Zwanenburg wrote: If I understand you correctly, an easy way is to use RefCounted with a simple wrapper. Something like this: // Descriptor defined by the external library struct DescriptorImpl { size_t type; void* data; } // Tiny wrapper

Re: D may disappoint in the presence of an alien Garbage Collector?

2014-07-29 Thread Carl Sturtivant via Digitalmars-d-learn
On Monday, 28 July 2014 at 20:52:01 UTC, Anton wrote: On Monday, 28 July 2014 at 19:57:38 UTC, Carl Sturtivant wrote: Suppose I want to use D as a system programming language to work with a library of functions written in another language, operating on dynamically typed data that has its own

D may disappoint in the presence of an alien Garbage Collector?

2014-07-28 Thread Carl Sturtivant via Digitalmars-d-learn
Suppose I want to use D as a system programming language to work with a library of functions written in another language, operating on dynamically typed data that has its own garbage collector, such as an algebra system or the virtual machine of a dynamically typed scripting language viewed as

  1   2   >