Re: module search paths

2021-08-03 Thread Ali Çehreli via Digitalmars-d-learn
On 8/3/21 9:51 PM, Brian Tiffin wrote: > I added an `import std.json;`. That did not include the > JSONType enum. It works for me: import std.json; int main() { return JSONType.null_; } > Is there a go to quick and easy way of tracking down > module members? Searching for it at dlang.org

module search paths

2021-08-03 Thread Brian Tiffin via Digitalmars-d-learn
Just tried the JSON sample from the home page. It's not an all in listing, so I added an `import std.json;`. That did not include the JSONType enum. A little more looking around, a more complete listing, added ``` import std.array; import std.conv; import std.range.primitives; import

Re: Name Mangling & its representation of D types

2021-08-03 Thread Mathias LANG via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 20:29:10 UTC, NonNull wrote: On Tuesday, 3 August 2021 at 17:01:38 UTC, Mike Parker wrote: On Tuesday, 3 August 2021 at 16:43:52 UTC, NonNull wrote: how does it work for recursive types like a struct containing a pointer to a struct of the same type A struct `S`

Re: alias using Complex!Double in module ... linker error??

2021-08-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 21:40:09 UTC, james.p.leblanc wrote: I am getting linker errors with this stripped-down example: --- **my_main.d:** import std.stdio; import std.complex; import my_module; void main(){ my_TYPE xxx;

alias using Complex!Double in module ... linker error??

2021-08-03 Thread james.p.leblanc via Digitalmars-d-learn
I am getting linker errors with this stripped-down example: --- **my_main.d:** import std.stdio; import std.complex; import my_module; void main(){ my_TYPE xxx; writeln(xxx); } ---

Re: Name Mangling & its representation of D types

2021-08-03 Thread NonNull via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 17:14:42 UTC, Ali Çehreli wrote: On 8/3/21 9:43 AM, NonNull wrote: I'd like to understand how any D type is represented as a string by the name mangling done by the compilers. Related article that mentions .mangleof, a property of all symbols:

Re: Name Mangling & its representation of D types

2021-08-03 Thread NonNull via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 17:01:38 UTC, Mike Parker wrote: On Tuesday, 3 August 2021 at 16:43:52 UTC, NonNull wrote: how does it work for recursive types like a struct containing a pointer to a struct of the same type A struct `S` with a member of type `S*` is still just a struct `S`. The

Re: Find struct not passed by reference

2021-08-03 Thread Ali Çehreli via Digitalmars-d-learn
On 8/3/21 12:22 PM, frame wrote: On Tuesday, 3 August 2021 at 19:19:27 UTC, jfondren wrote: On Tuesday, 3 August 2021 at 19:11:16 UTC, frame wrote: On Tuesday, 3 August 2021 at 16:35:04 UTC, Ali Çehreli wrote: Why foreach() does not accept a pointer? pointers don't come with a length?

Re: Find struct not passed by reference

2021-08-03 Thread frame via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 19:19:27 UTC, jfondren wrote: On Tuesday, 3 August 2021 at 19:11:16 UTC, frame wrote: On Tuesday, 3 August 2021 at 16:35:04 UTC, Ali Çehreli wrote: Why foreach() does not accept a pointer? pointers don't come with a length? Where is the problem if it points to

Re: Find struct not passed by reference

2021-08-03 Thread jfondren via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 19:11:16 UTC, frame wrote: On Tuesday, 3 August 2021 at 16:35:04 UTC, Ali Çehreli wrote: Why foreach() does not accept a pointer? pointers don't come with a length?

Re: Find struct not passed by reference

2021-08-03 Thread frame via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 16:35:04 UTC, Ali Çehreli wrote: a) Classes are already reference types. So, replace struct with class: class Foo { // ... } It's already a member of an object, so I don't like it to make it a sub object. b) Make your struct a reference type by i)

Re: align dynamic array (for avx friendliness) hints? / possible??

2021-08-03 Thread james.p.leblanc via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 17:57:47 UTC, Ali Çehreli wrote: On 8/3/21 10:50 AM, james.p.leblanc wrote: > **Is there some highly visible place this is already documented? For what it's worth, it appears as "slice from pointer" in my index:

Re: align dynamic array (for avx friendliness) hints? / possible??

2021-08-03 Thread Ali Çehreli via Digitalmars-d-learn
On 8/3/21 10:50 AM, james.p.leblanc wrote: > **Is there some highly visible place this is already documented? For what it's worth, it appears as "slice from pointer" in my index: http://ddili.org/ders/d.en/pointers.html#ix_pointers.slice%20from%20pointer Admittedly, one needs to know the

Re: align dynamic array (for avx friendliness) hints? / possible??

2021-08-03 Thread james.p.leblanc via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 16:32:34 UTC, kinke wrote: On Tuesday, 3 August 2021 at 12:33:56 UTC, james.p.leblanc wrote: Concise question: = I would like to use dynamic arrays, not for their dynamic sizing properties per se' (slicing, appending, etc). But, more for their

Re: Name Mangling & its representation of D types

2021-08-03 Thread Ali Çehreli via Digitalmars-d-learn
On 8/3/21 9:43 AM, NonNull wrote: I'd like to understand how any D type is represented as a string by the name mangling done by the compilers. Related article that mentions .mangleof, a property of all symbols: https://dlang.org/blog/2017/12/20/ds-newfangled-name-mangling/ Ali

Re: Name Mangling & its representation of D types

2021-08-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 16:43:52 UTC, NonNull wrote: how does it work for recursive types like a struct containing a pointer to a struct of the same type A struct `S` with a member of type `S*` is still just a struct `S`. The pointer doesn't change anything about the type.

Re: Name Mangling & its representation of D types

2021-08-03 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 16:43:52 UTC, NonNull wrote: I'd like to understand how any D type is represented as a string by the name mangling done by the compilers. Does this always have the desirable property that different types have different mangled names, so that a type is faithfully

Name Mangling & its representation of D types

2021-08-03 Thread NonNull via Digitalmars-d-learn
I'd like to understand how any D type is represented as a string by the name mangling done by the compilers. Does this always have the desirable property that different types have different mangled names, so that a type is faithfully represented by its mangled string incorporated into a

Re: Find struct not passed by reference

2021-08-03 Thread Ali Çehreli via Digitalmars-d-learn
On 8/2/21 4:06 PM, frame wrote: Is there a way to find a struct which should be passed by reference but accidentally isn't? Maybe with copy constructors? If I understand it correctly, your current value-type needs to be a reference type. Would the following be workable solutions? a) Classes

Re: align dynamic array (for avx friendliness) hints? / possible??

2021-08-03 Thread kinke via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 12:33:56 UTC, james.p.leblanc wrote: Concise question: = I would like to use dynamic arrays, not for their dynamic sizing properties per se' (slicing, appending, etc). But, more for their memory protection and efficiencies (for example,using

Re: Find struct not passed by reference

2021-08-03 Thread frame via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 13:23:04 UTC, Tejas wrote: No. ```ref``` can only be used as a function/template. or ```foreach``` parameter. Yeah, I know. I was in hope of a DIP or something. I just would like to hijack the reference chain to do something like: ```d void fun() { ref T rs;

Re: Find struct not passed by reference

2021-08-03 Thread Tejas via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 12:23:38 UTC, frame wrote: On Tuesday, 3 August 2021 at 11:55:51 UTC, Paul Backus wrote: You can't assign a `ref` to a variable; if you try, a copy is created. What you can do instead is use a pointer: ```d Unique!myType* rs = (); ``` Thanks. I feared that. So

align dynamic array (for avx friendliness) hints? / possible??

2021-08-03 Thread james.p.leblanc via Digitalmars-d-learn
Concise question: = I would like to use dynamic arrays, not for their dynamic sizing properties per se' (slicing, appending, etc). But, more for their memory protection and efficiencies (for example,using foreach). However, I must have the start of my array at an avx friendly 32

Re: Find struct not passed by reference

2021-08-03 Thread frame via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 11:55:51 UTC, Paul Backus wrote: You can't assign a `ref` to a variable; if you try, a copy is created. What you can do instead is use a pointer: ```d Unique!myType* rs = (); ``` Thanks. I feared that. So something like ``` ref T var = ... ``` does not exist

Re: Is returning void functions inside void functions a feature or an artifact?

2021-08-03 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 10:28:53 UTC, Rekel wrote: On Tuesday, 3 August 2021 at 00:53:43 UTC, user1234 wrote: You got the answer in another reply but here is a bit of more fun: ```d void main() { return cast(void) 1; } ``` What does casting to void do? Does it just ignore whatever

Re: Find struct not passed by reference

2021-08-03 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 11:31:02 UTC, frame wrote: On Tuesday, 3 August 2021 at 10:25:34 UTC, frame wrote: This could work, thanks for the hint. I was too optimistic. I get the error: ``` struct `std.typecons.Unique!(myType).Unique` is not copyable because it is annotated with

Re: Find struct not passed by reference

2021-08-03 Thread frame via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 10:25:34 UTC, frame wrote: This could work, thanks for the hint. I was too optimistic. I get the error: ``` struct `std.typecons.Unique!(myType).Unique` is not copyable because it is annotated with `@disable` ``` on a line like: ```d Unique!myType rs =

Re: Find struct not passed by reference

2021-08-03 Thread frame via Digitalmars-d-learn
On Monday, 2 August 2021 at 23:19:48 UTC, jfondren wrote: On Monday, 2 August 2021 at 23:06:42 UTC, frame wrote: Is there a way to find a struct which should be passed by reference but accidentally isn't? Maybe with copy constructors? @disable postblit: Well, I have to change a struct to be

Re: Is returning void functions inside void functions a feature or an artifact?

2021-08-03 Thread Rekel via Digitalmars-d-learn
On Tuesday, 3 August 2021 at 00:53:43 UTC, user1234 wrote: You got the answer in another reply but here is a bit of more fun: ```d void main() { return cast(void) 1; } ``` What does casting to void do? Does it just ignore whatever follows it? On Tuesday, 3 August 2021 at 07:23:34 UTC,

Re: Is returning void functions inside void functions a feature or an artifact?

2021-08-03 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 2 August 2021 at 14:46:36 UTC, jfondren wrote: On Monday, 2 August 2021 at 14:31:45 UTC, Rekel wrote: [...] I don't know where you can find this in the docs, but what doesn't seem trivial about it? The type of the expression `print()` is void. That's the type that `doSomething`