December 03, 2013 Re: No household is perfect | ||||
---|---|---|---|---|
| ||||
Posted in reply to eles | On 12/3/2013 7:49 AM, eles wrote:
> You mean std.uni? Seriously, let's change that name into std.unicode.
"unicode" is trademarked and could cause us some problems. So, no.
|
December 03, 2013 Re: No household is perfect | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russel Winder | On 12/3/2013 4:41 AM, Russel Winder wrote:
> Yes.
>
> a + b
>
> could be set union, logic and, string concatenation. The + is just a
> message to the LHS object, it determines what to do. This is the whole
> basis for DSLs.
Using operator overloading to create a DSL is just wrong. Part of the design of operator overloading in D is to deliberately frustrate such attempts.
+ should mean addition, not union, concatenation, etc. Overloading is there to support addition on user defined types, not to invent new meanings for it.
Embedded DSLs should be visually distinct, and D provides the ability for that with string mixins and CTFE.
Part of my opinion for this comes from C++ regexes done using expression templates. It's cute and clever, but it's madness. For one, any sort of errors coming out of it if a mistake is made are awesomely incomprehensible. For another, there's no clue in the source code when one has slipped into DSL-land, and suddenly * doesn't mean pointer dereference, it means "0 or more".
Utter madness.
|
December 03, 2013 Re: No household is perfect | ||||
---|---|---|---|---|
| ||||
Posted in reply to Shammah Chancellor | On 12/2/2013 9:18 PM, Shammah Chancellor wrote: > There are some beasts who fix bugs really quickly in the frontend. Yup, we have a couple of really prodigious contributors to the complex bits of the front end. > rant/ > With that said, I am finding though that a lot of the documentation on the > website is not maintained well by the community. There are a lot of references > to deprecated features, or things that don't work. E.G. scope'd calls allocation > > scope Foo bar = new Foo; is all over the documentation. I've come to find out > this is deprecated? > > Or this message from 2012: > http://forum.dlang.org/thread/20120411014440.GA12737@quickfur.ath.cx > > The hash-map doc still makes reference to opHash > (http://dlang.org/hash-map.html). Which bit me when I copied and pasted. > /rant > > I will try to do my part on updating these things. Thank you, we do need the help! |
December 03, 2013 Re: No household is perfect | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 12/3/13 4:53 PM, Andrei Alexandrescu wrote:
> On 12/3/13 4:41 AM, Russel Winder wrote:
>> On Tue, 2013-12-03 at 13:29 +0100, Tobias Pankrath wrote:
>> […]
>>> Does scala have arbitrary operators like Haskell? Looks useless
>>> in D. If you have an operator '+' that should not be pronounced
>>> 'plus' you are doing it wrong.
>>
>> Yes.
>>
>> a + b
>>
>> could be set union, logic and, string concatenation. The + is just a
>> message to the LHS object
>
> or RHS :o).
How come?
|
December 03, 2013 Re: No household is perfect | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Tuesday, 3 December 2013 at 20:06:49 UTC, Walter Bright wrote:
> On 12/3/2013 4:41 AM, Russel Winder wrote:
>> Yes.
>>
>> a + b
>>
>> could be set union, logic and, string concatenation. The + is just a
>> message to the LHS object, it determines what to do. This is the whole
>> basis for DSLs.
>
> Using operator overloading to create a DSL is just wrong. Part of the design of operator overloading in D is to deliberately frustrate such attempts.
>
> + should mean addition, not union, concatenation, etc. Overloading is there to support addition on user defined types, not to invent new meanings for it.
>
> Embedded DSLs should be visually distinct, and D provides the ability for that with string mixins and CTFE.
>
>
> Part of my opinion for this comes from C++ regexes done using expression templates. It's cute and clever, but it's madness. For one, any sort of errors coming out of it if a mistake is made are awesomely incomprehensible. For another, there's no clue in the source code when one has slipped into DSL-land, and suddenly * doesn't mean pointer dereference, it means "0 or more".
>
> Utter madness.
Indeed. I had a regex bottleneck in a C++ program so I figured I'd just convert it to Boost Xpressive as an easy solution. It took me half a day to convert the regular expression into the convoluted single line of code with dozens of operators it became. It did run faster (phew!) so it was worth it but the code is unrecognizable as a regular expression and I have to keep a comment with the original regular expression in the code because nobody (myself included) should have to spend an ungodly amount of time trying to decipher the cryptic source code it became.
If my program were written in D I would have just replaced "regex(" with "ctRegex!(" and moved on with my day.
|
December 03, 2013 Re: No household is perfect | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Tuesday, 3 December 2013 at 19:41:46 UTC, Andrei Alexandrescu wrote:
> On the other hand Walter has been adamantly against configurable syntax (and talked me into that stance as well), so D is immune from quite a few issues pointed by that rant. D code is readable at least at surface level without needing context.
>
Arguably, optional () and the mess involved around fall into the category of opaque and unclear syntax.
|
December 03, 2013 Re: No household is perfect | ||||
---|---|---|---|---|
| ||||
Posted in reply to eles | Am 03.12.2013 16:49, schrieb eles:
> On Tuesday, 3 December 2013 at 14:25:50 UTC, Paulo Pinto wrote:
>> On Tuesday, 3 December 2013 at 12:41:40 UTC, Russel Winder wrote:
>>> On Tue, 2013-12-03 at 13:29 +0100, Tobias Pankrath wrote:
>
>> Maybe I've spent too much time with math at the uni. :)
>
> You mean std.uni? Seriously, let's change that name into std.unicode.
> std.uni it is just laughable (yes, flames, flames) and tells, well,
> nothing.
It is my daily German creeping into my English, uni => University.
--
Paulo
|
December 03, 2013 Re: No household is perfect | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | Am 03.12.2013 16:36, schrieb Jesse Phillips:
> On Tuesday, 3 December 2013 at 09:46:27 UTC, Paulo Pinto wrote:
>> Sadly plain C and C++ compilers are what most young developers know as
>> AOT compilers, hence the spread of slow compilation message.
>>
>> --
>> Paulo
>
> I don't think that is limited to young developers. The only difference
> is that older developers are already comfortable programming in C/C++.
Every time I code in C++ instead of JVM/.NET/D/Go, I remember of Turbo Pascal/Delphi/Oberon/Modula-2 compile times with nostalgia.
--
Paulo
|
December 03, 2013 Re: No household is perfect | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Tuesday, 3 December 2013 at 19:56:24 UTC, Walter Bright wrote: > On 12/3/2013 7:49 AM, eles wrote: >> You mean std.uni? Seriously, let's change that name into std.unicode. > > "unicode" is trademarked and could cause us some problems. So, no. Huh...sure enough: The Unicode Consortium Name and Trademark Usage Policy: http://www.unicode.org/policies/logo_policy.html |
December 03, 2013 Re: No household is perfect | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ary Borenszweig | On Tuesday, 3 December 2013 at 20:09:52 UTC, Ary Borenszweig wrote: > On 12/3/13 4:53 PM, Andrei Alexandrescu wrote: >> On 12/3/13 4:41 AM, Russel Winder wrote: >>> On Tue, 2013-12-03 at 13:29 +0100, Tobias Pankrath wrote: >>> […] >>>> Does scala have arbitrary operators like Haskell? Looks useless >>>> in D. If you have an operator '+' that should not be pronounced >>>> 'plus' you are doing it wrong. >>> >>> Yes. >>> >>> a + b >>> >>> could be set union, logic and, string concatenation. The + is just a >>> message to the LHS object >> >> or RHS :o). > > How come? "opBinaryRight": http://dlang.org/operatoroverloading.html It's a "neat" feature that allows operators being member functions, yet still resolve to the right hand side if needed. For example: auto result = 1 + complex(1, 1); Will compile, and be re-written as: auto result = complex(1, 1).opBinaryRight!"+"(1); In contrast, C++ has to resort to non-member friend operators to make this work. |
Copyright © 1999-2021 by the D Language Foundation