Re: code folding

2017-03-18 Thread Basile B. via Digitalmars-d-learn
On Monday, 13 March 2017 at 17:29:41 UTC, Inquie wrote: Does D have any nice way to specify a block for cold folding? I have a very large set of structs and I'd like to be able to code fold them all at once and together. I have been using static if(true) { ... junk } but the static if is

We can't have alias of instantiated auto ref functions?

2017-03-18 Thread Yuxuan Shui via Digitalmars-d-learn
auto a(T)(auto ref T t) { return t; } void main() { alias tmp = a!int; import std.stdio; writeln(tmp(10)); } This gives this error message: test.d(1): Error: 'auto' can only be used as part of 'auto ref' for template function parameters Which is rather useless,

Re: GitHub detects .d source as Makefile?

2017-03-18 Thread XavierAP via Digitalmars-d-learn
On Saturday, 18 March 2017 at 01:33:13 UTC, David Nadlinger wrote: The code GitHub uses to infer source file languages is open-source, and – fittingly – available on GitHub: https://github.com/github/linguist You should check the issues for reports of similar D-related problems, and if ther

Re: GitHub detects .d source as Makefile?

2017-03-18 Thread XavierAP via Digitalmars-d-learn
On Saturday, 18 March 2017 at 10:52:31 UTC, XavierAP wrote: Thanks! It seems I can also override the language detection in .gitattributes, and it is now fixed :) The majority language assigned to the whole repository is fixed, but alas syntax highlighting in heatsim.d is still wrong. Looks

Re: List Comprehension equivalent

