digitalmars.D - No household is perfect
- Andrei Alexandrescu (3/3) Dec 02 2013 http://www.reddit.com/r/programming/comments/1rx8r2/go_binary_sizes_are_...
- Shammah Chancellor (5/13) Dec 02 2013 I find this particularly interesting. Where is the interest in Scala
- Andrei Alexandrescu (5/18) Dec 02 2013 The graph confirms what I believed - Scala is much more popular than D.
- Shammah Chancellor (30/60) Dec 02 2013 I don't understand it at all though. I've been using D (off and on)
- Walter Bright (4/17) Dec 03 2013 Yup, we have a couple of really prodigious contributors to the complex b...
- bearophile (5/11) Dec 03 2013 An interesting idea:
- Tobias Pankrath (4/15) Dec 03 2013 Does scala have arbitrary operators like Haskell? Looks useless
- Russel Winder (13/16) Dec 03 2013 Yes.
- Paulo Pinto (7/19) Dec 03 2013 Fully agree, I still cannot understand why so many people have
- eles (4/8) Dec 03 2013 You mean std.uni? Seriously, let's change that name into
- bearophile (4/6) Dec 03 2013 I think he meant "Unicorn".
- Walter Bright (2/3) Dec 03 2013 "unicode" is trademarked and could cause us some problems. So, no.
- Brad Anderson (4/9) Dec 03 2013 Huh...sure enough:
- eles (6/11) Dec 04 2013 Yeah, bad.
- =?UTF-8?B?Ikx1w61z?= Marques" (3/5) Dec 04 2013 That seems unlikely. Also, it's not that different from
- Parke (2/8) Dec 04 2013 Also, "unicode" is a standard type in Python 2.7.
- Kapps (22/28) Dec 04 2013 From http://www.unicode.org/policies/logo_policy.html :
- Marco Leise (11/46) Dec 04 2013 =20
- monarch_dodra (10/54) Dec 05 2013 Having read all that though, one could argue that having "uni" is
- =?UTF-8?B?Ikx1w61z?= Marques" (38/44) Dec 10 2013 (mind you, copyright is different from trademark!)
- eles (2/7) Dec 05 2013 http://www.erlang.org/doc/man/unicode.html
- Paulo Pinto (4/11) Dec 03 2013 It is my daily German creeping into my English, uni => University.
- eles (2/9) Dec 04 2013 it is my daily D rant, uni => unicode
- Tobias Pankrath (8/20) Dec 03 2013 I really have no problem with operator overloading, but set union
- Andrei Alexandrescu (3/12) Dec 03 2013 or RHS :o).
- Ary Borenszweig (2/16) Dec 03 2013 How come?
- monarch_dodra (12/32) Dec 03 2013 "opBinaryRight":
- Ary Borenszweig (4/32) Dec 04 2013 That's nice.
- Jakob Ovrum (6/9) Dec 04 2013 The point is that D does not have operator overloading for
- Walter Bright (5/8) Dec 04 2013 The bad thing about the global operator overloading is that it:
- Timon Gehr (4/14) Dec 04 2013 Makes sense, but I'd argue that whenever a.opBinaryRight!"+"(b) is
- Tobias Pankrath (17/19) Dec 11 2013 ---
- Marco Leise (8/45) Dec 04 2013 In this case I agree, but when porting some vector/matrix
- Walter Bright (13/18) Dec 03 2013 Using operator overloading to create a DSL is just wrong. Part of the de...
- Brad Anderson (12/38) Dec 03 2013 Indeed. I had a regex bottleneck in a C++ program so I figured
- H. S. Teoh (114/151) Dec 03 2013 Ugh. Ugh, ugh, ugh. This beckons to that horrid decision in C++'s
- Joshua Niehus (3/11) Dec 03 2013 This would make for a good blog post/wiki article. Does one
- bearophile (8/10) Dec 03 2013 If you have a AST macros like in Julia language, I think you can
- H. S. Teoh (12/24) Dec 04 2013 [...]
- Andrei Alexandrescu (3/24) Dec 04 2013 Yah, my thoughts exactly. Looks like we're in a sweet spot there.
- Dmitry Olshansky (14/39) Dec 04 2013 I'll just add a bit of my experience on this.
- Jacob Carlborg (8/19) Dec 05 2013 With AST macros it would be the same thing, just that you don't need to
- Don (9/36) Dec 05 2013 I think that is of negligible benefit. There's not a whole of
- Timon Gehr (2/4) Dec 05 2013 In particular, improvements to the specification of its semantics. :)
- Chris Cain (11/19) Dec 05 2013 Negligible? AST macros write the front-end of a D compiler for a
- Don (13/36) Dec 05 2013 It's a negligible benefit because most of the time is spent in
- Chris Cain (18/32) Dec 05 2013 I see. I thought you were saying the concept of not having to
- Shammah Chancellor (9/23) Dec 04 2013 Can't you define
- =?UTF-8?B?U2ltZW4gS2rDpnLDpXM=?= (14/31) Dec 05 2013 It'd have to be:
- Jacob Carlborg (6/8) Dec 03 2013 The point of DSL's are to make a languages that work optimal and look
- H. S. Teoh (15/23) Dec 04 2013 [...]
- Walter Bright (2/12) Dec 04 2013 Looks like we're on the same wavelength here.
- Russel Winder (17/25) Dec 10 2013 On Tue, 2013-12-03 at 12:06 -0800, Walter Bright wrote:
- Walter Bright (2/6) Dec 10 2013 Looking forward to it!
- Jesse Phillips (6/12) Dec 03 2013 This is what was basically done with D1, all the operator
- =?UTF-8?B?Ikx1w61z?= Marques" (4/7) Dec 02 2013 I think he might not have liked D either:
- Meta (8/15) Dec 02 2013 I don't think this author is used to working with strongly-typed
- Paulo Pinto (16/35) Dec 03 2013 The main issue is that many seem to think very simple languages
- Atila Neves (9/14) Dec 03 2013 This can't be repeated enough. The complexity doesn't go away, it
- Jesse Phillips (4/9) Dec 03 2013 I don't think that is limited to young developers. The only
- Paulo Pinto (5/13) Dec 03 2013 Every time I code in C++ instead of JVM/.NET/D/Go, I remember of Turbo
- Andrei Alexandrescu (13/31) Dec 03 2013 He would at least to the extent a motivated and talented programmer
- Walter Bright (3/12) Dec 03 2013 I also think it's abundantly clear that we hit a home run by making comp...
- deadalnix (4/9) Dec 03 2013 Arguably, optional () and the mess involved around fall into the
- eles (2/6) Dec 04 2013 yes, that was a trap
http://www.reddit.com/r/programming/comments/1rx8r2/go_binary_sizes_are_growing_out_of_control/ http://www.reddit.com/r/programming/comments/1rvltx/scala_1_would_not_program_again/#new Andrei
Dec 02 2013
On 2013-12-03 00:36:28 +0000, Andrei Alexandrescu said:http://www.reddit.com/r/programming/comments/1rx8r2/go_binary_sizes_are_gro ing_out_of_control/ http://www.reddit.com/r/programming/comments/1rvltx/scala_1_would_no _program_again/#new AndreiI find this particularly interesting. Where is the interest in Scala being generated compared to D? https://www.ohloh.net/languages/compare?measure=commits&percent=true&l0=scala&l1=dmd&l2=haskell&l3=-1 l4=-1&commit=Update -Shammah
Dec 02 2013
On 12/2/13 6:49 PM, Shammah Chancellor wrote:On 2013-12-03 00:36:28 +0000, Andrei Alexandrescu said:The graph confirms what I believed - Scala is much more popular than D. Odersky's response and the subsequent thread are interesting, too: https://groups.google.com/forum/?fromgroups#!topic/scala-debate/153H3Ya4Nxk Andreihttp://www.reddit.com/r/programming/comments/1rx8r2/go_binary_sizes_are_growing_out_of_control/ http://www.reddit.com/r/programming/comments/1rvltx/scala_1_would_not_program_again/#new AndreiI find this particularly interesting. Where is the interest in Scala being generated compared to D? https://www.ohloh.net/languages/compare?measure=commits&percent=true&l0=scala&l1=dmd&l2=haskell&l3=-1&l4=-1&commit=Update -Shammah
Dec 02 2013
On 2013-12-03 03:01:12 +0000, Andrei Alexandrescu said:On 12/2/13 6:49 PM, Shammah Chancellor wrote:I don't understand it at all though. I've been using D (off and on) since around 0.47. It's a fanastic language much better than Scala. Props to Walter, and you. There are some rough edges, but I argue about them on this forum, and for the most part many of the things that I dislike, or want, have been added or changed in an acceptable way over the last 10 years. I want to see this language succeed. I tell everyone I know about it. I burned out on D for awhile ago, but I've always poked my head in here a couple times a year, and am now using it for a fairly large project. The reason I kept having to abandon it in the past was due to blocking compiler bugs with templates & CTFE, but with the new bugzilla I find that the bugs I submit are generally noted and fixed in a reasonable amount of time now. I like that the community is more open now. There are some beasts who fix bugs really quickly in the frontend. 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. -ShammahOn 2013-12-03 00:36:28 +0000, Andrei Alexandrescu said:The graph confirms what I believed - Scala is much more popular than D. Odersky's response and the subsequent thread are interesting, too: https://groups.google.com/forum/?fromgroups#!topic/scala-debate/153H3Ya4Nxk Andreihttp://www.reddit.com/r/programming/comments/1rx8r2/go_binary_sizes_are_gro ing_out_of_control/ http://www.reddit.com/r/programming/comments/1rvltx/scala_1_would_no _program_again/#new AndreiI find this particularly interesting. Where is the interest in Scala being generated compared to D? https://www.ohloh.net/languages/compare?measure=commits&percent=true&l0=scala&l1=dmd&l2=haskell&l3=-1 l4=-1&commit=Update -Shammah
Dec 02 2013
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!
Dec 03 2013
Andrei Alexandrescu:Odersky's response and the subsequent thread are interesting, too: https://groups.google.com/forum/?fromgroups#!topic/scala-debate/153H3Ya4NxkAn interesting idea: Martin O.:we should do something about operators. I like James Ward's idea to mandate an alphabetic alias for every operator - at least people would know how to pronounce them then.<Bye, bearophile
Dec 03 2013
On Tuesday, 3 December 2013 at 12:18:32 UTC, bearophile wrote:Andrei Alexandrescu: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.Odersky's response and the subsequent thread are interesting, too: https://groups.google.com/forum/?fromgroups#!topic/scala-debate/153H3Ya4NxkAn interesting idea: Martin O.:we should do something about operators. I like James Ward's idea to mandate an alphabetic alias for every operator - at least people would know how to pronounce them then.<Bye, bearophile
Dec 03 2013
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, it determines what to do. This is the whole basis for DSLs. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Dec 03 2013
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: […]Fully agree, I still cannot understand why so many people have problems seeing operators as function calls with different set of letters, like so many languages allow. Maybe I've spent too much time with math at the uni. :) -- PauloDoes 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, it determines what to do. This is the whole basis for DSLs.
Dec 03 2013
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.
Dec 03 2013
eles:You mean std.uni? Seriously, let's change that name into std.unicode.I think he meant "Unicorn". Bye, bearophile
Dec 03 2013
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.
Dec 03 2013
On Tuesday, 3 December 2013 at 19:56:24 UTC, Walter Bright wrote:On 12/3/2013 7:49 AM, eles wrote:Huh...sure enough: The Unicode Consortium Name and Trademark Usage Policy: http://www.unicode.org/policies/logo_policy.htmlYou mean std.uni? Seriously, let's change that name into std.unicode."unicode" is trademarked and could cause us some problems. So, no.
Dec 03 2013
On Tuesday, 3 December 2013 at 21:12:36 UTC, Brad Anderson wrote:On Tuesday, 3 December 2013 at 19:56:24 UTC, Walter Bright wrote:On 12/3/2013 7:49 AM, eles wrote:The Unicode Consortium Name and Trademark Usage Policy: http://www.unicode.org/policies/logo_policy.htmlYeah, bad. D allows unicode source, so you could name the module std.Unicode® ;) no, I was joking. but I am sad 'bout it
Dec 04 2013
On Tuesday, 3 December 2013 at 19:56:24 UTC, Walter Bright wrote:"unicode" is trademarked and could cause us some problems. So, no.That seems unlikely. Also, it's not that different from std.windows, std.linux, etc.
Dec 04 2013
On Wednesday, 4 December 2013 at 17:21:24 UTC, Luís Marques wrote:On Tuesday, 3 December 2013 at 19:56:24 UTC, Walter Bright wrote:Also, "unicode" is a standard type in Python 2.7."unicode" is trademarked and could cause us some problems. So, no.That seems unlikely. Also, it's not that different from std.windows, std.linux, etc.
Dec 04 2013
On Wednesday, 4 December 2013 at 17:21:24 UTC, Luís Marques wrote:On Tuesday, 3 December 2013 at 19:56:24 UTC, Walter Bright wrote:From http://www.unicode.org/policies/logo_policy.html : You may use the Unicode Word Mark to refer to the Unicode® Standard, to other Unicode® specifications, tools and code, and to Unicode® seminars, tutorials, meetings, and events, so long as any such references (a) are truthful, fair, and not misleading, and (b) follow these Guidelines. Always use “Unicode” as an adjective followed by an appropriate noun. Do not use “Unicode” alone as a noun. Do not pluralize it or make it possessive, and do not alter its spelling. Use the ® symbol to indicate that the Unicode Mark is a registered trademark. The symbol should be used in all prominent references to the Unicode Mark, such as headlines, chapter titles, packaging, advertising, etc. The symbol should also be used in the first reference to the Unicode Mark in body copy, but may thereafter be omitted in body copy. Use the appropriate Trademark Legend (see below) in the footnotes or footers of any material making reference to the Unicode Mark. Incorrect: Unicode Correct: The Unicode® Standard I was rather surprised by this."unicode" is trademarked and could cause us some problems. So, no.That seems unlikely. Also, it's not that different from std.windows, std.linux, etc.
Dec 04 2013
Am Thu, 05 Dec 2013 06:16:14 +0100 schrieb "Kapps" <opantm2+spam gmail.com>:On Wednesday, 4 December 2013 at 17:21:24 UTC, Lu=C3=ADs Marques wrote:=20On Tuesday, 3 December 2013 at 19:56:24 UTC, Walter Bright=20 wrote:=20 From http://www.unicode.org/policies/logo_policy.html : =20 You may use the Unicode Word Mark to refer to the Unicode=C2=AE=20 Standard, to other Unicode=C2=AE specifications, tools and code, and=20 to Unicode=C2=AE seminars, tutorials, meetings, and events, so long as=20 any such references (a) are truthful, fair, and not misleading,=20 and (b) follow these Guidelines. =20 Always use =E2=80=9CUnicode=E2=80=9D as an adjective followed by an="unicode" is trademarked and could cause us some problems. So,=20 no.That seems unlikely. Also, it's not that different from=20 std.windows, std.linux, etc.appropriate noun. Do not use =E2=80=9CUnicode=E2=80=9D alone as a noun. D=o not=20pluralize it or make it possessive, and do not alter its spelling. Use the =C2=AE symbol to indicate that the Unicode Mark is a=20 registered trademark. The symbol should be used in all prominent=20 references to the Unicode Mark, such as headlines, chapter=20 titles, packaging, advertising, etc. The symbol should also be=20 used in the first reference to the Unicode Mark in body copy, but=20 may thereafter be omitted in body copy. Use the appropriate Trademark Legend (see below) in the=20 footnotes or footers of any material making reference to the=20 Unicode Mark. =20 Incorrect: Unicode Correct: The Unicode=C2=AE Standard =20 =20 I was rather surprised by this.No word about naming a module or a keyword 'unicode'. I would be surprised if someone asked if D could have a module named std.unicode and they said "no". Our use would be "truthful, fair and not misleading" and isn't a "prominent reference". But the current module name is ok for me, too. --=20 Marco
Dec 04 2013
On Thursday, 5 December 2013 at 06:04:20 UTC, Marco Leise wrote:Am Thu, 05 Dec 2013 06:16:14 +0100 schrieb "Kapps" <opantm2+spam gmail.com>:Having read all that though, one could argue that having "uni" is *even worst* than "unicode", as it violates both: a) Use the ® symbol to indicate that the Unicode Mark b) Do not alter its spelling I don't care much about uni vs unicode, but I think siding with "uni" for copyright reasons is a fallacious argument. Besides, I don't see where the problem with naming the file/module "std/unicode.d"/"std.unidoe" is, as long as the first paragraph reads: "This is the Unicode® module".On Wednesday, 4 December 2013 at 17:21:24 UTC, Luís Marques wrote:No word about naming a module or a keyword 'unicode'. I would be surprised if someone asked if D could have a module named std.unicode and they said "no". Our use would be "truthful, fair and not misleading" and isn't a "prominent reference". But the current module name is ok for me, too.On Tuesday, 3 December 2013 at 19:56:24 UTC, Walter Bright wrote:From http://www.unicode.org/policies/logo_policy.html : You may use the Unicode Word Mark to refer to the Unicode® Standard, to other Unicode® specifications, tools and code, and to Unicode® seminars, tutorials, meetings, and events, so long as any such references (a) are truthful, fair, and not misleading, and (b) follow these Guidelines. Always use “Unicode” as an adjective followed by an appropriate noun. Do not use “Unicode” alone as a noun. Do not pluralize it or make it possessive, and do not alter its spelling. Use the ® symbol to indicate that the Unicode Mark is a registered trademark. The symbol should be used in all prominent references to the Unicode Mark, such as headlines, chapter titles, packaging, advertising, etc. The symbol should also be used in the first reference to the Unicode Mark in body copy, but may thereafter be omitted in body copy. Use the appropriate Trademark Legend (see below) in the footnotes or footers of any material making reference to the Unicode Mark. Incorrect: Unicode Correct: The Unicode® Standard I was rather surprised by this."unicode" is trademarked and could cause us some problems. So, no.That seems unlikely. Also, it's not that different from std.windows, std.linux, etc.
Dec 05 2013
On Thursday, 5 December 2013 at 08:06:35 UTC, monarch_dodra wrote:Having read all that though, one could argue that having "uni" is *even worst* than "unicode", as it violates both: a) Use the ® symbol to indicate that the Unicode Mark b) Do not alter its spelling I don't care much about uni vs unicode, but I think siding with "uni" for copyright reasons is a fallacious argument.(mind you, copyright is different from trademark!) I didn't tell you this before, but I actually informally asked an IP lawyer about this situation and he told me that, in general, stating facts of the trademark is fine, as long as one is not implying it is authorized, etc. I think this use is not a problem, both in terms of the letter of the law and my personal judgement of how likely it would be for the Unicode Consortium to complain. For instance, see: "Nominative fair use. This is when a potential infringer (or defendant) uses the registered trademark to identify the trademark holder's product or service in conjunction with his or her own. To invoke this defense, the defendant must prove the following elements: * the product or service cannot be readily identified without the mark * he/she only uses as much of the mark as is necessary to identify the goods or services * he/she does nothing with the mark to suggest that the trademark holder has given his approval to the defendant " The unicode module uses the word Unicode to refer to facts about the Unicode Standard. If you want to, in the docs, add a few ® symbols, use quotes around "Unicode" and "The Unicode Standard", add a notice that the word is a trademark, etc., I think that is fine. Stopping the use of the word Unicode in the language and documentation because it is a trademark seems to me to be overthinking it. This is a factual use, just don't imply that the consortium approves anything of the D module and documentation. The rights of a trademark owner are *not* absolute, and if anything I'd expect them to complain about the current use of "Unicode" in the docs (which can easily be fixed) than the use of "unicode" in the module name (where it is reasonable not to use the ® symbol due to technical and practical reasons). Really, just don't overthink it. It's not like this issue would be specific to D (Python uses "unicode", as someone said) or to Unicode (the docs use several other trademarks, without mentioning that they are trademarks...)
Dec 10 2013
On Tuesday, 3 December 2013 at 19:56:24 UTC, Walter Bright wrote:On 12/3/2013 7:49 AM, eles wrote:http://www.erlang.org/doc/man/unicode.htmlYou mean std.uni? Seriously, let's change that name into std.unicode."unicode" is trademarked and could cause us some problems. So, no.
Dec 05 2013
Am 03.12.2013 16:49, schrieb eles:On Tuesday, 3 December 2013 at 14:25:50 UTC, Paulo Pinto wrote:It is my daily German creeping into my English, uni => University. -- PauloOn 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.
Dec 03 2013
On Tuesday, 3 December 2013 at 20:42:01 UTC, Paulo Pinto wrote: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:It is my daily German creeping into my English, uni => University.it is my daily D rant, uni => unicode
Dec 04 2013
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: […]I really have no problem with operator overloading, but set union (∪), logic and (∧) and string concatenation (∘) do have well defined and commonly used symbols. I would not argue against adding these to the language via a general mechanism and indeed then it might be useful to have a name for a user defined wtf-operator ?!?!. But if you overload an operator (+) it should be some kind of addition.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, it determines what to do. This is the whole basis for DSLs.
Dec 03 2013
On 12/3/13 4:41 AM, Russel Winder wrote:On Tue, 2013-12-03 at 13:29 +0100, Tobias Pankrath wrote: […]or RHS :o). AndreiDoes 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
Dec 03 2013
On 12/3/13 4:53 PM, Andrei Alexandrescu wrote:On 12/3/13 4:41 AM, Russel Winder wrote:How come?On Tue, 2013-12-03 at 13:29 +0100, Tobias Pankrath wrote: […]or RHS :o).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
Dec 03 2013
On Tuesday, 3 December 2013 at 20:09:52 UTC, Ary Borenszweig wrote:On 12/3/13 4:53 PM, Andrei Alexandrescu wrote:"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.On 12/3/13 4:41 AM, Russel Winder wrote:How come?On Tue, 2013-12-03 at 13:29 +0100, Tobias Pankrath wrote: […]or RHS :o).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
Dec 03 2013
On 12/3/13 7:23 PM, monarch_dodra wrote:On Tuesday, 3 December 2013 at 20:09:52 UTC, Ary Borenszweig wrote:That's nice. Of course, it's not needed if you overload "+" for the int type to receive a complex.On 12/3/13 4:53 PM, Andrei Alexandrescu wrote:"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.On 12/3/13 4:41 AM, Russel Winder wrote:How come?On Tue, 2013-12-03 at 13:29 +0100, Tobias Pankrath wrote: […]or RHS :o).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
Dec 04 2013
On Wednesday, 4 December 2013 at 13:39:32 UTC, Ary Borenszweig wrote:That's nice. Of course, it's not needed if you overload "+" for the int type to receive a complex.The point is that D does not have operator overloading for in-built types. The unnecessary one is the global operator overload you suggest, as it is more intrusive than `opBinaryRight`.
Dec 04 2013
On 12/4/2013 5:50 AM, Jakob Ovrum wrote:The point is that D does not have operator overloading for in-built types. The unnecessary one is the global operator overload you suggest, as it is more intrusive than `opBinaryRight`.The bad thing about the global operator overloading is that it: 1. follows different scoping and lookup rules 2. was the motivation for ADL (aka "Koenig Lookup") There was no way I was going to put ADL into D :-)
Dec 04 2013
On 12/04/2013 06:11 PM, Walter Bright wrote:On 12/4/2013 5:50 AM, Jakob Ovrum wrote:Makes sense, but I'd argue that whenever a.opBinaryRight!"+"(b) is valid, then a + b should be valid. (Also, the converse. Built-in types do not need to behave specially.)The point is that D does not have operator overloading for in-built types. The unnecessary one is the global operator overload you suggest, as it is more intrusive than `opBinaryRight`.The bad thing about the global operator overloading is that it: 1. follows different scoping and lookup rules 2. was the motivation for ADL (aka "Koenig Lookup") There was no way I was going to put ADL into D :-)
Dec 04 2013
On Wednesday, 4 December 2013 at 17:11:07 UTC, Walter Bright wrote:2. was the motivation for ADL (aka "Koenig Lookup") There was no way I was going to put ADL into D :-)--- // lib.d struct Struct {} // more.d import lib.d int front(Struct s) {} void popFront(ref Struct s) {} // main.d import lib; import more; import std.range; pragma(msg, isInputRange!(Struct)); // outputs 'false' void main() {} --- Any plans/ways to make external methods work here?
Dec 11 2013
Am Tue, 03 Dec 2013 23:23:07 +0100 schrieb "monarch_dodra" <monarchdodra gmail.com>:On Tuesday, 3 December 2013 at 20:09:52 UTC, Ary Borenszweig=20 wrote:In this case I agree, but when porting some vector/matrix code from C++ I found it hard to reproduce everything in D. I can't quite remember the details, but I think it had to do with mutual opOpAssign of classes in separate modules. --=20 MarcoOn 12/3/13 4:53 PM, Andrei Alexandrescu wrote:=20 "opBinaryRight": http://dlang.org/operatoroverloading.html =20 It's a "neat" feature that allows operators being member=20 functions, yet still resolve to the right hand side if needed.=20 For example: auto result =3D 1 + complex(1, 1); =20 Will compile, and be re-written as: auto result =3D complex(1, 1).opBinaryRight!"+"(1); =20 In contrast, C++ has to resort to non-member friend operators to=20 make this work.On 12/3/13 4:41 AM, Russel Winder wrote:How come?On Tue, 2013-12-03 at 13:29 +0100, Tobias Pankrath wrote: [=E2=80=A6]or RHS :o).Does scala have arbitrary operators like Haskell? Looks=20 useless in D. If you have an operator '+' that should not be=20 pronounced 'plus' you are doing it wrong.Yes. a + b could be set union, logic and, string concatenation. The + is=20 just a message to the LHS object
Dec 04 2013
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.
Dec 03 2013
On Tuesday, 3 December 2013 at 20:06:49 UTC, Walter Bright wrote:On 12/3/2013 4:41 AM, Russel Winder wrote: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.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.
Dec 03 2013
On Tue, Dec 03, 2013 at 09:19:34PM +0100, Brad Anderson wrote:On Tuesday, 3 December 2013 at 20:06:49 UTC, Walter Bright wrote:Ugh. Ugh, ugh, ugh. This beckons to that horrid decision in C++'s <iostream> of overloading << to mean "output" and >> to mean "input". The only redeeming quality about this is that << and >> are relatively rarely used in their original sense (bitwise shifts), so it doesn't cause as much of a cognitive dissonance as it otherwise might. But still. Ugh. There are just so many things wrong with this choice, not the least of which is the fact that the operator precedence of << and >> makes no sense when used as I/O operators -- because said operators were never intended to be I/O in the first place!! This leads to such fun as: int a, b; cout << a < b; // what does this do? // (hint: it does NOT output the value of a < b) Ugh!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.+1.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.There's a C++ library that overloads the *comma operator* (!!) to allow you to do things like this: // Creates a 3x4 matrix (!) A = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12; Now, this particular example looks rather cute, but let's say we want to compute matrix elements as we construct it: // Creates a 3x4 matrix (what, really?!) A = x++, y++, z++, f(x+y), y+2*x-z, 4*y, 5*(z-y*x), f(x)-f(y), f(z), g(x), 0; Seriously?? Anyone who understands what a comma operator is (which is itself already a Bad Idea) might imagine this is but a needlessly obscure way of setting A to 0 while performing a whole bunch of side-effects, in a way fitting for an IOCCC entry. (And just in case you wonder: the dimensions of the matrix are determined beforehand. So technically, you *could* create a 3x4 matrix using this code: // Yes this is still a 3x4 matrix... and yes the first row // contains 1, 2, 3, 4, and the second row starts with 5. // Obvious, isn't it? A = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12; Or, indeed, this: // This is a 3x4 matrix too, even though it sure doesn't look // anything like it!! A = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12; Please, somebody tell me how this can even remotely be construed to be a good thing.) Not to mention, the meaning of such code depends entirely up the type of A. What if I have another custom type that also overloads the comma operator, in a slightly different way? Then the semantics of the above snippets would be *completely* different yet again. Now tell me again, why is C++ code so hard to maintain? Hmmm...+ should mean addition, not union, concatenation, etc. Overloading is there to support addition on user defined types, not to invent new meanings for it.String mixins + CTFE = teh r0ckz when it comes to DSLs. After having experienced C++ for a decade or two, I've come to decide that operator overloading is a Bad Idea(tm), except when it applies strictly to custom numerical types that are intended to behave like built-in numerical types. All other uses of operator overloading are, strictly speaking, abusive, and lead to unmaintainable code. Yes, it's cute and clever, and lets you write things not supported by the language "directly", but the next person to inherit your code will curse your name when they spend 5 hours trying to figure out exactly why x+y didn't do what they thought it did. And that's just with *one* library that overloads operators in an unusual way. Now add a second, third, fourth library, each of which overloads the operators in an unusual way, and you might as well be submitting your code as IOCCC entries (except that they don't take C++ entries). OTOH, I completely understand the desire for infix notation for operators on custom types. If you're writing a set library, it sucks to have to write a.union(b.intersection(c)) when what you *really* want is to write: a ∪ (b ∩ c). Here is where D does it right: use a compile-time string argument to a CTFE function that transforms this string into code. Then you can write: Set a, b, c; auto d = mixin(SetExpr!"a ∪ (b ∩ c)"); // The above line gets turned into: // auto d = a.union(b.intersection(c)); // at compile-time. So you can write your set expressions the "natural" way, *and* a new reader of your code will know to look for SetExpr's documentation to understand what the string argument does (not to mention it being amply clear that a DSL is involved here, rather than code that looks like normal numerical expressions but actually does something else). This has even more benefits than fixing C++'s wrong approach, though: For one thing, overloaded operators can't easily generate optimal code, because they just get translated into nested function calls. In order to be able to optimize, say, a ∪ a ∪ a into a no-op, in C++'s approach you'd have to resort to arcane black magic like expression templates to coax the compiler to do what you want. In D, you are parsing the expression as a *string*, which means you get to define how the string is parsed, and how it is to be transformed into code, *directly*. You can run the expression tree through an expression simplifier algorithm, for example, factor common subexpressions, reduce it using known identities, etc.. All of which, granted, can be done by expression templates, except with many more times the pain, proneness to bugs, and unmaintainability. These string DSLs also let you define your own operators (like I did above) without needing to abuse existing operators like + and *, define your own operator precedence rules, define custom syntax without needing to twist and warp it to conform to host language syntax (like that C++ regex library, which honestly makes me cringe every time I look at its contorted syntax).Embedded DSLs should be visually distinct, and D provides the ability for that with string mixins and CTFE.Yeah, that library, while admittedly very clever, is total madness. It looks *nothing* like what regexen normally look like, does something completely unlike what its surface syntax might suggest, and is in pretty much every way very difficult to understand, and therefore hard to maintain and prone to bugs. In today's software development world, where there's too much code to comprehend and too little time to comprehend it, dissociating syntax from its usual meaning is just asking for maintenance nightmares.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.Yeah!! Props to std.regex! T -- Why can't you just be a nonconformist like everyone else? -- YHL
Dec 03 2013
On Tuesday, 3 December 2013 at 22:28:26 UTC, H. S. Teoh wrote:[snip] Then you can write: Set a, b, c; auto d = mixin(SetExpr!"a ∪ (b ∩ c)"); // The above line gets turned into: // auto d = a.union(b.intersection(c)); // at compile-time. So you can write your set expressions the "natural" way, *and* [snip]This would make for a good blog post/wiki article. Does one already exist?
Dec 03 2013
Joshua Niehus:This would make for a good blog post/wiki article. Does one already exist?If you have a AST macros like in Julia language, I think you can write something like: setExpr(a ∪ (b ∩ c)); The main difference is that the compiler gives you a tree in the macro to work on, instead of a string to parse and munge. Bye, bearophile
Dec 03 2013
On Wed, Dec 04, 2013 at 04:23:59AM +0100, bearophile wrote:Joshua Niehus:[...] The problem with having the compiler parse it is that it has to be in a syntax understood by the compiler. If your DSL needs a radically different syntax, it won't work (e.g., regex: how is the compiler to know '+' is a postfix operator instead of an infix one?). By having a compile-time string as input, you have maximum flexibility. It's essentially writing a mini-compiler embedded in D, because it runs in CTFE. T -- You are only young once, but you can stay immature indefinitely. -- azephrahelThis would make for a good blog post/wiki article. Does one already exist?If you have a AST macros like in Julia language, I think you can write something like: setExpr(a ∪ (b ∩ c)); The main difference is that the compiler gives you a tree in the macro to work on, instead of a string to parse and munge.
Dec 04 2013
On 12/4/13 7:06 AM, H. S. Teoh wrote:On Wed, Dec 04, 2013 at 04:23:59AM +0100, bearophile wrote:Yah, my thoughts exactly. Looks like we're in a sweet spot there. AndreiJoshua Niehus:[...] The problem with having the compiler parse it is that it has to be in a syntax understood by the compiler. If your DSL needs a radically different syntax, it won't work (e.g., regex: how is the compiler to know '+' is a postfix operator instead of an infix one?). By having a compile-time string as input, you have maximum flexibility. It's essentially writing a mini-compiler embedded in D, because it runs in CTFE.This would make for a good blog post/wiki article. Does one already exist?If you have a AST macros like in Julia language, I think you can write something like: setExpr(a ∪ (b ∩ c)); The main difference is that the compiler gives you a tree in the macro to work on, instead of a string to parse and munge.
Dec 04 2013
04-Dec-2013 20:22, Andrei Alexandrescu пишет:On 12/4/13 7:06 AM, H. S. Teoh wrote:I'll just add a bit of my experience on this. The coolest side of things is that you get to code a mini-compiler that has a very nice backend - D code. More then that you get optimizer and such for free. Then you only do the fun stuff - your frontend, and if it wasn't for CTFE speed/stability the experience is _very_ pleasant. Compare that with writing a fully fledged JIT compiler for say, regex patterns. Don't forget to account that you'd need to port it to X architectures times Y OS ABIs and generate code of at least moderate quality. JIT would have the benefit of being usable for patterns not known ahead of time though. -- Dmitry OlshanskyOn Wed, Dec 04, 2013 at 04:23:59AM +0100, bearophile wrote:Yah, my thoughts exactly. Looks like we're in a sweet spot there.Joshua Niehus:[...] The problem with having the compiler parse it is that it has to be in a syntax understood by the compiler. If your DSL needs a radically different syntax, it won't work (e.g., regex: how is the compiler to know '+' is a postfix operator instead of an infix one?). By having a compile-time string as input, you have maximum flexibility. It's essentially writing a mini-compiler embedded in D, because it runs in CTFE.This would make for a good blog post/wiki article. Does one already exist?If you have a AST macros like in Julia language, I think you can write something like: setExpr(a ∪ (b ∩ c)); The main difference is that the compiler gives you a tree in the macro to work on, instead of a string to parse and munge.
Dec 04 2013
On 2013-12-04 19:55, Dmitry Olshansky wrote:I'll just add a bit of my experience on this. The coolest side of things is that you get to code a mini-compiler that has a very nice backend - D code. More then that you get optimizer and such for free. Then you only do the fun stuff - your frontend, and if it wasn't for CTFE speed/stability the experience is _very_ pleasant.With AST macros it would be the same thing, just that you don't need to code the mini-compiler. It's already done for you.Compare that with writing a fully fledged JIT compiler for say, regex patterns. Don't forget to account that you'd need to port it to X architectures times Y OS ABIs and generate code of at least moderate quality. JIT would have the benefit of being usable for patterns not known ahead of time though.AST macros would generate a new AST, no need to create a JIT compiler. The advantage of AST macros is that the compiler doesn't need to re-lex and re-parse the result. -- /Jacob Carlborg
Dec 05 2013
On Thursday, 5 December 2013 at 08:17:01 UTC, Jacob Carlborg wrote:On 2013-12-04 19:55, Dmitry Olshansky wrote:I think that is of negligible benefit. There's not a whole of difference between manipulating an AST, vs manipulating text, and I'm confident that the time taken to do that is always going to be far more than the time required to lex and parse text. What AST macros could provide is syntax sugar. But IMHO there's a lot more to be gained from improvements to compile time reflection.I'll just add a bit of my experience on this. The coolest side of things is that you get to code a mini-compiler that has a very nice backend - D code. More then that you get optimizer and such for free. Then you only do the fun stuff - your frontend, and if it wasn't for CTFE speed/stability the experience is _very_ pleasant.With AST macros it would be the same thing, just that you don't need to code the mini-compiler. It's already done for you.Compare that with writing a fully fledged JIT compiler for say, regex patterns. Don't forget to account that you'd need to port it to X architectures times Y OS ABIs and generate code of at least moderate quality. JIT would have the benefit of being usable for patterns not known ahead of time though.AST macros would generate a new AST, no need to create a JIT compiler. The advantage of AST macros is that the compiler doesn't need to re-lex and re-parse the result.
Dec 05 2013
On 12/05/2013 10:25 AM, Don wrote:But IMHO there's a lot more to be gained from improvements to compile time reflection.In particular, improvements to the specification of its semantics. :)
Dec 05 2013
On Thursday, 5 December 2013 at 09:25:30 UTC, Don wrote:I think that is of negligible benefit. There's not a whole of difference between manipulating an AST, vs manipulating text, and I'm confident that the time taken to do that is always going to be far more than the time required to lex and parse text. What AST macros could provide is syntax sugar. But IMHO there's a lot more to be gained from improvements to compile time reflection.Negligible? AST macros write the front-end of a D compiler for a string mixin for you. That's not negligible. Even if the D frontend was static and didn't change it would be difficult to reach parity. The best that can be done now is a language that reminds you of D (or a D subset that, at best, will confuse users since it's not going to support nearly everything). Of course, I know we're not going to get AST macros, but at least don't say things like it's "negligible". The only reason we aren't getting AST macros is because it's the opposite of negligible; it's _too powerful_.
Dec 05 2013
On Thursday, 5 December 2013 at 14:18:46 UTC, Chris Cain wrote:On Thursday, 5 December 2013 at 09:25:30 UTC, Don wrote:What I said was negligible was:I think that is of negligible benefit. There's not a whole of difference between manipulating an AST, vs manipulating text, and I'm confident that the time taken to do that is always going to be far more than the time required to lex and parse text. What AST macros could provide is syntax sugar. But IMHO there's a lot more to be gained from improvements to compile time reflection.Negligible? AST macros write the front-end of a D compiler for a string mixin for you. That's not negligible.It's a negligible benefit because most of the time is spent in the semantic pass (which can take unbounded time), not in the lexing and parsing steps (which always take time O(n), where n is the length of the source code)."The advantage of AST macros is that the compiler doesn't need to re-lex and re-parse the result."Even if the D frontend was static and didn't change it would be difficult to reach parity. The best that can be done now is a language that reminds you of D (or a D subset that, at best, will confuse users since it's not going to support nearly everything).Actually everything can be done in a library. Especially when we switch to the frontend written in D, the library and compiler source can be the same. But I don't see the point of it being identical to D.Of course, I know we're not going to get AST macros, but at least don't say things like it's "negligible". The only reason we aren't getting AST macros is because it's the opposite of negligible; it's _too powerful_.Remember that it would have to be "more powerful" than an arbitrary chunk of source code text. I don't see how that could possibly be true.
Dec 05 2013
On Thursday, 5 December 2013 at 15:59:08 UTC, Don wrote:What I said was negligible was:I see. I thought you were saying the concept of not having to rewrite the D compiler was negligible. Which, of course, is false. The speed advantage is but that's really just a minor thing ultimately.It's a negligible benefit because most of the time is spent in the semantic pass (which can take unbounded time), not in the lexing and parsing steps (which always take time O(n), where n is the length of the source code)."The advantage of AST macros is that the compiler doesn't need to re-lex and re-parse the result."Actually everything can be done in a library. Especially when we switch to the frontend written in D, the library and compiler source can be the same.Hopefully it'll get us to where we need to go.But I don't see the point of it being identical to D.It doesn't _need_ to be, strictly speaking. But having a program written in C, some C++, D, SQL, and some CompileTimeScripting Language is inherently more difficult to deal with than something that limits it to C, C++, and mostly D (that generates necessary SQL and fulfills the requirements needed by the CTS-L). Considering the CTS-L would be unique to D (and possibly even to your project), that's quite an advantage.Remember that it would have to be "more powerful" than an arbitrary chunk of source code text. I don't see how that could possibly be true.Why would it have to be? Don't conflate this with the concept of "equivalent to a turing machine". We're not getting it because it'd be possible to change the meaning of 1+1 to 3. If it were more limited ("less powerful") then it would be something that wouldn't have been rejected but, potentially, far less useful.
Dec 05 2013
On 2013-12-04 03:23:59 +0000, bearophile said:Joshua Niehus:Can't you define template setExpr(string expr) { PeggedStuff... mixin(PeggedStuff()); } setExpr!(q{a ∪ (b ∩ c)}); ? -ShammahThis would make for a good blog post/wiki article. Does one already exist?If you have a AST macros like in Julia language, I think you can write something like: setExpr(a ∪ (b ∩ c)); The main difference is that the compiler gives you a tree in the macro to work on, instead of a string to parse and munge. Bye, bearophile
Dec 04 2013
On 2013-12-05 05:09, Shammah Chancellor wrote:On 2013-12-04 03:23:59 +0000, bearophile said: Joshua Niehus: This would make for a good blog post/wiki article.Does one already exist? If you have a AST macros like in Julia language, I think you can write something like: setExpr(a ∪ (b ∩ c)); The main difference is that the compiler gives you a tree in the macro to work on, instead of a string to parse and munge. Bye, bearophile Can't you define template setExpr(string expr) { PeggedStuff... mixin(PeggedStuff()); } setExpr!(q{a ∪ (b ∩ c)});?It'd have to be: template setExpr(string expr) { PeggedStuff... enum setExpr = PeggedStuff(); } mixin(setExpr!q{a ∪ (b ∩ c)}); for it to have access to the names a, b and c. Apart from that, absolutely. One of the problems would be the lack of type information. If it turns out that a is string, not a Set!int, -- Simen
Dec 05 2013
On 2013-12-03 21:06, Walter Bright wrote:Embedded DSLs should be visually distinct, and D provides the ability for that with string mixins and CTFE.The point of DSL's are to make a languages that work optimal and look appropriate for the given domain. Not necessarily make it distinct from standard D. -- /Jacob Carlborg
Dec 03 2013
On Wed, Dec 04, 2013 at 08:44:17AM +0100, Jacob Carlborg wrote:On 2013-12-03 21:06, Walter Bright wrote:[...] Of course, it's not the *point* of DSLs to be distinct from the host language, but it's a good idea for it to be. Operator overloading that turns + and * into something completely unlike their usual meanings violates the principle of least surprise. A CTFE-string containing + and * interpreted differently is better, because the syntax itself reminds you that something unlike normal D syntax is happening. // (D) It's clear * and + means something different: auto m = input.match(ctRegex!`^a+b*c`); // (C++) What on earth might this mean?! sregex r = (s1= +_w) >> ' ' >> (s2= +_w) >> '!'; T -- Computers aren't intelligent; they only think they are.Embedded DSLs should be visually distinct, and D provides the ability for that with string mixins and CTFE.The point of DSL's are to make a languages that work optimal and look appropriate for the given domain. Not necessarily make it distinct from standard D.
Dec 04 2013
On 12/4/2013 7:27 AM, H. S. Teoh wrote:Of course, it's not the *point* of DSLs to be distinct from the host language, but it's a good idea for it to be. Operator overloading that turns + and * into something completely unlike their usual meanings violates the principle of least surprise. A CTFE-string containing + and * interpreted differently is better, because the syntax itself reminds you that something unlike normal D syntax is happening. // (D) It's clear * and + means something different: auto m = input.match(ctRegex!`^a+b*c`); // (C++) What on earth might this mean?! sregex r = (s1= +_w) >> ' ' >> (s2= +_w) >> '!';Looks like we're on the same wavelength here.
Dec 04 2013
On Tue, 2013-12-03 at 12:06 -0800, Walter Bright wrote: […] I have been waiting to answer this as I wanted to do some experiment first. However circumstances mean that this playing will have to wait till the Christmas break. I thought I should put a place holder message in though to mark that a reply is coming.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.I think this position is too restrictive and just wrong. If D is really aiming to stop internal DSLs using operators then D is missing the whole point of abstraction. But as noted I want code not just waffle to further this discussion. […] -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Dec 10 2013
On 12/10/2013 4:28 AM, Russel Winder wrote:I think this position is too restrictive and just wrong. If D is really aiming to stop internal DSLs using operators then D is missing the whole point of abstraction. But as noted I want code not just waffle to further this discussion.Looking forward to it!
Dec 10 2013
On Tuesday, 3 December 2013 at 12:18:32 UTC, bearophile wrote:Martin O.:This is what was basically done with D1, all the operator overloading was name based so people know they were overloading 'add' and not 'concatenate.' Using the symbol wasn't legal. I don't think it will prevent people from doing what they want though so I don't see it necessary.we should do something about operators. I like James Ward's idea to mandate an alphabetic alias for every operator - at least people would know how to pronounce them then.<Bye, bearophile
Dec 03 2013
On Tuesday, 3 December 2013 at 00:36:32 UTC, Andrei Alexandrescu wrote:http://www.reddit.com/r/programming/comments/1rvltx/scala_1_would_not_program_again/#newI think he might not have liked D either:This leads to ridiculous decisions such as using ~ to glue handlers together in the flexible DSL offered by spray;-)
Dec 02 2013
On Tuesday, 3 December 2013 at 03:06:20 UTC, Luís Marques wrote:On Tuesday, 3 December 2013 at 00:36:32 UTC, Andrei Alexandrescu wrote:I don't think this author is used to working with strongly-typed languages or languages with lower-level features: "And while I’m on the topic, thanks for making me care about the difference between long and int, again. It’s been far too long since I wrote C." I think he might've had a lot of the same criticisms for D as he did for Scala (save the build times. D's a real winner there).http://www.reddit.com/r/programming/comments/1rvltx/scala_1_would_not_program_again/#newI think he might not have liked D either:This leads to ridiculous decisions such as using ~ to glue handlers together in the flexible DSL offered by spray;-)
Dec 02 2013
On Tuesday, 3 December 2013 at 05:54:22 UTC, Meta wrote:On Tuesday, 3 December 2013 at 03:06:20 UTC, Luís Marques wrote:The main issue is that many seem to think very simple languages are the way to go, until they need to tackle complex problems and end up modeling manuly what other languages offer for free. Like code generation tools in Go to overcome templates, or crazy macros in C to support OOP.On Tuesday, 3 December 2013 at 00:36:32 UTC, Andrei Alexandrescu wrote:I don't think this author is used to working with strongly-typed languages or languages with lower-level features: "And while I’m on the topic, thanks for making me care about the difference between long and int, again. It’s been far too long since I wrote C."http://www.reddit.com/r/programming/comments/1rvltx/scala_1_would_not_program_again/#newI think he might not have liked D either:This leads to ridiculous decisions such as using ~ to glue handlers together in the flexible DSL offered by spray;-)I think he might've had a lot of the same criticisms for D as he did for Scala (save the build times. D's a real winner there).Most languages with module support should provide pretty good compile times, C and C++ compilers are good example on how not to do it. Just look at the compiler improvements in Objective-C, now with initial module support as of Maverick. Sadly plain C and C++ compilers are what most young developers know as AOT compilers, hence the spread of slow compilation message. -- Paulo
Dec 03 2013
The main issue is that many seem to think very simple languages are the way to go, until they need to tackle complex problems and end up modeling manuly what other languages offer for free. Like code generation tools in Go to overcome templates, or crazy macros in C to support OOP.This can't be repeated enough. The complexity doesn't go away, it just moves into the implementation of the current application. Which brings to mind: "Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp." Replace Common Lisp with any other language that lets you get work done, and there you go. Atila
Dec 03 2013
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. -- PauloI don't think that is limited to young developers. The only difference is that older developers are already comfortable programming in C/C++.
Dec 03 2013
Am 03.12.2013 16:36, schrieb Jesse Phillips:On Tuesday, 3 December 2013 at 09:46:27 UTC, Paulo Pinto wrote: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. -- PauloSadly plain C and C++ compilers are what most young developers know as AOT compilers, hence the spread of slow compilation message. -- PauloI don't think that is limited to young developers. The only difference is that older developers are already comfortable programming in C/C++.
Dec 03 2013
On 12/2/13 9:54 PM, Meta wrote:On Tuesday, 3 December 2013 at 03:06:20 UTC, Luís Marques wrote:He would at least to the extent a motivated and talented programmer could put together a rant against every language out there. 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. Also, the way D types work is quite a bit simpler so quite a few of the odd cases don't appear by design. I have this thought that D has offloaded to CTFE and Boolean logic a bunch of tasks that people achieve with complicated type-based proofs in Haskell or Scala. I think that's the real winner but time will tell. AndreiOn Tuesday, 3 December 2013 at 00:36:32 UTC, Andrei Alexandrescu wrote:I don't think this author is used to working with strongly-typed languages or languages with lower-level features: "And while I’m on the topic, thanks for making me care about the difference between long and int, again. It’s been far too long since I wrote C." I think he might've had a lot of the same criticisms for D as he did for Scala (save the build times. D's a real winner there).http://www.reddit.com/r/programming/comments/1rvltx/scala_1_would_not_program_again/#newI think he might not have liked D either:This leads to ridiculous decisions such as using ~ to glue handlers together in the flexible DSL offered by spray;-)
Dec 03 2013
On 12/3/2013 11:41 AM, 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. Also, the way D types work is quite a bit simpler so quite a few of the odd cases don't appear by design. I have this thought that D has offloaded to CTFE and Boolean logic a bunch of tasks that people achieve with complicated type-based proofs in Haskell or Scala. I think that's the real winner but time will tell.I also think it's abundantly clear that we hit a home run by making compile speed a priority since the beginning.
Dec 03 2013
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.
Dec 03 2013
On Tuesday, 3 December 2013 at 20:20:40 UTC, deadalnix wrote:On Tuesday, 3 December 2013 at 19:41:46 UTC, Andrei Alexandrescu wrote:Arguably, optional () and the mess involved around fall into the category of opaque and unclear syntax.yes, that was a trap
Dec 04 2013