Re: in not working for arrays is silly, change my view

2020-02-29 Thread Ali Çehreli via Digitalmars-d-learn
On 2/29/20 11:38 AM, JN wrote: > assert(1 in [1, 2, 3]); Because you mentioned canFind, I think you want the semantics to be "is there an element with this value." If so, it would be confusing to use the same operator for two different things: For associative arrays, it means "is there an

Re: in not working for arrays is silly, change my view

2020-02-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/29/20 2:38 PM, JN wrote: assert(1 in [1, 2, 3]); Error: incompatible types for (1) in ([1, 2, 3]): int and int[ Yes, I know about .canFind(), but this is something that trips people over and over. I think it would be better if "in" worked for both assoc arrays and normal arrays, or

Re: Should getSymbolsByUDA work with member variables?

2020-02-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/28/20 1:34 PM, cc wrote: This compiles: class Foo { int x; @(1) void y() {} this() {     static foreach (idx, field; getSymbolsByUDA!(Foo, 1)) {     } } } This does not: class Foo { @(1) int x; void y() {} this() {     static foreach

in not working for arrays is silly, change my view

2020-02-29 Thread JN via Digitalmars-d-learn
assert(1 in [1, 2, 3]); Error: incompatible types for (1) in ([1, 2, 3]): int and int[ Yes, I know about .canFind(), but this is something that trips people over and over. I think it would be better if "in" worked for both assoc arrays and normal arrays, or didn't work at all, for added

Re: Using std.net.curl

2020-02-29 Thread David Anderson via Digitalmars-d-learn
On Saturday, 29 February 2020 at 07:35:10 UTC, Boris Carvajal wrote: On Saturday, 29 February 2020 at 03:53:37 UTC, David Anderson wrote: I want to capture that text in a variable, but the upload function returns void. How can I get the text returned by the web server to be stored in a

Re: How to sum multidimensional arrays?

2020-02-29 Thread p.shkadzko via Digitalmars-d-learn
On Friday, 28 February 2020 at 16:51:10 UTC, AB wrote: On Thursday, 27 February 2020 at 14:15:26 UTC, p.shkadzko wrote: [...] Your Example with a minimal 2D array. module test2; import std.random : Xorshift, unpredictableSeed, uniform; import std.range : generate, take, chunks;

Re: can't run D app on VS 2019

2020-02-29 Thread Виталий Фадеев via Digitalmars-d-learn
On Thursday, 27 February 2020 at 11:29:01 UTC, Greatsam4aure wrote: I have install Vs 2019 and install the C++ package together with Visual-D bundle with DMD and LDC. But by project refuse to run [...] user32.lib - this file in C:\D\dmd2\windows ( on my PC, on you it other ) LINK : fatal

Re: Call method if declared only

2020-02-29 Thread Виталий Фадеев via Digitalmars-d-learn
On Friday, 28 February 2020 at 12:21:41 UTC, Simen Kjærås wrote: On Friday, 28 February 2020 at 10:33:11 UTC, Виталий Фадеев wrote: Thanks all ! I happy ! Check this one: void On( T, M )( T o, M message ) { [snip] void main() { auto a = new A(); a.Send( a,

Re: Idiomatic way to express errors without resorting to exceptions

2020-02-29 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 29 February 2020 at 13:40:11 UTC, Adnan wrote: On Saturday, 29 February 2020 at 13:03:21 UTC, Sebastiaan Koppe wrote: On Saturday, 29 February 2020 at 12:50:59 UTC, Adnan wrote: * Option!T from the optional package: Has even worse problem IMO. Not only it allows None + int but

Re: Idiomatic way to express errors without resorting to exceptions

2020-02-29 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 29 February 2020 at 13:40:11 UTC, Adnan wrote: On Saturday, 29 February 2020 at 13:03:21 UTC, Sebastiaan Koppe wrote: On Saturday, 29 February 2020 at 12:50:59 UTC, Adnan wrote: * Option!T from the optional package: Has even worse problem IMO. Not only it allows None + int but

Re: Idiomatic way to express errors without resorting to exceptions

2020-02-29 Thread Basile B. via Digitalmars-d-learn
On Saturday, 29 February 2020 at 12:50:59 UTC, Adnan wrote: I have a struct that has to arrays. Each of those must have the same sizes. So while constructing the array, if you pass two arrays of different sizes the constructor must return nothing. In Rust I could easily use Option. D has no

Re: Idiomatic way to express errors without resorting to exceptions

2020-02-29 Thread Adnan via Digitalmars-d-learn
On Saturday, 29 February 2020 at 13:03:21 UTC, Sebastiaan Koppe wrote: On Saturday, 29 February 2020 at 12:50:59 UTC, Adnan wrote: * Option!T from the optional package: Has even worse problem IMO. Not only it allows None + int but also it returns a `[]`. This API is not to my liking. You could

Re: Idiomatic way to express errors without resorting to exceptions

2020-02-29 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 29 February 2020 at 12:50:59 UTC, Adnan wrote: * Option!T from the optional package: Has even worse problem IMO. Not only it allows None + int but also it returns a `[]`. This API is not to my liking. You could say well Haskell has fmap for Optional etc, and I am aware of that, so

Idiomatic way to express errors without resorting to exceptions

2020-02-29 Thread Adnan via Digitalmars-d-learn
I have a struct that has to arrays. Each of those must have the same sizes. So while constructing the array, if you pass two arrays of different sizes the constructor must return nothing. In Rust I could easily use Option. D has no answer to Optional types as far as I am concerned. Is