2017-03-18 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2017-03-17 at 12:29 -0700, H. S. Teoh via Digitalmars-d-learn wrote: > […] > Also, there is now a variant of reduce called `fold`, that has a > nicer > order of parameters, i.e., you can use it in UFCS chains: > > myData.map!(a => transform(a)) >   .fold!((a,b) => a + b)(0

Building custom library package with dub

2017-03-18 Thread alex1974 via Digitalmars-d-learn
I want to build a custom library with useful extensions to phobos. They should be named like: extensions.regex extensions.path extensions.files ... Some libraries, like extensions.files contain several files (e.g files.d, filesexceptions.d) Analog to phobos I would like to import them like i

Re: List Comprehension equivalent

2017-03-18 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2017-03-17 at 12:32 -0700, Ali Çehreli via Digitalmars-d-learn wrote: > On 03/17/2017 12:21 PM, John Colvin wrote: >  > On Friday, 17 March 2017 at 19:08:36 UTC, Russel Winder wrote: > >  >> Rust ownership problems >  >> seem to be a doddle compared to this problem. > > It sometimes feels

Re: List Comprehension equivalent

2017-03-18 Thread thedeemon via Digitalmars-d-learn
On Saturday, 18 March 2017 at 11:09:34 UTC, Russel Winder wrote: Is this foldr or foldl' ? It's a left fold of course, having foldr by default in eager language would be awkward.

Enums and immutables

2017-03-18 Thread Oleg B via Digitalmars-d-learn
Hello. I found strange behavior while casting enum array and immutable array. import std.stdio; void main() { enum arr = cast(ubyte[])[0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4]; auto arr1 = cast(void[])arr; immutable arr2 = cast(immutable(void)[])arr; enum arr3 = cast(void[])arr; w

Re: Building custom library package with dub

2017-03-18 Thread Basile B. via Digitalmars-d-learn
On Saturday, 18 March 2017 at 11:29:43 UTC, alex1974 wrote: I want to build a custom library with useful extensions to phobos. They should be named like: extensions.regex extensions.path extensions.files ... Some libraries, like extensions.files contain several files (e.g files.d, filesexcept

Re: first try

2017-03-18 Thread Philip Miess via Digitalmars-d-learn
On Fri, 17 Mar 2017 03:55:26 +, Jordan Wilson wrote: > Hello Phil, > > I think there might be an issue with this function here: snip > I get an infinate loop if I put in something that's not convertible to > an integer. I think what happens is that you catch the exception, the > input still re

Re: Enums and immutables

2017-03-18 Thread rikki cattermole via Digitalmars-d-learn
On 19/03/2017 1:22 AM, Oleg B wrote: Hello. I found strange behavior while casting enum array and immutable array. import std.stdio; void main() { enum arr = cast(ubyte[])[0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4]; auto arr1 = cast(void[])arr; immutable arr2 = cast(immutable(void)[])arr;

Re: Building custom library package with dub

2017-03-18 Thread alex1974 via Digitalmars-d-learn
On Saturday, 18 March 2017 at 12:26:35 UTC, Basile B. wrote: On Saturday, 18 March 2017 at 11:29:43 UTC, alex1974 wrote: [...] You can put everything in a single library. The module names should match to the folder layout: extensions/regex.d// module extensions.regex;

Re: first try

2017-03-18 Thread Philip Miess via Digitalmars-d-learn
On Fri, 17 Mar 2017 09:44:02 +, Andrea Fontana wrote: >> // Probably you mean > rather than >= >> if ( card1 >= card2 ) { >> swap( card1, card2); >> } >> >> >> // This is an old way to avoid not-intended assigment // but in D >> problem doesn't exists (and yoda notation doesn't work well wi

Re: first try

2017-03-18 Thread Philip Miess via Digitalmars-d-learn
On Fri, 17 Mar 2017 23:58:59 +, XavierAP wrote: > On Friday, 17 March 2017 at 00:35:32 UTC, Philip Miess wrote: >> >> https://gitlab.com/pmiess/101gamesDlangComputerGames/blob/master/ >> aceyducy.d > > You don't need string literals to be verbatim (r"") in order to insert > newlines as in th

Re: Get most D type from type

2017-03-18 Thread Hussien via Digitalmars-d-learn
On Saturday, 18 March 2017 at 05:15:07 UTC, Mike Parker wrote: On Saturday, 18 March 2017 at 02:23:01 UTC, Hussien wrote: I need the general solution. One that simply returns the type. None of what you said helps... string dtype(T)() { static if(is(T == enum)) return "enum"; el

Re: Get most D type from type

2017-03-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 18 March 2017 at 13:06:56 UTC, Hussien wrote: So you are telling me there is no way to do this easily? What are you actually trying to do?

Re: Get most D type from type

2017-03-18 Thread Hussien via Digitalmars-d-learn
On Saturday, 18 March 2017 at 13:16:49 UTC, Adam D. Ruppe wrote: On Saturday, 18 March 2017 at 13:06:56 UTC, Hussien wrote: So you are telling me there is no way to do this easily? What are you actually trying to do? Glad you asked! It is very simple: I am trying to get the underlying D typ

Re: Building custom library package with dub

2017-03-18 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 18 March 2017 at 12:49:33 UTC, alex1974 wrote: This simple layout works, but then all parts will be compiled every time. Is there a way to just compile the "sublibraries" which have changed? By "compiled every time", if you're talking about when using the library as a dependen

Re: Building custom library package with dub

2017-03-18 Thread alex1974 via Digitalmars-d-learn
On Saturday, 18 March 2017 at 13:41:12 UTC, Mike Parker wrote: On Saturday, 18 March 2017 at 12:49:33 UTC, alex1974 wrote: This simple layout works, but then all parts will be compiled every time. Is there a way to just compile the "sublibraries" which have changed? By "compiled every time

Re: Get most D type from type

2017-03-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 18 March 2017 at 13:30:22 UTC, Hussien wrote: Glad you asked! It is very simple: I am trying to get the underlying D type from a type that I have. But why? What are you going to do with it?

Re: Get most D type from type

2017-03-18 Thread Hussien via Digitalmars-d-learn
On Saturday, 18 March 2017 at 13:47:50 UTC, Adam D. Ruppe wrote: On Saturday, 18 March 2017 at 13:30:22 UTC, Hussien wrote: Glad you asked! It is very simple: I am trying to get the underlying D type from a type that I have. But why? What are you going to do with it? I'm going to use it in m

Re: List Comprehension equivalent

2017-03-18 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2017-03-18 at 11:38 +, thedeemon via Digitalmars-d-learn wrote: > On Saturday, 18 March 2017 at 11:09:34 UTC, Russel Winder wrote: > > Is this foldr or foldl' ? > > It's a left fold of course, having foldr by default in eager  > language would be awkward. I would expect foldl, but the

Re: std.digest toHexString

2017-03-18 Thread NotSpooky via Digitalmars-d-learn
On Thursday, 16 March 2017 at 22:06:24 UTC, H. S. Teoh wrote: On Thu, Mar 16, 2017 at 02:36:15PM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: [...] Honestly, I think that it was a big mistake to have implicit slicing of static arrays in the language at all. That makes at least 3 of u

Re: Get most D type from type

2017-03-18 Thread Basile B. via Digitalmars-d-learn
On Saturday, 18 March 2017 at 13:30:22 UTC, Hussien wrote: On Saturday, 18 March 2017 at 13:16:49 UTC, Adam D. Ruppe wrote: On Saturday, 18 March 2017 at 13:06:56 UTC, Hussien wrote: So you are telling me there is no way to do this easily? What are you actually trying to do? Glad you asked!

trying to use nightly in windows 10 x64

2017-03-18 Thread steven kladitis via Digitalmars-d-learn
before trying nightly I run the c:\d\dmd2vars32.bat or c:\d\dmd2vars64.bat respectively. and I can compile an run either 32 or 64 bit executables. now I want to try nightly I renamed the current dmd directory in c:\d to dmd_current I extracted the 7z file for nightly into c:\d the 32 bit appears

Re: Get most D type from type

2017-03-18 Thread Hussien via Digitalmars-d-learn
On Saturday, 18 March 2017 at 15:16:35 UTC, Basile B. wrote: On Saturday, 18 March 2017 at 13:30:22 UTC, Hussien wrote: On Saturday, 18 March 2017 at 13:16:49 UTC, Adam D. Ruppe wrote: On Saturday, 18 March 2017 at 13:06:56 UTC, Hussien wrote: So you are telling me there is no way to do this e

Re: Get most D type from type

2017-03-18 Thread Basile B. via Digitalmars-d-learn
On Saturday, 18 March 2017 at 15:30:27 UTC, Hussien wrote: On Saturday, 18 March 2017 at 15:16:35 UTC, Basile B. wrote: On Saturday, 18 March 2017 at 13:30:22 UTC, Hussien wrote: On Saturday, 18 March 2017 at 13:16:49 UTC, Adam D. Ruppe wrote: On Saturday, 18 March 2017 at 13:06:56 UTC, Hussie

Re: trying to use nightly in windows 10 x64

2017-03-18 Thread steven kladitis via Digitalmars-d-learn
On Saturday, 18 March 2017 at 15:26:42 UTC, steven kladitis wrote: before trying nightly I run the c:\d\dmd2vars32.bat or c:\d\dmd2vars64.bat respectively. and I can compile an run either 32 or 64 bit executables. now I want to try nightly I renamed the current dmd directory in c:\d to dmd_cu

'Access Violation Error' with parallel-foreach loop

2017-03-18 Thread ooyu via Digitalmars-d-learn
When i was uing parallel-foreach loop, got this error: object.Error@(0): Access Violation 0x0056CCB8 in _flushbu 0x005663C7 in fwrite 0x0041D39F in nothrow @nogc @trusted uint std.stdio.trustedFwrite!(char).trustedFwrite(share

Error: out of memory

2017-03-18 Thread StarGrazer via Digitalmars-d-learn
I have some CTFE's and meta programming that cause dmd to run out of memory ;/ I am generating simple classes, but a lot of them. dmd uses about 2GB before it quites. It also only uses about 12% of cpu. I have 16 GB total memory and about that free. Surely dmd could do a better job? Any way

Re: Error: out of memory

2017-03-18 Thread Basile B. via Digitalmars-d-learn
On Saturday, 18 March 2017 at 20:39:20 UTC, StarGrazer wrote: I have some CTFE's and meta programming that cause dmd to run out of memory ;/ I am generating simple classes, but a lot of them. dmd uses about 2GB before it quites. It also only uses about 12% of cpu. I have 16 GB total memory a

Re: Error: out of memory

2017-03-18 Thread StarGrazer via Digitalmars-d-learn
On Saturday, 18 March 2017 at 20:43:29 UTC, Basile B. wrote: On Saturday, 18 March 2017 at 20:39:20 UTC, StarGrazer wrote: I have some CTFE's and meta programming that cause dmd to run out of memory ;/ I am generating simple classes, but a lot of them. dmd uses about 2GB before it quites. It

Re: 'Access Violation Error' with parallel-foreach loop

2017-03-18 Thread ikod via Digitalmars-d-learn
On Saturday, 18 March 2017 at 16:15:30 UTC, ooyu wrote: When i was uing parallel-foreach loop, got this error: object.Error@(0): Access Violation 0x0056CCB8 in _flushbu 0x005663C7 in fwrite 0x0041D39F in nothrow @nogc @trusted

Re: Enums and immutables

2017-03-18 Thread ag0aep6g via Digitalmars-d-learn
On 03/18/2017 01:22 PM, Oleg B wrote: enum arr = cast(ubyte[])[0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4]; auto arr1 = cast(void[])arr; immutable arr2 = cast(immutable(void)[])arr; enum arr3 = cast(void[])arr; Aside: The casts here do nothing to affect the outcome. writeln(cast(ush

Re: 'Access Violation Error' with parallel-foreach loop

2017-03-18 Thread Vladimir Panteleev via Digitalmars-d-learn
On Saturday, 18 March 2017 at 16:15:30 UTC, ooyu wrote: I don't understand why got Access Violation error. :-( That looks like https://issues.dlang.org/show_bug.cgi?id=13727, though I thought a fix was included in recent DMD Windows versions. Try using std.file.write.

Re: Error: out of memory

2017-03-18 Thread Basile B. via Digitalmars-d-learn
On Saturday, 18 March 2017 at 20:56:47 UTC, StarGrazer wrote: On Saturday, 18 March 2017 at 20:43:29 UTC, Basile B. wrote: On Saturday, 18 March 2017 at 20:39:20 UTC, StarGrazer wrote: I have some CTFE's and meta programming that cause dmd to run out of memory ;/ I am generating simple classe

Re: Error: out of memory

2017-03-18 Thread XavierAP via Digitalmars-d-learn
On Saturday, 18 March 2017 at 20:39:20 UTC, StarGrazer wrote: about 2GB before it quites. It also only uses about 12% of cpu. I have 16 GB total memory and about that free. Surely dmd could do a better job? Any way to get it to do such a thing like set the maximum amount of memory it can use?

Re: Error: out of memory

2017-03-18 Thread kinke via Digitalmars-d-learn
The Win64 LDC releases [https://github.com/ldc-developers/ldc/releases] feature a 64-bit compiler.

Re: bug in foreach continue

2017-03-18 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Mar 17, 2017 at 02:52:39PM -0700, Ali Çehreli via Digitalmars-d-learn wrote: > On 03/17/2017 12:05 PM, H. S. Teoh via Digitalmars-d-learn wrote: > > > 1) Template expansion / AST manipulation, and: > > > > 2) CTFE (compile-time function evaluation). > > > > Not clearly understanding the

Re: 'Access Violation Error' with parallel-foreach loop

2017-03-18 Thread ooyu via Digitalmars-d-learn
On Saturday, 18 March 2017 at 20:57:59 UTC, ikod wrote: On Saturday, 18 March 2017 at 16:15:30 UTC, ooyu wrote: When i was uing parallel-foreach loop, got this error: object.Error@(0): Access Violation 0x0056CCB8 in _flushbu

Re: 'Access Violation Error' with parallel-foreach loop

2017-03-18 Thread ooyu via Digitalmars-d-learn
On Saturday, 18 March 2017 at 22:27:27 UTC, Vladimir Panteleev wrote: On Saturday, 18 March 2017 at 16:15:30 UTC, ooyu wrote: I don't understand why got Access Violation error. :-( That looks like https://issues.dlang.org/show_bug.cgi?id=13727, though I thought a fix was included in recent DM

Re: bug in foreach continue

2017-03-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, March 18, 2017 17:18:15 H. S. Teoh via Digitalmars-d-learn wrote: > On Fri, Mar 17, 2017 at 02:52:39PM -0700, Ali Çehreli via Digitalmars-d- learn wrote: > > On 03/17/2017 12:05 PM, H. S. Teoh via Digitalmars-d-learn wrote: > > > 1) Template expansion / AST manipulation, and: > > > >

'_input' field not found in MapResult

2017-03-18 Thread Dragos Carp via Digitalmars-d-learn
After minimizing a more complex program I got the following small example that produces a rather strange error. The error says that MapResult has no field '_input' although the sole MapResult definition has such a field. What is the explanation for this error? ``` auto foo(T)(T ) { import

How to COM interfaces work

2017-03-18 Thread StarGrazer via Digitalmars-d-learn
I have a COM interface that is dynamically created using invoke and such. One of the functions returns an interface. It is just a value of IUnknown or whatever. If I use it as a pointer in to the the D interface equivalent, it crashes as the value is not pointing to anything valid. What do

Re: bug in foreach continue

2017-03-18 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 19 March 2017 at 00:18:15 UTC, H. S. Teoh wrote: Haha, I don't think I'm up for writing a book... and I don't really keep a blog either. But perhaps a writeup on wiki.dlang.org is in order. This particular topic, I think, is something somebody *should* write about, because it s

Re: How to COM interfaces work

2017-03-18 Thread evilrat via Digitalmars-d-learn
On Sunday, 19 March 2017 at 02:04:53 UTC, StarGrazer wrote: I have a COM interface that is dynamically created using invoke and such. One of the functions returns an interface. It is just a value of IUnknown or whatever. If I use it as a pointer in to the the D interface equivalent, it cras

Re: How to COM interfaces work

2017-03-18 Thread StarGrazer via Digitalmars-d-learn
On Sunday, 19 March 2017 at 02:45:48 UTC, evilrat wrote: On Sunday, 19 March 2017 at 02:04:53 UTC, StarGrazer wrote: I have a COM interface that is dynamically created using invoke and such. One of the functions returns an interface. It is just a value of IUnknown or whatever. If I use it a

Re: How to COM interfaces work

2017-03-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 19 March 2017 at 02:04:53 UTC, StarGrazer wrote: If I use it as a pointer in to the the D interface equivalent, it crashes as the value is not pointing to anything valid. What's the code look like? What interface too?

Re: How to COM interfaces work

2017-03-18 Thread StarGrazer via Digitalmars-d-learn
On Sunday, 19 March 2017 at 02:45:48 UTC, evilrat wrote: On Sunday, 19 March 2017 at 02:04:53 UTC, StarGrazer wrote: I have a COM interface that is dynamically created using invoke and such. One of the functions returns an interface. It is just a value of IUnknown or whatever. If I use it a

Re: How to COM interfaces work

2017-03-18 Thread StarGrazer via Digitalmars-d-learn
On Sunday, 19 March 2017 at 03:10:02 UTC, Adam D. Ruppe wrote: On Sunday, 19 March 2017 at 02:04:53 UTC, StarGrazer wrote: If I use it as a pointer in to the the D interface equivalent, it crashes as the value is not pointing to anything valid. What's the code look like? What interface too?

Re: How to COM interfaces work

2017-03-18 Thread evilrat via Digitalmars-d-learn
On Sunday, 19 March 2017 at 03:27:28 UTC, StarGrazer wrote: I'd just like to get some conformation on the process so at least I know I'm headed in the right direction. The project is pretty complex and most of the stuff is done in compile time code. What debug shows? If CoCreateInstance an