Re: "Disappearing" operator methods

2016-09-29 Thread Robert Rat via Digitalmars-d
On Thursday, 29 September 2016 at 12:28:54 UTC, Tomer Filiba wrote: Consider this code struct MyTable { bool opBinaryRight(string op: "in")(int x) { return true; } } Now let's use it: MyTable m1; assert(5 in m1); Everything works as expected. Now suppose I had a const object

Re: Allow Explicit Pointer for Auto Declaration

2016-09-29 Thread Steven Schveighoffer via Digitalmars-d
On 9/29/16 9:48 PM, Jacob wrote: It still requires the &, what it prevents is this situation: auto pValue = expr; // wanted pointer, expr evaluates to non-ptr value through change of code or simply forgetting "&" Wait, what happens when you do that? If that's now an error, this is a non-start

Re: The XML and JSON library

2016-09-29 Thread Nick Sabalausky via Digitalmars-d
On 09/29/2016 04:14 PM, Szabo Bogdan wrote: On Thursday, 29 September 2016 at 14:46:10 UTC, Nick Sabalausky wrote: On 09/28/2016 05:40 PM, Szabo Bogdan wrote: How about Json... there is something that is stopping the D community to move the `vibe.data.json` to `phobos`? Why does it need to

Re: Allow Explicit Pointer for Auto Declaration

2016-09-29 Thread Jacob via Digitalmars-d
On Friday, 30 September 2016 at 03:07:41 UTC, Mike Parker wrote: On Friday, 30 September 2016 at 01:48:02 UTC, Jacob wrote: auto* pValue = expr; // still invalid code unless expr evaluate to a pointer type auto* pValue = &expr; // this is valid if expr is a ref It still requires the &, what

Re: Allow Explicit Pointer for Auto Declaration

2016-09-29 Thread Mike Parker via Digitalmars-d
On Friday, 30 September 2016 at 01:48:02 UTC, Jacob wrote: auto* pValue = expr; // still invalid code unless expr evaluate to a pointer type auto* pValue = &expr; // this is valid if expr is a ref It still requires the &, what it prevents is this situation: auto pValue = expr; // wanted poin

Re: Allow Explicit Pointer for Auto Declaration

