Operator Overloading for Enum

2021-02-08 Thread Michael Brown via Digitalmars-d-learn
Hi all, Is it possible to operator overload on enums? I'd like to do a opCmp() Kind regards, Mike

Re: cannot call impure function

2020-10-04 Thread Michael via Digitalmars-d-learn
On Sunday, 4 October 2020 at 17:43:13 UTC, Michael wrote: On Sunday, 4 October 2020 at 17:37:52 UTC, Mathias LANG wrote: On Sunday, 4 October 2020 at 17:05:33 UTC, Michael wrote: On Sunday, 4 October 2020 at 17:01:44 UTC, Paul Backus wrote: On Sunday, 4 October 2020 at 16:48:24 UTC, Michael

Re: cannot call impure function

2020-10-04 Thread Michael via Digitalmars-d-learn
On Sunday, 4 October 2020 at 17:37:52 UTC, Mathias LANG wrote: On Sunday, 4 October 2020 at 17:05:33 UTC, Michael wrote: On Sunday, 4 October 2020 at 17:01:44 UTC, Paul Backus wrote: On Sunday, 4 October 2020 at 16:48:24 UTC, Michael wrote: Dear all, Sorry for the potentially stupid question

Re: cannot call impure function

2020-10-04 Thread Michael via Digitalmars-d-learn
On Sunday, 4 October 2020 at 17:05:33 UTC, Michael wrote: On Sunday, 4 October 2020 at 17:01:44 UTC, Paul Backus wrote: On Sunday, 4 October 2020 at 16:48:24 UTC, Michael wrote: Dear all, Sorry for the potentially stupid question, but I'm a complete newbie to D. Why does compilin

Re: cannot call impure function

2020-10-04 Thread Michael via Digitalmars-d-learn
On Sunday, 4 October 2020 at 17:01:44 UTC, Paul Backus wrote: On Sunday, 4 October 2020 at 16:48:24 UTC, Michael wrote: Dear all, Sorry for the potentially stupid question, but I'm a complete newbie to D. Why does compiling the following trivial code fail? import std.stdio; void

cannot call impure function

2020-10-04 Thread Michael via Digitalmars-d-learn
(1590):instantiated from here: formattedWrite!(LockingTextWriter, char, double) /Library/D/dmd/src/phobos/std/stdio.d(3927):instantiated from here: write!(double, char) test1.d(5):instantiated from here: writeln!double Cheers, Michael

Re: D on lm32-CPU: string argument on stack instead of register

2020-08-04 Thread Michael Reese via Digitalmars-d-learn
On Saturday, 1 August 2020 at 23:08:38 UTC, Chad Joan wrote: Though if the compiler is allowed to split a single uint64_t into two registers, I would expect it to split struct/string into two registers as well. At least, the manual doesn't seem to explicitly mention higher-level constructs like

Re: D on lm32-CPU: string argument on stack instead of register

2020-08-01 Thread Michael Reese via Digitalmars-d-learn
On Friday, 31 July 2020 at 15:13:29 UTC, Chad Joan wrote: THAT SAID, I think there are things to try and I hope we can get you what you want. If you're willing to entertain more experimentation, here are my thoughts: Thanks a lot for the suggestions and explanations. I tried them all but th

D on lm32-CPU: string argument on stack instead of register

2020-07-31 Thread Michael Reese via Digitalmars-d-learn
n, it is also slower because it need to access the ram, and it needs more stack space. My question: Is there a way I can tell the D compiler to use registers instead of stack for string arguments, or any other trick to reduce code size while maintaining an ideomatic D codestyle? Best regards Mich

Unused imports

2020-01-30 Thread Michael via Digitalmars-d-learn
Is there a way to detect unused imports? It happened to me that I used imports which I did not need in the end. So, I'd like to remove them easily.

Re: readline / Gnu readline

2020-01-30 Thread Michael via Digitalmars-d-learn
On Thursday, 30 January 2020 at 13:23:17 UTC, Adam D. Ruppe wrote: On Thursday, 30 January 2020 at 06:12:32 UTC, Michael wrote: I did exactly just what you proposed. yeah i often just leave my random filenames in there, in this case rl was one of them. (if you don't put `.d` at the end

auto keyword

2020-01-30 Thread Michael via Digitalmars-d-learn
auto is surely a nice feature. Nonetheless I'd prefer to use explicit types. So when reading a code and I see the auto keyword I also have to find out what kind of type is meant. I have a line of code that looks like this: auto elements = buf.to!string.strip.split(" ").filter!(a => a != "");

Re: readline / Gnu readline

2020-01-30 Thread Michael via Digitalmars-d-learn
On Thursday, 30 January 2020 at 08:13:16 UTC, Mike Parker wrote: That means any arguments you pass on the command line after the source file name will be passed to your program. Compiler options need to go before the source file name. rdmd -L-lreadline mysource.d That works, thanks Mike

Re: readline / Gnu readline

2020-01-29 Thread Michael via Digitalmars-d-learn
On Thursday, 30 January 2020 at 06:15:54 UTC, Mike Parker wrote: Is your source file named rl.d? And are you running dmd in the source file's directory? No, I did not. Changed it now and it works with dmd. Great! Tried the same with rdmd I'm getting a linker error.

Re: readline / Gnu readline

2020-01-29 Thread Michael via Digitalmars-d-learn
On Wednesday, 29 January 2020 at 21:15:08 UTC, Adam D. Ruppe wrote: On Wednesday, 29 January 2020 at 20:01:32 UTC, Michael wrote: I am new to D. I would like to use the Gnu readline function in D. Is there a module that i can use? just define it yourself --- // this line right here is all

readline / Gnu readline

2020-01-29 Thread Michael via Digitalmars-d-learn
I am new to D. I would like to use the Gnu readline function in D. Is there a module that i can use?

Re: Run-time reflection for class inheritance

2019-12-02 Thread Michael Green via Digitalmars-d-learn
On Sunday, 1 December 2019 at 14:42:46 UTC, Adam D. Ruppe wrote: You can get the type at runtime by simply casting it... if(auto c = cast(EventSocket) event) { // is an event socket } Thanks. I guess you need to be careful about which order you do those tests so as not to cast to more gen

Re: Run-time reflection for class inheritance

2019-12-01 Thread Michael Green via Digitalmars-d-learn
On Sunday, 1 December 2019 at 12:26:03 UTC, Michael Green wrote: interface Event { [note to self - shouldn't make last minute checks and reverse them by hand before posting] That should of course read: class Event {

Run-time reflection for class inheritance

2019-12-01 Thread Michael Green via Digitalmars-d-learn
I don't know if this would be a sensible approach to try and get at the actual class types for objects stored in some container at runtime? I have noticed that this approach doesn't work if Event is an interface rather than a ancestor class. ``` import std.stdio; import std.string; import s

What is the simplest way to download and set path variables for D compilers when using AppVeyor

2019-11-27 Thread Michael Brockus via Digitalmars-d-learn
I am wondering if you guys would know what maybe the simplest way to have D working on AppVeyor because I already have a solution for both CircleCi, Travis-Ci and wish to expand to windows. Also as tip for Meson build users Ninja is available on PyPi meaning that you can have a simple command

Re: Deprecation: foreach: loop index implicitly converted from size_t to int

2019-01-18 Thread Michael via Digitalmars-d-learn
On Friday, 18 January 2019 at 13:29:29 UTC, Adam D. Ruppe wrote: On Friday, 18 January 2019 at 12:27:17 UTC, Michael wrote: This, to be, looks like quite the explicit conversion, no? Yeah, I agree. But the language is silly. I just leave the type out of foreach and explicitly cast it inside

Deprecation: foreach: loop index implicitly converted from size_t to int

2019-01-18 Thread Michael via Digitalmars-d-learn
quite the explicit conversion, no? Does it mean I now have to use to!int(i) to convert the type of i in a foreach now? Thanks, Michael.

Re: Enum and CTFE function call

2018-08-14 Thread Michael via Digitalmars-d-learn
On Tuesday, 14 August 2018 at 11:25:06 UTC, Jonathan M Davis wrote: On Tuesday, August 14, 2018 4:03:11 AM MDT Michael via Digitalmars-d-learn wrote: [...] CTFE is triggered when a value must be known at compile-time. So, if you have something like [...] That is much clearer now, thanks

Re: Enum and CTFE function call

2018-08-14 Thread Michael via Digitalmars-d-learn
On Tuesday, 14 August 2018 at 09:17:41 UTC, ixid wrote: On Tuesday, 14 August 2018 at 09:12:30 UTC, ixid wrote: This will not compile as it says n is not known at compile time... This does work if 'value' is changed to immutable and fun to accept it. So it still seems like a missed opportunit

Re: UFCS confusion

2018-07-13 Thread Michael via Digitalmars-d-learn
On Friday, 13 July 2018 at 11:17:32 UTC, Radu wrote: On Friday, 13 July 2018 at 11:12:47 UTC, Michael wrote: On Friday, 13 July 2018 at 10:52:54 UTC, Radu wrote: On Friday, 13 July 2018 at 10:21:54 UTC, Michael wrote: [...] Do you try to call member functions? UFCS only works with free

Re: UFCS confusion

2018-07-13 Thread Michael via Digitalmars-d-learn
On Friday, 13 July 2018 at 10:52:54 UTC, Radu wrote: On Friday, 13 July 2018 at 10:21:54 UTC, Michael wrote: Hello, I am nesting some function calls, and I'm pretty used to making use of D's Uniform Function Call Syntax, but I'm getting an error if I try to convert this lin

UFCS confusion

2018-07-13 Thread Michael via Digitalmars-d-learn
Hello, I am nesting some function calls, and I'm pretty used to making use of D's Uniform Function Call Syntax, but I'm getting an error if I try to convert this line: createSet(createVector(langSize, index)).length; which works, into this line: createVector(langSize, index).createSet.le

Re: Passing a reference to a returned reference

2018-07-06 Thread Michael via Digitalmars-d-learn
On Friday, 6 July 2018 at 16:24:03 UTC, Timoses wrote: On Friday, 6 July 2018 at 15:51:34 UTC, Michael wrote: [...] While writing I realized that the following is even the case without the 'ref' parameter: The caller of the setter will still be able to change the content of your pr

Re: Passing a reference to a returned reference

2018-07-06 Thread Michael via Digitalmars-d-learn
On Friday, 6 July 2018 at 15:57:27 UTC, Timoses wrote: On Friday, 6 July 2018 at 15:33:18 UTC, Michael wrote: This is definitely to do with my use of the setter syntax, which maybe I am misunderstanding? Because if I change it to a normal function call like so: a.beliefs(Operator.create

Re: Passing a reference to a returned reference

2018-07-06 Thread Michael via Digitalmars-d-learn
On Friday, 6 July 2018 at 15:37:25 UTC, Timoses wrote: On Friday, 6 July 2018 at 15:14:01 UTC, Michael wrote: class Agent { private { double[int] mDict; } // Setter: copy void beliefs(ref double[int] dict) { import std.stdio : writeln; writeln

Re: Passing a reference to a returned reference

2018-07-06 Thread Michael via Digitalmars-d-learn
On Friday, 6 July 2018 at 15:14:01 UTC, Michael wrote: On Friday, 6 July 2018 at 14:50:39 UTC, Ali Çehreli wrote: [...] I'm just trying to do that now. Here is what I have in terms of code: [...] This is definitely to do with my use of the setter syntax, which maybe I am misundersta

Re: Passing a reference to a returned reference

2018-07-06 Thread Michael via Digitalmars-d-learn
On Friday, 6 July 2018 at 14:50:39 UTC, Ali Çehreli wrote: On 07/06/2018 07:36 AM, Michael wrote: > but not in > my case, if this is a weird edge-case with setter member functions? This is all very interesting but I'm dying to see the code. :) Can you change Timoses's code to

Re: Passing a reference to a returned reference

2018-07-06 Thread Michael via Digitalmars-d-learn
On Friday, 6 July 2018 at 14:11:42 UTC, Timoses wrote: This works for me: auto create() { string[int] dict; dict[2] = "hello"; return dict; } void modifyNoRef(string[int] m) { writeln("Address not ref: ", &m); m[0] = "modified";

Re: Passing a reference to a returned reference

2018-07-06 Thread Michael via Digitalmars-d-learn
On Friday, 6 July 2018 at 14:11:42 UTC, Timoses wrote: On Friday, 6 July 2018 at 13:13:43 UTC, Michael wrote: static auto ref consensus( ... ) `auto ref` infers the return type from the return statement [1]. So it's not necessarily returning a ref type. However, I don't think th

Passing a reference to a returned reference

2018-07-06 Thread Michael via Digitalmars-d-learn
Hello, I'm a little confused about what is actually happening when I try to pass a reference, returned by a method that produces the object (associative array), to a setter method which expects a reference. What seems to be happening is that it simply does nothing, as if the setter method is

Function in a slice instead of just pointer?

2018-06-21 Thread Michael Brown via Digitalmars-d-learn
Hi D Community, Is it possible to get a slice of a function, rather than just its start pointer? I'm interested in currying a function at runtime - So I would need to copy a function block (Either the original function, a wrapper function, or copys of manually altered functions). Addresses

Re: ldc flags for beginner

2018-04-22 Thread Michael via Digitalmars-d-learn
On Sunday, 22 April 2018 at 02:08:40 UTC, fevasu wrote: what flags to use so that the intermediate .o files are discared by ldc and only a.out is written to disk You can also use rdmd with ldc, if that makes things easier.

Should "a is b" compile if a and b have unrelated classes?

2018-04-10 Thread Michael Coulombe via Digitalmars-d-learn
I had a bug in my code that was messing me up for a while, and it boiled down to an identity check between two Object references with unrelated static types, like below: class A {} class B {} void main() { A a = new A; B b = new B; if (a is b) {} // compiles } I was surprised that

Re: How to delete element from array container or dlist?

2018-03-18 Thread Michael via Digitalmars-d-learn
On Sunday, 18 March 2018 at 15:42:18 UTC, Andrey Kabylin wrote: On Sunday, 18 March 2018 at 15:32:47 UTC, Michael wrote: On Sunday, 18 March 2018 at 14:58:52 UTC, Andrey Kabylin wrote: In DList we have method remove, but I can't understand how this method works, I want write somethink

Re: How to delete element from array container or dlist?

2018-03-18 Thread Michael via Digitalmars-d-learn
On Sunday, 18 March 2018 at 14:58:52 UTC, Andrey Kabylin wrote: In DList we have method remove, but I can't understand how this method works, I want write somethink like this: void unsubscribe(EventsSubscriber subscriber) { subscribers.remove(subscriber); } The remove function seems to exp

Re: How to delete element from array container or dlist?

2018-03-18 Thread Michael via Digitalmars-d-learn
On Sunday, 18 March 2018 at 14:58:52 UTC, Andrey Kabylin wrote: In DList we have method remove, but I can't understand how this method works, I want write somethink like this: void unsubscribe(EventsSubscriber subscriber) { subscribers.remove(subscriber); } So I guess you would want someth

Re: I want to transmit the class name and the member name in the method

2018-01-05 Thread Michael via Digitalmars-d-learn
On Friday, 5 January 2018 at 12:19:11 UTC, thedeemon wrote: On Friday, 5 January 2018 at 07:40:14 UTC, Brian wrote: I think code style like: db.select(User).where(email.like("*@hotmail.com")).limit(10); You need to read about templates in D, here's a good guide: https://github.com/PhilippeSiga

Re: Alias example should supposedly be illegal, but runs fine

2017-12-19 Thread Michael via Digitalmars-d-learn
On Tuesday, 19 December 2017 at 02:12:29 UTC, Mike Franklin wrote: On Tuesday, 19 December 2017 at 02:04:34 UTC, codephantom wrote: writeln(S.j); // Error: Instance symbols cannot be used through types. I don't understand why you would say that is a bug. I meant that the example is wrong

Re: Alias example should supposedly be illegal, but runs fine

2017-12-19 Thread Michael via Digitalmars-d-learn
On Tuesday, 19 December 2017 at 01:29:04 UTC, Meta wrote: On Monday, 18 December 2017 at 23:44:46 UTC, Michael wrote: [...] I think the reason that this works is because i is static, meaning that you don't need the `this` reference of S to access it and thus it can be aliased. Declar

Alias example should supposedly be illegal, but runs fine

2017-12-18 Thread Michael via Digitalmars-d-learn
Hello, I have been looking at the following example found right at the end of the section here: https://dlang.org/spec/declaration.html#alias struct S { static int i; } S s; alias a = s.i; // illegal, s.i is an expression alias b = S.i; // ok b = 4; // sets S.i to 4 and it runs fine

Re: Is there a pragma or command line option to ask DMD to show a warning when it implicitly casts from long to ulong ?

2017-12-15 Thread Michael via Digitalmars-d-learn
On Friday, 15 December 2017 at 21:29:10 UTC, Jonathan M Davis wrote: On Friday, December 15, 2017 20:40:10 Ecstatic Coder via Digitalmars-d-learn wrote: It's taken me some time to find an implicit cast bug ("if (my_sometimes_negative_index >= this_array.length)"), while a simple C++-like implic

Re: Shared and race conditions

2017-11-29 Thread Michael via Digitalmars-d-learn
On Wednesday, 29 November 2017 at 17:03:42 UTC, Steven Schveighoffer wrote: On 11/29/17 11:13 AM, Wanderer wrote: I'm trying to simulate a race condition in D with the following code: (https://run.dlang.io/is/RfOX0I) One word of caution, I think the running of your code on run.dlang.io is c

Re: Shared and race conditions

2017-11-29 Thread Michael via Digitalmars-d-learn
On Wednesday, 29 November 2017 at 16:33:50 UTC, Steven Schveighoffer wrote: On 11/29/17 11:13 AM, Wanderer wrote: [...] [snip] [...] Using the compiler switch -vcg-ast, I see no synchronization of these methods. [...] Any idea what has changed in DMD-nightly to retain the correct ord

Re: Shared and race conditions

2017-11-29 Thread Michael via Digitalmars-d-learn
On Wednesday, 29 November 2017 at 16:19:05 UTC, Michael wrote: On Wednesday, 29 November 2017 at 16:13:13 UTC, Wanderer wrote: [...] I unfortunately cannot answer your question but I am noticing that running the code with DMD gives you an unordered sequence of IDs, but running with DMD

Re: Shared and race conditions

2017-11-29 Thread Michael via Digitalmars-d-learn
On Wednesday, 29 November 2017 at 16:13:13 UTC, Wanderer wrote: I'm trying to simulate a race condition in D with the following code: (https://run.dlang.io/is/RfOX0I) ``` import std.stdio; import core.thread; import std.concurrency; shared struct IdGen(T) { T id; this(T start) {

Re: Floating point types default to NaN?

2017-11-28 Thread Michael V. Franklin via Digitalmars-d-learn
On Wednesday, 29 November 2017 at 01:24:21 UTC, A Guy With a Question wrote: I was just more curious of the design decisions that were made. So am I. I'm trying to get to the heart of in the the PR comments. Mike

Re: Floating point types default to NaN?

2017-11-28 Thread Michael V. Franklin via Digitalmars-d-learn
On Monday, 27 November 2017 at 23:05:55 UTC, Michael V. Franklin wrote: I think I'm going to implement a feature gate to require explicit initialization. It would be better to be strict up front and relax it as flow control analysis becomes more mature. Well, I implemented it (

Re: Floating point types default to NaN?

2017-11-27 Thread Michael V. Franklin via Digitalmars-d-learn
On Saturday, 25 November 2017 at 22:13:43 UTC, Adam D. Ruppe wrote: It technically did: https://dlang.org/spec/function.html#local-variables "It is an error to use a local variable without first assigning it a value. The implementation may not always be able to detect these cases. Other lan

Re: DMD test suite assertion failure in test_cdvecfill.d

2017-11-25 Thread Michael V. Franklin via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 10:04:50 UTC, Petar Kirov [ZombineDev] wrote: File a bug report and try contacting Martin Nowak, as he's the author of this test, IIRC. https://issues.dlang.org/show_bug.cgi?id=18013

Re: betterC and noboundscheck

2017-11-24 Thread Michael V. Franklin via Digitalmars-d-learn
On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote: import core.stdc.stdio; import std.algorithm : min; extern (C) void main() { char[256] buf; buf[] = '\0'; auto str = "hello world"; auto ln = min(buf.length, str.length); buf[0..ln] = str[0..ln]; printf("%s\n

Re: reduce condition nesting

2017-11-23 Thread Michael via Digitalmars-d-learn
On Thursday, 23 November 2017 at 14:16:25 UTC, Andrea Fontana wrote: On Thursday, 23 November 2017 at 13:47:37 UTC, Adam D. Ruppe wrote: On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote: for instance in kotlin it can be replace with this: when { c1 -> foo(), c2 -> bar(),

Re: Can I count the of enum's fields at compile time?

2017-11-22 Thread Michael V. Franklin via Digitalmars-d-learn
On Thursday, 23 November 2017 at 00:58:21 UTC, Marc wrote: for example: enum A { a = -10, b = -11, c = -12, d = -13, e = -34} enum int countOfA = coutOfFields(A); // 5 fields https://dlang.org/spec/traits.html#allMembers enum A { a = -10, b = -11, c = -12, d = -13, e = -34} enum int countOf

DMD test suite assertion failure in test_cdvecfill.d

2017-11-20 Thread Michael V. Franklin via Digitalmars-d-learn
I'm getting this error when I try to run the DMD test suite. cd dmd make -C test -f Makefile ... runnable/test_cdvecfill.d -O (-mcpu=avx -mcpu=avx2) Test failed. The logged output: ../src/dmd -conf= -m64 -Irunnable -O -odtest_results/runnable -oftest_results/runnable/test_cdvecfill_0 r

Re: writeln, alias this and dynamic arrays.

2017-11-16 Thread Michael V. Franklin via Digitalmars-d-learn
On Friday, 17 November 2017 at 02:13:54 UTC, matthewh wrote: [...] as is it produces: [1, 2, 3, 4, 5, 6, 7, 8] [] I expected it to produce: [1, 2, 3, 4, 5, 6, 7, 8] [1, 2, 3, 4, 5, 6, 7, 8] And with the toString override included it does. Why does the version without the toString override ou

Re: writeln, alias this and dynamic arrays.

2017-11-16 Thread Michael V. Franklin via Digitalmars-d-learn
On Friday, 17 November 2017 at 02:16:35 UTC, Michael V. Franklin wrote: On Friday, 17 November 2017 at 02:13:54 UTC, matthewh wrote: And with the toString override included it does. Why does the version without the toString override output an empty array? I think that is due to this bug

Re: writeln, alias this and dynamic arrays.

2017-11-16 Thread Michael V. Franklin via Digitalmars-d-learn
On Friday, 17 November 2017 at 02:13:54 UTC, matthewh wrote: And with the toString override included it does. Why does the version without the toString override output an empty array? I think that is due to this bug: https://issues.dlang.org/show_bug.cgi?id=13189 It's actually on my todo

Re: Conditional compilation of array of structs initializer

2017-11-09 Thread Michael V. Franklin via Digitalmars-d-learn
On Friday, 10 November 2017 at 06:22:51 UTC, Tony wrote: Doing a port of some C code that has an #ifdef in the middle of an initialization for an array of structs. I am getting a compile error trying to get equivalent behavior with "static if" or "version". Is there a way to achieve this other

Re: Compiler magic for preventing memory access re-ordering _by the compiler_ (keywords: memory model, compiler optimisations, memory order)

2017-11-05 Thread Michael V. Franklin via Digitalmars-d-learn
On Monday, 6 November 2017 at 05:54:00 UTC, Michael V. Franklin wrote: On Monday, 6 November 2017 at 03:40:23 UTC, Cecil Ward wrote: Is there a magic visible sign (or even one needed) in the D language that tells D _compilers_ not to move certain types of memory load / store operations

Re: Compiler magic for preventing memory access re-ordering _by the compiler_ (keywords: memory model, compiler optimisations, memory order)

2017-11-05 Thread Michael V. Franklin via Digitalmars-d-learn
On Monday, 6 November 2017 at 03:40:23 UTC, Cecil Ward wrote: Is there a magic visible sign (or even one needed) in the D language that tells D _compilers_ not to move certain types of memory load / store operations forwards or backwards relative to other operations when optimising the code s

Re: Any book recommendation for writing a compiler?

2017-11-01 Thread Michael V. Franklin via Digitalmars-d-learn
On Wednesday, 1 November 2017 at 20:53:44 UTC, Dr. Assembly wrote: Hey guys, if I were to get into dmd's source code to play a little bit (just for fun, no commercial use at all), which books/resources do you recommend to start out? I found this to be quite helpful: http://llvm.org/docs/tutori

Re: Temporary objects as function parameters or when-is-this-shit-going-to-end?

2017-10-15 Thread Michael V. Franklin via Digitalmars-d-learn
On Monday, 16 October 2017 at 03:29:03 UTC, Michael V. Franklin wrote: My experience says that BountySource almost doesn't help. It works if the bounty is worth someone sacrificing their free time to do the work. For example, I'd attempt fixing the bug if the bounty were greater

Re: Temporary objects as function parameters or when-is-this-shit-going-to-end?

2017-10-15 Thread Michael V. Franklin via Digitalmars-d-learn
On Friday, 13 October 2017 at 11:54:38 UTC, Jack Applegame wrote: On Friday, 13 October 2017 at 11:21:48 UTC, Biotronic wrote: BountySource[2] lets you do basically exactly that. My experience says that BountySource almost doesn't help. It works if the bounty is worth someone sacrificing thei

Re: Simplest multithreading example

2017-08-31 Thread Michael Coulombe via Digitalmars-d-learn
On Friday, 1 September 2017 at 01:59:07 UTC, Brian wrote: Hello, I am trying to get the most trivial example of multithreading working, but can't seem to figure it out. I want to split a task across threads, and wait for all those tasks to finish before moving to the next line of code. The fol

Re: Comparison of Enumerations with base type of String?

2017-08-27 Thread Michael Reiland via Digitalmars-d-learn
whoa, you can use a struct as a basetype for an enum? I'm guessing it allows you to associate more information with the enum without using lookup tables and the like? And equality is probably just a memberwise comparison of the struct itself? That seems interesting like an interesting idea,

Re: Comparison of Enumerations with base type of String?

2017-08-26 Thread Michael Reiland via Digitalmars-d-learn
You can randomly assign a string to an enum? Or am I misunderstanding that last bit of code? Also it sounds to me like string enums are going to be slower performance wise than integer enums.

Comparison of Enumerations with base type of String?

2017-08-26 Thread Michael Reiland via Digitalmars-d-learn
Hey guys, I was running through a tutorial and I noticed that enums can have a base type of string. Which is interesting, but I'm wondering about comparisons. I'm guessing the comparison boils down to a pointer comparison, but I thought I'd confirm.

Re: html fetcher/parser

2017-08-12 Thread Michael via Digitalmars-d-learn
On Saturday, 12 August 2017 at 20:22:44 UTC, Adam D. Ruppe wrote: On Saturday, 12 August 2017 at 19:53:22 UTC, Faux Amis wrote: [...] My dom.d and http2.d combine to make this easy: https://github.com/adamdruppe/arsd/blob/master/dom.d https://github.com/adamdruppe/arsd/blob/master/http2.d [.

Re: Vectorflow noob

2017-08-11 Thread Michael via Digitalmars-d-learn
On Thursday, 10 August 2017 at 19:10:05 UTC, Jiyan wrote: Hey, wanted to the following simple thing with vectorflow: [...] I'm worried there might not be many on the forums who can help too much with vectorflow given how new it is. Maybe some in the community are more familiar with neural ne

Re: Why free and realloc seem to include .

2017-08-03 Thread Michael via Digitalmars-d-learn
On Thursday, 3 August 2017 at 15:29:29 UTC, Adam D. Ruppe wrote: On Thursday, 3 August 2017 at 15:18:17 UTC, Michael wrote: I've not seen that either, though I'm not a C++ programmer. Does using free() on its own not assume access of a global namespace? Consider the following:

Re: Why free and realloc seem to include .

2017-08-03 Thread Michael via Digitalmars-d-learn
On Thursday, 3 August 2017 at 14:15:40 UTC, Temtaime wrote: On Thursday, 3 August 2017 at 14:03:56 UTC, Michael wrote: So this might be a bit of a stupid question, but looking at the DMD source code (dmodule.d in particular) I see the following code: [...] and I was just wondering why

Why free and realloc seem to include .

2017-08-03 Thread Michael via Digitalmars-d-learn
So this might be a bit of a stupid question, but looking at the DMD source code (dmodule.d in particular) I see the following code: if (srcfile._ref == 0) .free(srcfile.buffer); srcfile.buffer = null; srcfile.len = 0; and I was just wondering why certain functions seem to be called using

Re: D for Web Development?

2017-06-09 Thread Michael Reiland via Digitalmars-d-learn
On Friday, 9 June 2017 at 15:07:03 UTC, Adam D. Ruppe wrote: // compile with the cgi.d, database.d, postgres.d, and dom.d library modules // and make sure your C libpq library is available. so on my computer, the // compile command is: // dmd webtest.d ~/arsd/{cgi,database,postgres,dom} -L-L/

Re: D for Web Development?

2017-06-09 Thread Michael Reiland via Digitalmars-d-learn
Thanks for the link to those resources, that'll definitely help giving me a broad overview, which for me is best. If I know something is there I can dive into the details when it becomes more important to what I'm doing. On Friday, 9 June 2017 at 03:34:20 UTC, Adam D. Ruppe wrote: anyway, if

D for Web Development?

2017-06-08 Thread Michael Reiland via Digitalmars-d-learn
Hey guys, I'm looking for a web solution that's: 1. Supported on Linux 2. Statically typed, 3. Reasonably performant, 4. Reasonably productive. 5. Simplicity (in terms of infrastructure and the language itself). The contenders as I see them are .Net Core, Go, and D. I know next to nothing a

Re: BinaryHeap crashes upon insertion if heapified with an array of length 1?

2017-04-09 Thread Michael Coulombe via Digitalmars-d-learn
On Sunday, 9 April 2017 at 00:36:00 UTC, TheGag96 wrote: I'm trying to use a binary heap initialized with one element. However, this always seems to cause a range violation for some reason. This small example will do it: import std.stdio, std.container; void main() { auto pq = heapify([5]);

Re: bug in foreach continue

2017-03-17 Thread Michael via Digitalmars-d-learn
On Friday, 17 March 2017 at 11:30:48 UTC, Jonathan M Davis wrote: On Friday, March 17, 2017 01:55:19 Hussien via Digitalmars-d-learn wrote: I tend to agree with this. If the foreach is static, and continue and break are just going to be ignored, then they should just be illegal. Allowing them

align(n) outside struct useless?

2017-02-20 Thread Michael Coulombe via Digitalmars-d-learn
I can't figure out how to set the alignment of a struct using align(n) on the outside of the struct. Only align on the fields (default or annotated) seems to work. I get the same results back to at least DMD 2.065... Is this a bug or am I using it wrong? align(32) struct A { ubyte padding; } p

Re: usage of ref foreach with variadic functions fails with "cannot be ref"

2017-02-11 Thread Michael Coulombe via Digitalmars-d-learn
On Saturday, 11 February 2017 at 15:02:11 UTC, error wrote: On Saturday, 11 February 2017 at 14:43:18 UTC, rikki cattermole wrote: Try: foreach(i, v; vars) { vars[i] = ...; } Perfect! Thanks so much - I wish that hint was in the documentation for variadic functions, although I guess

Re: Mallocator and 'shared'

2017-02-10 Thread Michael Coulombe via Digitalmars-d-learn
On Friday, 10 February 2017 at 23:57:18 UTC, bitwise wrote: https://github.com/dlang/phobos/blob/cd7846eb96ea7d2fa65ccb04b4ca5d5b0d1d4a63/std/experimental/allocator/mallocator.d#L63-L65 Looking at Mallocator, the use of 'shared' doesn't seem correct to me. The logic stated in the comment abov

Re: Quine using strings?

2017-01-15 Thread Michael Coulombe via Digitalmars-d-learn
A quine I came up with a while ago, using q{} string notation: enum s = q{enum s = q{%s}; void main() { import std.stdio; writefln(s,s); }}; void main() { import std.stdio; writefln(s,s); }

Best way to clear dynamic array for reuse

2016-12-28 Thread Michael Rynn via Digitalmars-d-learn
It takes a bit of work to get around the mutable buffers problem in D language arrays. I found it made a performance difference in xml parsing. https://github.com/betrixed/dlang-xml/blob/master/xml/util/buffer.d /** Buffer(T) - Versatile appendable D array for buffer reuse, append, re

Re: Reflection: Order of fields guaranteed?

2016-10-22 Thread Michael Coulombe via Digitalmars-d-learn
On Friday, 21 October 2016 at 01:51:44 UTC, Stefan Koch wrote: On Friday, 21 October 2016 at 01:34:44 UTC, Nick Sabalausky wrote: When using reflection to obtain the fields of a class/struct, is there any guarantee that the order is the same as the order the fields are defined? Yes they shoul

Re: D to C++

2016-08-31 Thread Michael via Digitalmars-d-learn
On Wednesday, 31 August 2016 at 11:43:12 UTC, Nick wrote: On Tuesday, 30 August 2016 at 14:24:22 UTC, eugene wrote: On Tuesday, 30 August 2016 at 13:33:44 UTC, Nick wrote: Is it possible to compile from D to C++? Explanation: I do some competition programming and would like to write it in D i

Retreive method given object, name and arguments

2016-08-11 Thread Michael Coulombe via Digitalmars-d-learn
Is there a way to implement "getSymbolOfCall" and "getDelegateOfCall" such that doit is functionally equivalent to calling the method directly? auto doit(C, string methodName, Args...)(C c, Args args) { alias methodSymbol = getSymbolOfCall!(c, methodName, Args); pragma(msg, hasUDA!(meth

Re: SortedRange.lowerBound from FrontTransversal

2016-08-07 Thread Michael Coulombe via Digitalmars-d-learn
On Monday, 8 August 2016 at 00:57:41 UTC, Michael Coulombe wrote: ... And looking at the source, the reason it fails when using TransverseOptions.assumeNotJagged is that it does not implement length or $. I made this into an enhancement request: https://issues.dlang.org/show_bug.cgi?id

Re: SortedRange.lowerBound from FrontTransversal

2016-08-07 Thread Michael Coulombe via Digitalmars-d-learn
On Saturday, 6 August 2016 at 23:00:42 UTC, Alex wrote: Hi all... a technical question from my side... why the last line of the following gives the error? import std.stdio; import std.range; import std.algorithm; void main() { size_t[][] darr; darr.length = 2; darr[0] = [0, 1, 2, 3]

Re: Static ternary if

2016-07-25 Thread Michael Coulombe via Digitalmars-d-learn
On Monday, 25 July 2016 at 22:57:05 UTC, Gorge Jingale wrote: On Monday, 25 July 2016 at 22:27:11 UTC, Cauterite wrote: On Monday, 25 July 2016 at 02:15:12 UTC, Gorge Jingale wrote: Is there a static ternary if? (A == B) ? C : D; for compile type that works like static if. You can pretty ea

Re: Variadic Tuple of Structs with Mixed Types

2016-07-15 Thread Michael Coulombe via Digitalmars-d-learn
On Friday, 15 July 2016 at 17:00:09 UTC, jmh530 wrote: I was working with the lightweight wrapper and it seemed to work for simple stuff, but then I started getting a bunch of errors when I tried to integrate it in to my project. Below is the stripped down version of what I've been working wi

Re: Typesafe variadic functions requiring at least one argument

2016-07-07 Thread Michael Coulombe via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 19:50:11 UTC, pineapple wrote: I'd like to do something like this but it doesn't seem to be legal - void test(int[] ints...) if(ints.length){ // stuff } Not being able to specify this interferes with how I'd like to define my method overloads. What

Re: Using -O with DMD seems to produce non-random values.

2016-05-19 Thread Michael via Digitalmars-d-learn
On Thursday, 19 May 2016 at 15:49:17 UTC, ag0aep6g wrote: On 05/19/2016 05:09 PM, Michael wrote: Any idea what causes this to occur when optimising? I wanted to try and speed up a simulation I'm running but it just produces too many unexpected consequences. I suspect that you're se

Re: Using -O with DMD seems to produce non-random values.

2016-05-19 Thread Michael via Digitalmars-d-learn
Could it be that the code is optimised to the same as that in the original issue and so the current compiler still produces the incorrect result? Obviously the original issue has since been fixed but I won't be able to test this until the next version of DMD is released.

Using -O with DMD seems to produce non-random values.

2016-05-19 Thread Michael via Digitalmars-d-learn
I'm not entirely sure what optimisations are made when supplying the -O flag to rdmd, but this may be related to an earlier issue I found for similar code here: https://issues.dlang.org/show_bug.cgi?id=16027 The code is: void main() { auto seed = 128; auto rand = Random(seed);

Re: Using shorthand *= leads to unexpected result?

2016-05-15 Thread Michael via Digitalmars-d-learn
On Sunday, 15 May 2016 at 14:12:47 UTC, Marc Schütz wrote: On Sunday, 15 May 2016 at 13:01:45 UTC, Michael wrote: It may be that I'm doing something wrong here, but after updating DMD to the latest version, my simulations started producing some very odd results and I think I've pin

Re: Using shorthand *= leads to unexpected result?

2016-05-15 Thread Michael via Digitalmars-d-learn
On Sunday, 15 May 2016 at 13:12:44 UTC, Saurabh Das wrote: On Sunday, 15 May 2016 at 13:01:45 UTC, Michael wrote: It may be that I'm doing something wrong here, but after updating DMD to the latest version, my simulations started producing some very odd results and I think I've pin

Using shorthand *= leads to unexpected result?

2016-05-15 Thread Michael via Digitalmars-d-learn
It may be that I'm doing something wrong here, but after updating DMD to the latest version, my simulations started producing some very odd results and I think I've pinpointed it to a sign inversion that I was making. Here is some code from dpaste to demonstrate the behaviour I get vs. the beha

  1   2   3   >