2016-09-29 Thread Jacob via Digitalmars-d
On Friday, 30 September 2016 at 00:05:45 UTC, Steven Schveighoffer wrote: On 9/29/16 7:42 PM, Jacob wrote: Was wondering if this feature could be implemented, right now auto needs to be written like this: auto pValue = someFunctionReturnsRef(); // forgot '&', still valid

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Chris Wright via Digitalmars-d
On Thu, 29 Sep 2016 10:41:38 +0200, Timon Gehr wrote: > On 29.09.2016 06:15, Walter Bright wrote: >> On 9/28/2016 1:40 PM, Timon Gehr wrote: >>> (This is NOT expression templates.) >> >> Right, but it's an enabler of expression templates. Discussion of more >> powerful operator overloading cannot

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Chris Wright via Digitalmars-d
On Thu, 29 Sep 2016 17:50:54 -0700, Jonathan M Davis via Digitalmars-d wrote: > Except that it kind of is. It's an example of a language allowing you to > mess with too much and make it so that it doesn't function as expected, > which is what happens when you overload operators to act in a way > i

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Jonathan M Davis via Digitalmars-d
On Thursday, September 29, 2016 22:37:51 Minty Fresh via Digitalmars-d wrote: > On Thursday, 29 September 2016 at 22:27:50 UTC, bachmeier wrote: > > You're looking for https://www.perl.org/ That's a highly viable > > language, where you can do things like bury $[ = 1 somewhere in > > your code to c

Re: Allow Explicit Pointer for Auto Declaration

2016-09-29 Thread Steven Schveighoffer via Digitalmars-d
On 9/29/16 7:42 PM, Jacob wrote: Was wondering if this feature could be implemented, right now auto needs to be written like this: auto pValue = someFunctionReturnsRef(); // forgot '&', still valid // makes a copy when we didn't want one The featu

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread bachmeier via Digitalmars-d
On Thursday, 29 September 2016 at 22:37:51 UTC, Minty Fresh wrote: On Thursday, 29 September 2016 at 22:27:50 UTC, bachmeier wrote: You're looking for https://www.perl.org/ That's a highly viable language, where you can do things like bury $[ = 1 somewhere in your code to change from 0-indexing

Allow Explicit Pointer for Auto Declaration

2016-09-29 Thread Jacob via Digitalmars-d
Was wondering if this feature could be implemented, right now auto needs to be written like this: auto pValue = someFunctionReturnsRef(); // forgot '&', still valid // makes a copy when we didn't want one The feature would make the code look li

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Minty Fresh via Digitalmars-d
On Thursday, 29 September 2016 at 22:27:50 UTC, bachmeier wrote: You're looking for https://www.perl.org/ That's a highly viable language, where you can do things like bury $[ = 1 somewhere in your code to change from 0-indexing to 1-indexing of arrays. They take pride in unpredictable, unreada

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread bachmeier via Digitalmars-d
On Thursday, 29 September 2016 at 20:16:00 UTC, pineapple wrote: I repeat: Your thinking like this limits D's viability for real-world code. You're looking for https://www.perl.org/ That's a highly viable language, where you can do things like bury $[ = 1 somewhere in your code to change from

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
On Thursday, 29 September 2016 at 22:03:36 UTC, ag0aep6g wrote: On 09/29/2016 11:28 PM, Ilya Yaroshenko wrote: [...] [...] [...] When the values themselves are known at compile time, we can convert them to size_t before generating the function: enum isIndex(T) = is(T == size_t); /* b

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread ag0aep6g via Digitalmars-d
On 09/29/2016 11:28 PM, Ilya Yaroshenko wrote: On Thursday, 29 September 2016 at 20:57:00 UTC, ag0aep6g wrote: [...] void foo(size_t n)(size_t[n] a ...) { /* ... */ } Just found an example, where this approach does not work :-( template transposed(Dimensions...) if (Dimensions.length) {

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
On Thursday, 29 September 2016 at 21:31:11 UTC, Timothee Cour wrote: maybe remove the corresponding DIP from https://github.com/libmir/mir/wiki/Compiler-and-druntime-bugs#dips ? On Thu, Sep 29, 2016 at 2:19 PM, Ilya Yaroshenko via Digitalmars-d < digitalmars-d@puremagic.com> wrote: On Thursd

Re: The XML and JSON library

2016-09-29 Thread cym13 via Digitalmars-d
On Thursday, 29 September 2016 at 20:14:27 UTC, Szabo Bogdan wrote: On Thursday, 29 September 2016 at 14:46:10 UTC, Nick Sabalausky wrote: [...] Well... the json format can be used in a lot of cases not only for the web and I think it does not make much sense to include a web framework in or

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Timothee Cour via Digitalmars-d
maybe remove the corresponding DIP from https://github.com/libmir/mir/wiki/Compiler-and-druntime-bugs#dips ? On Thu, Sep 29, 2016 at 2:19 PM, Ilya Yaroshenko via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > On Thursday, 29 September 2016 at 21:06:13 UTC, Timothee Cour wrote: > >> this wo

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
On Thursday, 29 September 2016 at 20:57:00 UTC, ag0aep6g wrote: On 09/29/2016 10:43 PM, Ilya Yaroshenko wrote: On Thursday, 29 September 2016 at 20:12:44 UTC, Walter Bright wrote: [...] void foo(T)(T[] a ...) { printf("%d %d %d\n", a[0], a[1], a[2]); } [...] a.length must be known at CT

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
On Thursday, 29 September 2016 at 21:06:13 UTC, Timothee Cour wrote: this works: void foo(T, size_t n)(T[n] a ...) {...} However, see this: https://github.com/libmir/mir/issues/337 On Thu, Sep 29, 2016 at 1:57 PM, Ilya Yaroshenko via Digitalmars-d < digitalmars-d@puremagic.com> wrote: On T

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
On Thursday, 29 September 2016 at 20:57:00 UTC, ag0aep6g wrote: On 09/29/2016 10:43 PM, Ilya Yaroshenko wrote: On Thursday, 29 September 2016 at 20:12:44 UTC, Walter Bright wrote: [...] void foo(T)(T[] a ...) { printf("%d %d %d\n", a[0], a[1], a[2]); } [...] a.length must be known at CT

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Timothee Cour via Digitalmars-d
this works: void foo(T, size_t n)(T[n] a ...) {...} However, see this: https://github.com/libmir/mir/issues/337 On Thu, Sep 29, 2016 at 1:57 PM, Ilya Yaroshenko via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > On Thursday, 29 September 2016 at 20:54:12 UTC, Ilya Yaroshenko wrote: > >>

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
On Thursday, 29 September 2016 at 20:54:12 UTC, Ilya Yaroshenko wrote: On Thursday, 29 September 2016 at 20:47:35 UTC, Andrei Alexandrescu wrote: Ilya Yaroshenko wrote: On Thursday, 29 September 2016 at 18:55:07 UTC, Andrei Alexandrescu wrote: [...] This is the same like in current ndslice

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread ag0aep6g via Digitalmars-d
On 09/29/2016 10:43 PM, Ilya Yaroshenko wrote: On Thursday, 29 September 2016 at 20:12:44 UTC, Walter Bright wrote: [...] void foo(T)(T[] a ...) { printf("%d %d %d\n", a[0], a[1], a[2]); } [...] a.length must be known at CT. 99%-100% foreach loops in ndslice package are CT. I'm not sur

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
On Thursday, 29 September 2016 at 20:47:35 UTC, Andrei Alexandrescu wrote: Ilya Yaroshenko wrote: On Thursday, 29 September 2016 at 18:55:07 UTC, Andrei Alexandrescu wrote: On 09/29/2016 02:53 PM, Ilya Yaroshenko wrote: `(Index...)` -> `(size_t[] Index...)` // this is about template argument

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Jonathan M Davis via Digitalmars-d
On Thursday, September 29, 2016 20:16:00 pineapple via Digitalmars-d wrote: > On Thursday, 29 September 2016 at 19:39:35 UTC, Jonathan M Davis > > wrote: > > The reality of the matter is that D's operator overloading was > > designed specifically so that you could overload the built-in > > operator

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Andrei Alexandrescu via Digitalmars-d
Ilya Yaroshenko wrote: > On Thursday, 29 September 2016 at 18:55:07 UTC, Andrei > Alexandrescu wrote: >> On 09/29/2016 02:53 PM, Ilya Yaroshenko wrote: >>> `(Index...)` -> `(size_t[] Index...)` // this is about template >>> arguments, not runtime >> >> What is the drawback of taking Index... and

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
On Thursday, 29 September 2016 at 20:12:44 UTC, Walter Bright wrote: Here's one way to do it: -- import core.stdc.stdio; void foo(T)(T[] a ...) { printf("%d %d %d\n", a[0], a[1], a[2]); } void main() { foo(1, 2, 3); } - C:\cbx>foo 1 2 3 a.length must be known at CT. 99%-100% f

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread pineapple via Digitalmars-d
On Thursday, 29 September 2016 at 19:39:35 UTC, Jonathan M Davis wrote: The reality of the matter is that D's operator overloading was designed specifically so that you could overload the built-in operators to be used with your own types so that they could act like the built-in types. It was no

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Walter Bright via Digitalmars-d
Here's one way to do it: -- import core.stdc.stdio; void foo(T)(T[] a ...) { printf("%d %d %d\n", a[0], a[1], a[2]); } void main() { foo(1, 2, 3); } - C:\cbx>foo 1 2 3

Re: The XML and JSON library

2016-09-29 Thread Szabo Bogdan via Digitalmars-d
On Thursday, 29 September 2016 at 14:46:10 UTC, Nick Sabalausky wrote: On 09/28/2016 05:40 PM, Szabo Bogdan wrote: How about Json... there is something that is stopping the D community to move the `vibe.data.json` to `phobos`? Why does it need to be in phobos? It's already usable as-is. O

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Minty Fresh via Digitalmars-d
On Thursday, 29 September 2016 at 19:39:35 UTC, Jonathan M Davis wrote: The language can't stop you from doing at least some arbitrary stuff with them (like making + do subtraction), but the whole goal was for user-defined types to be able to act like the built-in types, and as such, it would m

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Timon Gehr via Digitalmars-d
On 29.09.2016 18:41, Sai wrote: I.e. you can overload '+' to do bad things. Yes, you can, and as I replied upthread that can be done because there's no way to prevent that while having operator overloading at all. But that is not justification for allowing such disasters for the comparison opera

Re: DIP 1002 (TryElseExpression) added to the queue

2016-09-29 Thread Timon Gehr via Digitalmars-d
On 29.09.2016 19:35, Walter Bright wrote: On 9/29/2016 7:32 AM, Andrei Alexandrescu wrote: A DIP should stay as far away from this kind of argument as possible. Redundancy of existing features should not be used as precedent and justification for adding another redundant feature. More generall

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Jonathan M Davis via Digitalmars-d
On Thursday, September 29, 2016 19:11:55 pineapple via Digitalmars-d wrote: > On Thursday, 29 September 2016 at 18:38:42 UTC, Jonathan M Davis > > wrote: > > You just can't use overloaded operators for it, since it would > > not be in line with what the operators are supposed to mean and > > be use

Re: The worst Phobos template (in binderoo)

2016-09-29 Thread Andrei Alexandrescu via Digitalmars-d
On 09/29/2016 03:27 PM, Timon Gehr wrote: On 16.09.2016 01:10, Andrei Alexandrescu wrote: On 9/15/16 7:08 PM, Andrei Alexandrescu wrote: Yes, that DIP. It would need some more formal work before defining an implementation. Stefan, would you want to lead that effort? -- Andrei Actually I see T

Re: The worst Phobos template (in binderoo)

2016-09-29 Thread Timon Gehr via Digitalmars-d
On 16.09.2016 01:25, Stefan Koch wrote: On Thursday, 15 September 2016 at 23:08:54 UTC, Andrei Alexandrescu wrote: Yes, that DIP. It would need some more formal work before defining an implementation. Stefan, would you want to lead that effort? -- Andrei I am not good at defining semantics, y

Re: The worst Phobos template (in binderoo)

2016-09-29 Thread Timon Gehr via Digitalmars-d
On 16.09.2016 01:10, Andrei Alexandrescu wrote: On 9/15/16 7:08 PM, Andrei Alexandrescu wrote: Yes, that DIP. It would need some more formal work before defining an implementation. Stefan, would you want to lead that effort? -- Andrei Actually I see Timon authored that (I thought it's an older

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Minty Fresh via Digitalmars-d
On Thursday, 29 September 2016 at 19:11:55 UTC, pineapple wrote: Relinquish the notion that you or anyone can have the slightest idea what any language feature is "supposed to mean and be used for". Basically what led to D's CTFE implementation in the first place, IIRC.

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread pineapple via Digitalmars-d
On Thursday, 29 September 2016 at 18:38:42 UTC, Jonathan M Davis wrote: You just can't use overloaded operators for it, since it would not be in line with what the operators are supposed to mean and be used for. This is not a valid argument because what an operator is "supposed to mean" is up

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread pineapple via Digitalmars-d
On Thursday, 29 September 2016 at 18:56:40 UTC, Ilya Yaroshenko wrote: No, it does not --- void foo(size_t[] I...)(I i) { } Using phobos' allSatisfy or a similar template, this can become: enum isIndex(T) = is(T == size_t); void foo(I...)(I i) if(allSatisfy!(isIndex, I)){ ...

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
On Thursday, 29 September 2016 at 19:03:00 UTC, pineapple wrote: On Thursday, 29 September 2016 at 18:56:40 UTC, Ilya Yaroshenko wrote: No, it does not --- void foo(size_t[] I...)(I i) { } Using phobos' allSatisfy or a similar template, this can become: enum isIndex(T) = is(T ==

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
On Thursday, 29 September 2016 at 18:55:07 UTC, Andrei Alexandrescu wrote: On 09/29/2016 02:53 PM, Ilya Yaroshenko wrote: `(Index...)` -> `(size_t[] Index...)` // this is about template arguments, not runtime What is the drawback of taking Index... and constraining it with a template constrai

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Matthias Bentrup via Digitalmars-d
On Thursday, 29 September 2016 at 18:38:42 UTC, Jonathan M Davis wrote: Then you could always do something like a.myOp!"<"(b) and a.myOp!">="(b) if you still want to have the operator in there somewhere. You can name the functions whatever you want. You just can't use overloaded operators for

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
On Thursday, 29 September 2016 at 18:53:26 UTC, Andrei Alexandrescu wrote: On 09/29/2016 02:37 PM, Ilya Yaroshenko wrote: On Thursday, 29 September 2016 at 17:56:59 UTC, Stefan Koch wrote: Solution T[] can be added to a template variadic name. ``` void foo(size_t[] Index...)(Indexes index) {

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Steven Schveighoffer via Digitalmars-d
On 9/29/16 2:49 PM, Stefan Koch wrote: On Thursday, 29 September 2016 at 18:37:36 UTC, Ilya Yaroshenko wrote: On Thursday, 29 September 2016 at 17:56:59 UTC, Stefan Koch wrote: Solution T[] can be added to a template variadic name. ``` void foo(size_t[] Index...)(Indexes index) { ... } ``

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Andrei Alexandrescu via Digitalmars-d
On 09/29/2016 02:53 PM, Ilya Yaroshenko wrote: `(Index...)` -> `(size_t[] Index...)` // this is about template arguments, not runtime What is the drawback of taking Index... and constraining it with a template constraint (all must be integral)? We use that in a few places in Phobos. -- Andrei

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
On Thursday, 29 September 2016 at 18:49:45 UTC, Stefan Koch wrote: On Thursday, 29 September 2016 at 18:37:36 UTC, Ilya Yaroshenko wrote: On Thursday, 29 September 2016 at 17:56:59 UTC, Stefan Koch wrote: Solution T[] can be added to a template variadic name. ``` void foo(size_t[] Index...)(I

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Andrei Alexandrescu via Digitalmars-d
On 09/29/2016 02:37 PM, Ilya Yaroshenko wrote: On Thursday, 29 September 2016 at 17:56:59 UTC, Stefan Koch wrote: Solution T[] can be added to a template variadic name. ``` void foo(size_t[] Index...)(Indexes index) { ... } ``` This description does not tell me anything. Current templa

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Stefan Koch via Digitalmars-d
On Thursday, 29 September 2016 at 18:37:36 UTC, Ilya Yaroshenko wrote: On Thursday, 29 September 2016 at 17:56:59 UTC, Stefan Koch wrote: Solution T[] can be added to a template variadic name. ``` void foo(size_t[] Index...)(Indexes index) { ... } ``` This description does not tell me an

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
On Thursday, 29 September 2016 at 17:56:59 UTC, Stefan Koch wrote: Solution T[] can be added to a template variadic name. ``` void foo(size_t[] Index...)(Indexes index) { ... } ``` This description does not tell me anything. Current template argument can be declared as `(Index...)`. The

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Jonathan M Davis via Digitalmars-d
On Thursday, September 29, 2016 18:14:22 Minty Fresh via Digitalmars-d wrote: > On Thursday, 29 September 2016 at 18:07:37 UTC, Russel Winder > > wrote: > > On Thu, 2016-09-29 at 10:52 -0700, Walter Bright via > > > > Digitalmars-d wrote: > >> On 9/29/2016 9:41 AM, Sai wrote: > >> > If I understand

dmd --fileprefix=$PWD/ to show custom file prefix before error messages

2016-09-29 Thread Timothee Cour via Digitalmars-d
I'd like to be able to customize rendering of files (eg in error messages) output by dmd, eg: dmd XXX foo/bar.d: Warning: statement is unreachable dmd --fileprefix=mydir/ XXX mydir/foo/bar.d: Warning: statement is unreachable this makes it easy to allow user to see where errors came from even af

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Minty Fresh via Digitalmars-d
On Thursday, 29 September 2016 at 18:07:37 UTC, Russel Winder wrote: On Thu, 2016-09-29 at 10:52 -0700, Walter Bright via Digitalmars-d wrote: On 9/29/2016 9:41 AM, Sai wrote: > > If I understand the issue correctly, one will not be able to > overload <=, >, etc > for symbolic math, like CAS (

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Russel Winder via Digitalmars-d
On Thu, 2016-09-29 at 10:52 -0700, Walter Bright via Digitalmars-d wrote: > On 9/29/2016 9:41 AM, Sai wrote: > > > > If I understand the issue correctly, one will not be able to > > overload <=, >, etc > > for symbolic math, like CAS (mimicking mathematica for example), > > how can I do it > > now

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Stefan Koch via Digitalmars-d
On Thursday, 29 September 2016 at 17:24:55 UTC, Ilya Yaroshenko wrote: Problem Most ndslice API accepts variadic list of integers. The following code example shows how `slice` and `[a, b, c]` can generate 64 identical functions each. ``` // (1, 1U, 1UL, 1L) x // (2, 2U, 2UL, 2L) x // (3, 3U, 3U

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Walter Bright via Digitalmars-d
On 9/29/2016 9:41 AM, Sai wrote: If I understand the issue correctly, one will not be able to overload <=, >, etc for symbolic math, like CAS (mimicking mathematica for example), how can I do it now? a.isLessThan(b)

Re: DIP 1002 (TryElseExpression) added to the queue

2016-09-29 Thread Walter Bright via Digitalmars-d
On 9/29/2016 4:45 AM, Marc Schütz wrote: And `Foo` could have `@disabled this()`, so you simply _can't_ declare it without initializing it Foo foo = void;

Re: DIP 1002 (TryElseExpression) added to the queue

2016-09-29 Thread Walter Bright via Digitalmars-d
On 9/29/2016 7:32 AM, Andrei Alexandrescu wrote: A DIP should stay as far away from this kind of argument as possible. Redundancy of existing features should not be used as precedent and justification for adding another redundant feature. More generally, a problem with existing feature X is not

Re: Linking D code into existing C programs

2016-09-29 Thread Walter Bright via Digitalmars-d
On 9/26/2016 4:32 PM, Walter Bright wrote: Produces: bar.o:(.eh_frame+0x13): undefined reference to `__dmd_personality_v0' I fixed this for Linux and OSX: https://github.com/dlang/dmd/pull/6159 There is apparently some issue with the gnu toolchain on FreeBSD which prevents this improv

Re: DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
https://github.com/libmir/mir/wiki/Compiler-and-druntime-bugs#dips

DIP Mir1 Draft: Variadic template parameters with the same time.

2016-09-29 Thread Ilya Yaroshenko via Digitalmars-d
Problem Most ndslice API accepts variadic list of integers. The following code example shows how `slice` and `[a, b, c]` can generate 64 identical functions each. ``` // (1, 1U, 1UL, 1L) x // (2, 2U, 2UL, 2L) x // (3, 3U, 3UL, 3L) = 4 ^^ 3 = 64 identical variants auto cube = slice!double(1, 2, 3

Re: Parameterized delegate attributes

2016-09-29 Thread Steven Schveighoffer via Digitalmars-d
On 9/28/16 5:35 PM, Lodovico Giaretta wrote: On Wednesday, 28 September 2016 at 20:23:10 UTC, pineapple wrote: But using a templated opApply currently breaks type inference in `foreach`, right? It'd be really nice if that were fixed. Yeah, it would be nice, but I don't think it's technically

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Sai via Digitalmars-d
I.e. you can overload '+' to do bad things. Yes, you can, and as I replied upthread that can be done because there's no way to prevent that while having operator overloading at all. But that is not justification for allowing such disasters for the comparison operators. I.e. one weakness is not

Re: The worst Phobos template (in binderoo)

2016-09-29 Thread Stefan Koch via Digitalmars-d
On Thursday, 29 September 2016 at 16:30:56 UTC, Eugene Wissner wrote: The problem is you can never know all the use cases of some feature. It is just pointless to try to predict where a user will need a feature. I had a use case where I could be sure that everything needed is imported and whe

Re: The worst Phobos template (in binderoo)

2016-09-29 Thread Eugene Wissner via Digitalmars-d
On Thursday, 29 September 2016 at 16:02:53 UTC, David Nadlinger wrote: This wouldn't be a correct use of the feature anyway, since it runs into all sorts of fundamental issues with imports/scoping, aliases and templates. Using .stringof/fullyQualifiedName to generate a reference to a type or

Re: "Disappearing" operator methods

2016-09-29 Thread Yuxuan Shui via Digitalmars-d
On Thursday, 29 September 2016 at 14:34:18 UTC, Marc Schütz wrote: Please have a look at this PR: https://github.com/dlang/dmd/pull/6140 However, the error message printed with this PR isn't particularly helpful either: Error: incompatible types for ((5) in (m2)): 'int' and 'const(MyTable)'

Re: The worst Phobos template (in binderoo)

2016-09-29 Thread Eugene Wissner via Digitalmars-d
On Thursday, 29 September 2016 at 14:49:03 UTC, Stefan Koch wrote: The reason why this fails is because of the cast(Flag) which should be cast(Flag!"unsafe"). I can probably make it work tough, that means more special casing :) Yes, I know. See this topic for the first discussion: http://forum

Re: The worst Phobos template (in binderoo)

2016-09-29 Thread David Nadlinger via Digitalmars-d
On Thursday, 29 September 2016 at 13:58:44 UTC, Eugene Wissner wrote: Any chance to get this one working: import std.typecons; enum Stuff { asdf, } void main() { BitFlags!Stuff a; mixin(__traits(fullyQualifiedName, typeof(a)) ~ " c;"); } This wouldn't be a correct use

Re: Linking D code into existing C programs

2016-09-29 Thread David Soria Parra via Digitalmars-d
On Monday, 26 September 2016 at 23:32:05 UTC, Walter Bright wrote: How much of an issue is this with D? Is it something we need to address? I've run into this problem a few times and it took me a while to understand how to correctly initialize the druntime (including attaching pthreads), when

Re: The worst Phobos template (in binderoo)

2016-09-29 Thread Stefan Koch via Digitalmars-d
On Thursday, 29 September 2016 at 13:58:44 UTC, Eugene Wissner wrote: On Wednesday, 14 September 2016 at 20:28:13 UTC, Stefan Koch wrote: On Wednesday, 14 September 2016 at 20:24:13 UTC, Stefan Koch wrote: I would like to see users of fullyQualifiedName because apart from binderoo code which

Re: The XML and JSON library

2016-09-29 Thread Nick Sabalausky via Digitalmars-d
On 09/28/2016 05:40 PM, Szabo Bogdan wrote: How about Json... there is something that is stopping the D community to move the `vibe.data.json` to `phobos`? Why does it need to be in phobos? It's already usable as-is. Only libraries within a std lib are valid?

Re: "Disappearing" operator methods

2016-09-29 Thread Marc Schütz via Digitalmars-d
Please have a look at this PR: https://github.com/dlang/dmd/pull/6140 However, the error message printed with this PR isn't particularly helpful either: Error: incompatible types for ((5) in (m2)): 'int' and 'const(MyTable)' You might want to add a comment there, and/or open an enhancement r

Re: DIP 1002 (TryElseExpression) added to the queue

2016-09-29 Thread Andrei Alexandrescu via Digitalmars-d
On 09/28/2016 04:21 PM, pineapple wrote: On Wednesday, 28 September 2016 at 20:18:06 UTC, pineapple wrote: This is not and was not intended to be a glorious, incredible addition to the language. It is meant to shove D a couple inches further in the direction of modern programming constructs. Eve

Re: DIP 1002 (TryElseExpression) added to the queue

2016-09-29 Thread Andrei Alexandrescu via Digitalmars-d
On 09/29/2016 09:00 AM, pineapple wrote: One thing I'd point out: You rewrote my rewritten examples without using `else`, but as was stated immediately before I listed those examples: The best examples of code that can be more elegantly written using this `else` clause occur in application logi

Re: The worst Phobos template (in binderoo)

2016-09-29 Thread Eugene Wissner via Digitalmars-d
On Wednesday, 14 September 2016 at 20:28:13 UTC, Stefan Koch wrote: On Wednesday, 14 September 2016 at 20:24:13 UTC, Stefan Koch wrote: I would like to see users of fullyQualifiedName because apart from binderoo code which seems to work, I have none. That was supposed to say : I would like t

Re: D, ZeroMQ, Nanomsg

2016-09-29 Thread qznc via Digitalmars-d
On Thursday, 29 September 2016 at 04:18:55 UTC, Nikolay wrote: On Wednesday, 28 September 2016 at 11:53:05 UTC, Russel Winder wrote: Has anyone wrapped Nanomsg? Be aware - Nanomsg project is mostly dead now. See http://sealedabstract.com/rants/nanomsg-postmortem-and-other-stories/ That ar

Re: DIP 1002 (TryElseExpression) added to the queue

2016-09-29 Thread Steven Schveighoffer via Digitalmars-d
On 9/28/16 6:12 PM, Idan Arye wrote: On Wednesday, 28 September 2016 at 21:00:00 UTC, Steven Schveighoffer wrote: Declaring variables that you need in the right scopes is pretty straightforward. Having scopes magically continue around other separate scopes (catch scopes) doesn't look correct. I

Re: DIP 1002 (TryElseExpression) added to the queue

2016-09-29 Thread Steven Schveighoffer via Digitalmars-d
On 9/29/16 7:02 AM, pineapple wrote: On Thursday, 29 September 2016 at 10:51:01 UTC, Nick Treleaven wrote: Note that finally(bool) is more flexible than finally/else as you can interleave code arbitrarily. __guard makes it clearer something special is happening rather than just implicitly extend

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread rikki cattermole via Digitalmars-d
On 30/09/2016 2:18 AM, Jacob Carlborg wrote: On 2016-09-29 14:57, rikki cattermole wrote: Me and Cauterite were toying with the idea of AST macros but in a completely new form a while ago. Below is the usage of it. Something you'll notice about it is that it could turn the asm block into a lib

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Minty Fresh via Digitalmars-d
On Thursday, 29 September 2016 at 12:54:54 UTC, Jacob Carlborg wrote: BTW, there's a CTFE parser generator for D around somewhere. And that will handle all that the DMD parser does? I don't think so. I agree with this entirely. Lest you have an entire D compiler implemented in CTFE (reducti

Re: Qualifier parameters (inout on steroids)

2016-09-29 Thread Steven Schveighoffer via Digitalmars-d
On 9/29/16 8:53 AM, Tomer Filiba wrote: `inout` is a useful feature, but it's nearly impossible to actually use it. Suppose I have struct MyTable { @property items() inout { return Range(&this); } static struct Range { MyTable* table; // can't be inout } } I wan

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Jacob Carlborg via Digitalmars-d
On 2016-09-29 14:57, rikki cattermole wrote: Me and Cauterite were toying with the idea of AST macros but in a completely new form a while ago. Below is the usage of it. Something you'll notice about it is that it could turn the asm block into a library solution (which is clearly what we'd want

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Jacob Carlborg via Digitalmars-d
On 2016-09-29 11:31, pineapple wrote: This is not an argument to justify adding just any feature, it's an argument that it is idiocy to give a programmer a powerful tool, and then impose arbitrary limitations upon how they are allowed to use it. One of the most popular topics of discussion in t

Re: DIP 1002 (TryElseExpression) added to the queue

2016-09-29 Thread pineapple via Digitalmars-d
On Thursday, 29 September 2016 at 11:45:42 UTC, Marc Schütz wrote: On Wednesday, 28 September 2016 at 22:12:27 UTC, Idan Arye wrote: Foo foo; try { foo = Foo(); } catch (FooCreationException) { // ... } else { foo.doSomethingWithFoo(); } // foo exi

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread rikki cattermole via Digitalmars-d
Me and Cauterite were toying with the idea of AST macros but in a completely new form a while ago. Below is the usage of it. Something you'll notice about it is that it could turn the asm block into a library solution (which is clearly what we'd want anyway). Not to mention Linq style queries

Re: DIP 1002 (TryElseExpression) added to the queue

2016-09-29 Thread Jack Stouffer via Digitalmars-d
On Thursday, 29 September 2016 at 12:24:31 UTC, Andrei Alexandrescu wrote: Once submitted, if rejected, the only way to propose a similar feature is by authoring a new proposal with a completely novel perspective. So official review is an important milestone with a high bar. -- Andrei Ok, I s

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Jacob Carlborg via Digitalmars-d
On 2016-09-29 09:58, Walter Bright wrote: I.e. you can overload '+' to do bad things. Yes, you can, and as I replied upthread that can be done because there's no way to prevent that while having operator overloading at all. But that is not justification for allowing such disasters for the compa

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread pineapple via Digitalmars-d
On Thursday, 29 September 2016 at 12:20:42 UTC, Russel Winder wrote: Opinionated is not always bad. Look at Go, the developers know that there is no sane way of doing generics so they ban it. Also they know that exceptions are totally incomprehensible to all programmers so they ban them. Rust

Qualifier parameters (inout on steroids)

2016-09-29 Thread Tomer Filiba via Digitalmars-d
`inout` is a useful feature, but it's nearly impossible to actually use it. Suppose I have struct MyTable { @property items() inout { return Range(&this); } static struct Range { MyTable* table; // can't be inout } } I want my items-range to be const if `this` i

"Disappearing" operator methods

2016-09-29 Thread Tomer Filiba via Digitalmars-d
Consider this code struct MyTable { bool opBinaryRight(string op: "in")(int x) { return true; } } Now let's use it: MyTable m1; assert(5 in m1); Everything works as expected. Now suppose I had a const object object const MyTable m2; 5 in m2; // Error: rvalue of in expressio

Re: DIP 1002 (TryElseExpression) added to the queue

2016-09-29 Thread Andrei Alexandrescu via Digitalmars-d
On 9/28/16 6:50 AM, Jack Stouffer wrote: On Wednesday, 28 September 2016 at 10:45:11 UTC, Andrei Alexandrescu wrote: Assertions such as "makes the code cleaner" are likely to add value only if backed up by evidence (case studies, realistic examples). This is based on my anecdotal experience. I

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Russel Winder via Digitalmars-d
On Thu, 2016-09-29 at 11:50 +, Minty Fresh via Digitalmars-d wrote: > On Thursday, 29 September 2016 at 11:29:55 UTC, Russel Winder  > wrote: > > > > However, this has come up many times, and every time Walter  > > says "no, it's wrong". Whilst the C++ iostreams << may have  > > problems, usin

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Russel Winder via Digitalmars-d
On Wed, 2016-09-28 at 21:15 -0700, Walter Bright via Digitalmars-d wrote: > On 9/28/2016 1:40 PM, Timon Gehr wrote: > > > > What's wrong with that usage? > > Because then something other than comparison is happening with <=, <, > >, >= and  > there'll be nothing in the code to give the user a hin

Re: Module names shadowing defined functions/templates.

2016-09-29 Thread Adam D. Ruppe via Digitalmars-d
On Thursday, 29 September 2016 at 01:54:42 UTC, Minty Fresh wrote: module leastsq; Here's my tip: always give a module a name with at least two pieces, and always write it explicitly. So make it `module your_name.leastsq;`. If you ever end up mixing modules from different projects, this

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Minty Fresh via Digitalmars-d
On Thursday, 29 September 2016 at 11:29:55 UTC, Russel Winder wrote: However, this has come up many times, and every time Walter says "no, it's wrong". Whilst the C++ iostreams << may have problems, using this as a single point argument as to why overloading fails in all other cases except nume

Re: DIP 1002 (TryElseExpression) added to the queue

2016-09-29 Thread Andrei Alexandrescu via Digitalmars-d
On 09/29/2016 03:49 AM, John Colvin wrote: On Wednesday, 28 September 2016 at 23:44:19 UTC, Andrei Alexandrescu wrote: On 9/28/16 7:40 PM, Andrei Alexandrescu wrote: // With scope void assertNot(string s) { try { scope(success) assert(0, s); decode(s,DecodeMode.STRICT); } catch (Decode

Re: DIP 1002 (TryElseExpression) added to the queue

2016-09-29 Thread Marc Schütz via Digitalmars-d
On Wednesday, 28 September 2016 at 22:12:27 UTC, Idan Arye wrote: Foo foo; try { foo = Foo(); } catch (FooCreationException) { // ... } else { foo.doSomethingWithFoo(); } // foo exists here - it could be initialized, it could be not... And `Foo`

Re: Overloading relational operators separately; thoughts?

2016-09-29 Thread Russel Winder via Digitalmars-d
On Wed, 2016-09-28 at 20:30 +, pineapple via Digitalmars-d wrote: > On Wednesday, 28 September 2016 at 20:16:08 UTC, Walter Bright  > wrote: > > > > Because there is no way to stop the former but still have  > > operator overloading. > > > > To reiterate, operator overloading exists in D to s

  1   2   >