digitalmars.D - What are the unused but useful feature you know in D?
- aberba (2/2) Jun 25 2017 Can you share feature(s) in D people are not talking about which
- Adam D. Ruppe (6/8) Jun 25 2017 I actually like anonymous classes. D took it from Java and D has
- Jacob Carlborg (7/11) Jun 26 2017 They're used heavily in DWT [1], since it's ported from Java. Before
- Mike (20/22) Jun 25 2017 In my experience, using appropriate attributes for functions,
- H. S. Teoh via Digitalmars-d (41/63) Jun 25 2017 It happens for template functions, member functions of templated
- Adam D. Ruppe (29/30) Jun 26 2017 One that we could fix, even without breaking any code.
- Mike Parker (6/11) Jun 26 2017 And along with that a compiler switch to enable strict mode by
- H. S. Teoh via Digitalmars-d (11/29) Jun 26 2017 Yes, please do! If we can push this through, D could be in a much, much
- Seb (5/32) Jun 26 2017 This idea is brillant!
- Moritz Maxeiner (3/25) Jun 26 2017 As long as you don't introduce immutable by default, resulting in
- Adam D. Ruppe (5/7) Jun 26 2017 Yeah, I'm against immutable by default. Also, my nogc, safe, etc
- Moritz Maxeiner (4/10) Jun 26 2017 Addendum: I'm also not in favor of `nothrow` by default, because
- Random D user (48/51) Jun 26 2017 I dislike doubling the keywords by having a 'not' case for each.
- Moritz Maxeiner (9/26) Jun 26 2017 Imagine having n libraries with pairwise different required
- Random D user (23/36) Jun 27 2017 Yeah, that's true. I didn't really think of full source
- Moritz Maxeiner (8/17) Jun 27 2017 The power of having plenty of money to pay for (viral) marketing.
- Nicholas Wilson (14/67) Jun 26 2017 Hmm I really like this.
- Nicholas Wilson (4/5) Jun 26 2017 Initial draft
- Nicholas Wilson (2/7) Jul 03 2017 https://github.com/dlang/DIPs/pull/75
- Mike (2/5) Jun 26 2017 That's a really good idea.
- Walter Bright (3/5) Nov 04 2017 And all function literals, and all functions generated by the compiler (...
- Eljay (7/13) Nov 04 2017 If/when D 3.0 happens, as a breaking change, hopefully the
- rikki cattermole (3/17) Nov 04 2017 Like signatures which I'm working on!
- jmh530 (8/10) Nov 04 2017 The first example kind of reminds me of what I was trying to do
- rikki cattermole (13/27) Nov 04 2017 Okay so:
- bauss (4/19) Nov 04 2017 It reminds a lot of traits in Rust.
- rikki cattermole (11/36) Nov 04 2017 Rust traits are a variant of ML's signature. Only they decided to add a
- Atila Neves (8/27) Nov 06 2017 I like Rust's traits more than our way of ad-hoc specification of
- solidstate1991 (5/7) Jul 03 2017 If you need to write a lightweight library or app with no GC and
- codephantom (4/6) Nov 05 2017 How about the compiler option: -release
- user1234 (6/8) Nov 07 2017 I see none.
- Gary Willoughby (5/7) Nov 07 2017 Some of the best features are in the standard library. I've
- Jon Degenhardt (3/10) Nov 07 2017 It's mentioned in Gary's articles, but std.conv.to is fantastic.
- codephantom (28/30) Nov 07 2017 How about this feature: i.e. it actually compiles just fine ;-)
- bauss (17/47) Nov 07 2017 I laughed.
Can you share feature(s) in D people are not talking about which you've found very useful?
Jun 25 2017
On Sunday, 25 June 2017 at 23:21:25 UTC, aberba wrote:Can you share feature(s) in D people are not talking about which you've found very useful?I actually like anonymous classes. D took it from Java and D has a lot of other ways to do it too, but I've found anonymous classes to be nice with using my gui lib... and the only time I see other people talk about them is wanting to remove them from the language!
Jun 25 2017
On 2017-06-26 01:24, Adam D. Ruppe wrote:I actually like anonymous classes. D took it from Java and D has a lot of other ways to do it too, but I've found anonymous classes to be nice with using my gui lib... and the only time I see other people talk about them is wanting to remove them from the language!They're used heavily in DWT [1], since it's ported from Java. Before Java 8, when lambdas was introduced, anonymous classes inheriting from some interface is what was used to handle events. [1] https://github.com/d-widget-toolkit/dwt -- /Jacob Carlborg
Jun 26 2017
On Sunday, 25 June 2017 at 23:21:25 UTC, aberba wrote:Can you share feature(s) in D people are not talking about which you've found very useful?In my experience, using appropriate attributes for functions, variables, etc... doesn't happen like it should. This includes attributes like ` safe`, `immutable`, `pure`, `const`, and others. I recently watched of video where Andrei acknowledged this when talking about the `pure` attribute (https://youtu.be/WsgW4HJXEAg?t=3052). It was also acknowledged somewhat by Walter in his talk at DConf 2017 (https://youtu.be/iDFhvCkCLb4?t=2531). As I understand it, though, the D compiler has some logic to automatically infer some of these attributes, but because its *invisible* to the user it's difficult to predict what those inferences are, and there's no documentation that I'm aware of that defines how/where/where this happens. IMO, part of the problem is that D has the wrong defaults (e.g. `immutable` by default, ` safe` by default, `final` by default, etc...), so users have to opt in to these things when they should really only be opting out of them. Unfortunately, changing this would be disruptive and will probably never happen without a fork. Mike
Jun 25 2017
On Mon, Jun 26, 2017 at 12:38:21AM +0000, Mike via Digitalmars-d wrote:On Sunday, 25 June 2017 at 23:21:25 UTC, aberba wrote:It happens for template functions, member functions of templated aggregates (structs/classes), and auto functions. One of the reasons it's undocumented or underdocumented is because it's a moving target: the goal is to apply automatic inference as widely as possible. Requiring users to manually write attributes is ultimately an impractical plan, especially when the number of attributes increase. You can always use pragma(msg, typeof(...)) to find out exactly what was inferred. To ensure that a particular template function *must* have some attribute as long as none of its arguments break it, use an attributed unittest. E.g.: auto myTemplateFunc(Range)(Range r) if (isInputRange!Range) { } pure unittest { auto r = [1,2,3].myTemplateFunc(); } The reason you don't want to stick the attribute on the function itself is because then it will preclude using it with a range that happens to have impure methods, whereas what you want is that the function is pure if the range is also pure, but if the range is impure, it's OK for the function to be impure. This is achieved by putting the attribute on the unittest: since [1,2,3] is a range known to be pure, any source of impurity must have come from the function; the pure attribute on the unittest would force a compile error in that case.Can you share feature(s) in D people are not talking about which you've found very useful?In my experience, using appropriate attributes for functions, variables, etc... doesn't happen like it should. This includes attributes like ` safe`, `immutable`, `pure`, `const`, and others. I recently watched of video where Andrei acknowledged this when talking about the `pure` attribute (https://youtu.be/WsgW4HJXEAg?t=3052). It was also acknowledged somewhat by Walter in his talk at DConf 2017 (https://youtu.be/iDFhvCkCLb4?t=2531). As I understand it, though, the D compiler has some logic to automatically infer some of these attributes, but because its *invisible* to the user it's difficult to predict what those inferences are, and there's no documentation that I'm aware of that defines how/where/where this happens.IMO, part of the problem is that D has the wrong defaults (e.g. `immutable` by default, ` safe` by default, `final` by default, etc...), so users have to opt in to these things when they should really only be opting out of them. Unfortunately, changing this would be disruptive and will probably never happen without a fork.[...] Yes, the wrong defaults were a historical accident. It was inherited from before D had attributes, so when the attributes were added, the only way was to add attributes that negate the status quo rather than change the default setting, otherwise it would have completely broken everyone's code. Pretty much everyone here agrees that if we could start over, we would have pure by default, nothrow by default, safe by default, etc., and only require marking when something is impure, throwing, system, etc.. But as they say, hindsight is always 20/20... it was not obvious back when D was first designed. T -- Only boring people get bored. -- JM
Jun 25 2017
On Monday, 26 June 2017 at 04:31:33 UTC, H. S. Teoh wrote:Yes, the wrong defaults were a historical accident.One that we could fix, even without breaking any code. Of course, breaking some code to change it would be fairly straightforward to fix for authors, and could even be done automatically in theory (something like dfix), but there's another solution too: opt in once per module, then change things. Javascript did this to pretty good success with its "use strict" thing. --- // status quo D module foo.bar; safe void whatever() {} --- --- // next gen D module version(3.0) foo.bar; // opt in here void whatever() {} // now safe by default --- The syntax could be whatever, but inside the compiler, when it detects that, it switches around the default for the module. Being opt in means only maintained files get it, but being single point change means it is easy to do. And since changes like this can easily live side by side with other modules, it provides a simple path forward. So here's how I'd do it: 1) Add the opposite attributes: `impure`, `throws`, ` gc`, etc. 2) Add the module version thing that changes defaults on request 3) imagine more potential going forward It isn't even hard.
Jun 26 2017
On Monday, 26 June 2017 at 14:17:26 UTC, Adam D. Ruppe wrote:So here's how I'd do it: 1) Add the opposite attributes: `impure`, `throws`, ` gc`, etc. 2) Add the module version thing that changes defaults on request 3) imagine more potential going forward It isn't even hard.And along with that a compiler switch to enable strict mode by default. If you, or anyone else, is willing to put this in DIP form, I'll gladly do what I can to help minimize the effort required to write it up. This is something I'd love to see.
Jun 26 2017
On Mon, Jun 26, 2017 at 02:39:30PM +0000, Mike Parker via Digitalmars-d wrote:On Monday, 26 June 2017 at 14:17:26 UTC, Adam D. Ruppe wrote:Yes, please do! If we can push this through, D could be in a much, much better place in a few years' time! Actually, couldn't we use the same versioning mechanism for *most* of the proposed changes that are currently turned down because they would break too much code? Using this versioning would allow us to introduce breaking changes in an opt-in way, thus allowing codebases the needed time to migrate. T -- MACINTOSH: Most Applications Crash, If Not, The Operating System HangsSo here's how I'd do it: 1) Add the opposite attributes: `impure`, `throws`, ` gc`, etc. 2) Add the module version thing that changes defaults on request 3) imagine more potential going forward It isn't even hard.And along with that a compiler switch to enable strict mode by default. If you, or anyone else, is willing to put this in DIP form, I'll gladly do what I can to help minimize the effort required to write it up. This is something I'd love to see.
Jun 26 2017
On Monday, 26 June 2017 at 16:10:01 UTC, H. S. Teoh wrote:On Mon, Jun 26, 2017 at 02:39:30PM +0000, Mike Parker via Digitalmars-d wrote:This idea is brillant! We could use it to finally get rid off auto-decoding - a small PoC: https://github.com/dlang/phobos/pull/5513On Monday, 26 June 2017 at 14:17:26 UTC, Adam D. Ruppe wrote:Yes, please do! If we can push this through, D could be in a much, much better place in a few years' time! Actually, couldn't we use the same versioning mechanism for *most* of the proposed changes that are currently turned down because they would break too much code? Using this versioning would allow us to introduce breaking changes in an opt-in way, thus allowing codebases the needed time to migrate.So here's how I'd do it: 1) Add the opposite attributes: `impure`, `throws`, ` gc`, etc. 2) Add the module version thing that changes defaults on request 3) imagine more potential going forward It isn't even hard.And along with that a compiler switch to enable strict mode by default. If you, or anyone else, is willing to put this in DIP form, I'll gladly do what I can to help minimize the effort required to write it up. This is something I'd love to see.
Jun 26 2017
On Monday, 26 June 2017 at 16:10:01 UTC, H. S. Teoh wrote:On Mon, Jun 26, 2017 at 02:39:30PM +0000, Mike Parker via Digitalmars-d wrote:As long as you don't introduce immutable by default, resulting in datastructures being littered with `mutable`.On Monday, 26 June 2017 at 14:17:26 UTC, Adam D. Ruppe wrote:Yes, please do! If we can push this through, D could be in a much, much better place in a few years' time!So here's how I'd do it: 1) Add the opposite attributes: `impure`, `throws`, ` gc`, etc. 2) Add the module version thing that changes defaults on request 3) imagine more potential going forward It isn't even hard.And along with that a compiler switch to enable strict mode by default. If you, or anyone else, is willing to put this in DIP form, I'll gladly do what I can to help minimize the effort required to write it up. This is something I'd love to see.
Jun 26 2017
On Monday, 26 June 2017 at 16:51:06 UTC, Moritz Maxeiner wrote:As long as you don't introduce immutable by default, resulting in datastructures being littered with `mutable`.Yeah, I'm against immutable by default. Also, my nogc, safe, etc by default idea does NOT apply to main() or virtual methods. I have explained why before and feel like we are hijacking this thread now though....
Jun 26 2017
On Monday, 26 June 2017 at 16:51:06 UTC, Moritz Maxeiner wrote:On Monday, 26 June 2017 at 16:10:01 UTC, H. S. Teoh wrote:Addendum: I'm also not in favor of `nothrow` by default, because imho that contradicts D's error handling using exceptions by default.Yes, please do! If we can push this through, D could be in a much, much better place in a few years' time!As long as you don't introduce immutable by default, resulting in datastructures being littered with `mutable`.
Jun 26 2017
On Monday, 26 June 2017 at 14:17:26 UTC, Adam D. Ruppe wrote:1) Add the opposite attributes: `impure`, `throws`, ` gc`, etc. 2) Add the module version thing that changes defaults on request 3) imagine more potential going forwardI dislike doubling the keywords by having a 'not' case for each. I'd rather have a systematic way of adding/removing attributes and udas. Something like: gc !gc (previously nogc, compiler could even rewrite nogc into !gc for transition) --- Anyway, I think we could just have a compile time switch for defaults. Since some projects want to have pure, safe, immutable by default, but others want to have system nogc. And no one wants write attributes more than they have to. For example, I kind of like the current defaults since I like flexibility/changeability/editability of code. Because that makes coding fun which in turn usually means better code, features and productivity. Strictness is just a kind of salt that can be sprinkled on code in few difficult or dangerous cases. Also I think safe is a little bit broken (because of trusted and even the very pros (d-devs) seem to get trusted wrong on a regular basis (at least that's my perception)). Just bite the bullet and use Rust if you want to be actually safe. I'm not a huge fan of immutable/const system either as it's kind of difficult to use and low benefits. It often leads into backtracking and changing your code all over the place (small change becomes an avalanche), because you found out in the last leaf function of your subsystem, that your design can't actually be immutable (basically, you forgot or couldn't imagine that elusive corner case no. 99). The good thing is that immutable/const is actually strict and checkable. No holes like in safe. So if this change would happen, I would probably start all of my d files with impure: system: ( nogc:) // depending on my needs, I actually haven't had big issues with the gc (nothrow:) ... Which reminds me that it would be nice to group attributes as well. Something like this: alias apiStrict = safe immutable pure int foo() apiStrict { return 1; }
Jun 26 2017
On Monday, 26 June 2017 at 18:47:18 UTC, Random D user wrote:Anyway, I think we could just have a compile time switch for defaults.Imagine having n libraries with pairwise different required defaults used in your application. Say goodbye to combined compilation, hello n separate required compiler invocations.Since some projects want to have pure, safe, immutable by default, but others want to have system nogc. And no one wants write attributes more than they have to.That's why most of what I do is in templates, so the compiler infers them for me, anyway.Also I think safe is a little bit broken (because of trusted and even the very pros (d-devs) seem to get trusted wrong on a regular basis (at least that's my perception)). Just bite the bullet and use Rust if you want to be actually safe.Except Rust is in exactly the same boat as D, because the same issues that apply to ` trusted` apply to `unsafe`, as well.Which reminds me that it would be nice to group attributes as well. Something like this: alias apiStrict = safe immutable pure int foo() apiStrict { return 1; }That would be useful.
Jun 26 2017
On Monday, 26 June 2017 at 22:17:00 UTC, Moritz Maxeiner wrote:On Monday, 26 June 2017 at 18:47:18 UTC, Random D user wrote:Yeah, that's true. I didn't really think of full source compilation of libs in your project. I though .lib would've been compiled with some settings and you'd just link with that and work with its api. Also in reality I wouldn't want to be able to cancel nogc in a function, because then the attribute would just lose power and you couldn't trust it. I just used it as a simple example for the and ! syntax that I'd like to have in general. Which would allow a nice way of working with sections of code like this: class { nogc: or !gc: ... some code .. gc: or gc: ... more code .. nogc: or !gc: ... even more code .. }Anyway, I think we could just have a compile time switch for defaults.Imagine having n libraries with pairwise different required defaults used in your application. Say goodbye to combined compilation, hello n separate required compiler invocations.Hmmm, I guess that's true. I don't really know a lot about Rust. Their safety story just sounds way more convincing and believable than D's. It would probably be the first language I'd look into if I was interested in low level safety critical code.Also I think safe is a little bit broken (because of trusted and even the very pros (d-devs) seem to get trusted wrong on a regular basis (at least that's my perception)). Just bite the bullet and use Rust if you want to be actually safe.Except Rust is in exactly the same boat as D, because the same issues that apply to ` trusted` apply to `unsafe`, as well.
Jun 27 2017
On Tuesday, 27 June 2017 at 19:06:19 UTC, Random D user wrote:On Monday, 26 June 2017 at 22:17:00 UTC, Moritz Maxeiner wrote:The power of having plenty of money to pay for (viral) marketing. Or in short: Propaganda. Rust is a good PL, but in practice it isn't significantly safer than safe D in my experience. And you pay for that small difference dearly with productivity decrease (even after becoming comfortable with the borrow checker system).Except Rust is in exactly the same boat as D, because the same issues that apply to ` trusted` apply to `unsafe`, as well.Hmmm, I guess that's true. I don't really know a lot about Rust. Their safety story just sounds way more convincing and believable than D's. It would probably be the first language I'd look into if I was interested in low level safety critical code.
Jun 27 2017
On Monday, 26 June 2017 at 18:47:18 UTC, Random D user wrote:On Monday, 26 June 2017 at 14:17:26 UTC, Adam D. Ruppe wrote:Hmm I really like this. If we could have an AttributeAliasSeq then we could solve all of the inversion problems by simply removing them from the list. This would also allow us to define a default set of attributes (in say core.attribute) that every symbol (except templates?) get tagged by. Then you could change the default set of attributes by a version switch. Or we could have the default attribute set apply to the module (declaration?) and be user overridable and then any explicit attributes applied to symbols override the default module attributes. I think I'll write a DIP for this after my honours thesis.1) Add the opposite attributes: `impure`, `throws`, ` gc`, etc. 2) Add the module version thing that changes defaults on request 3) imagine more potential going forwardI dislike doubling the keywords by having a 'not' case for each. I'd rather have a systematic way of adding/removing attributes and udas. Something like: gc !gc (previously nogc, compiler could even rewrite nogc into !gc for transition) --- Anyway, I think we could just have a compile time switch for defaults. Since some projects want to have pure, safe, immutable by default, but others want to have system nogc. And no one wants write attributes more than they have to. For example, I kind of like the current defaults since I like flexibility/changeability/editability of code. Because that makes coding fun which in turn usually means better code, features and productivity. Strictness is just a kind of salt that can be sprinkled on code in few difficult or dangerous cases. Also I think safe is a little bit broken (because of trusted and even the very pros (d-devs) seem to get trusted wrong on a regular basis (at least that's my perception)). Just bite the bullet and use Rust if you want to be actually safe. I'm not a huge fan of immutable/const system either as it's kind of difficult to use and low benefits. It often leads into backtracking and changing your code all over the place (small change becomes an avalanche), because you found out in the last leaf function of your subsystem, that your design can't actually be immutable (basically, you forgot or couldn't imagine that elusive corner case no. 99). The good thing is that immutable/const is actually strict and checkable. No holes like in safe. So if this change would happen, I would probably start all of my d files with impure: system: ( nogc:) // depending on my needs, I actually haven't had big issues with the gc (nothrow:) ... Which reminds me that it would be nice to group attributes as well. Something like this: alias apiStrict = safe immutable pure int foo() apiStrict { return 1; }
Jun 26 2017
On Tuesday, 27 June 2017 at 02:19:56 UTC, Nicholas Wilson wrote:I think I'll write a DIP for this after my honours thesis.Initial draft https://github.com/thewilsonator/DIPs/blob/Attributes/DIPs/DIPxxxx_attributes.md Don't expect much from me until 4th of July.
Jun 26 2017
On Tuesday, 27 June 2017 at 03:14:58 UTC, Nicholas Wilson wrote:On Tuesday, 27 June 2017 at 02:19:56 UTC, Nicholas Wilson wrote:https://github.com/dlang/DIPs/pull/75I think I'll write a DIP for this after my honours thesis.Initial draft https://github.com/thewilsonator/DIPs/blob/Attributes/DIPs/DIPxxxx_attributes.md Don't expect much from me until 4th of July.
Jul 03 2017
On Monday, 26 June 2017 at 14:17:26 UTC, Adam D. Ruppe wrote:// next gen D module version(3.0) foo.bar; // opt in here void whatever() {} // now safe by defaultThat's a really good idea.
Jun 26 2017
On 6/25/2017 9:31 PM, H. S. Teoh via Digitalmars-d wrote:It happens for template functions, member functions of templated aggregates (structs/classes), and auto functions.And all function literals, and all functions generated by the compiler (such as lazy delegates and aggregate destructors).
Nov 04 2017
On Monday, 26 June 2017 at 00:38:21 UTC, Mike wrote:IMO, part of the problem is that D has the wrong defaults (e.g. `immutable` by default, ` safe` by default, `final` by default, etc...), so users have to opt in to these things when they should really only be opting out of them. Unfortunately, changing this would be disruptive and will probably never happen without a fork.If/when D 3.0 happens, as a breaking change, hopefully the defaults can be made to be better right defaults. (D 1.x to D 2.x had *cough* some breaking changes.) OCaml that perhaps could be considered for D 3.0.
Nov 04 2017
On 04/11/2017 1:16 PM, Eljay wrote:On Monday, 26 June 2017 at 00:38:21 UTC, Mike wrote:Like signatures which I'm working on! https://github.com/rikkimax/DIPs/blob/master/DIPs/DIP1xxx-RC.mdIMO, part of the problem is that D has the wrong defaults (e.g. `immutable` by default, ` safe` by default, `final` by default, etc...), so users have to opt in to these things when they should really only be opting out of them. Unfortunately, changing this would be disruptive and will probably never happen without a fork.If/when D 3.0 happens, as a breaking change, hopefully the defaults can be made to be better right defaults. (D 1.x to D 2.x had *cough* some breaking changes.) could be considered for D 3.0.
Nov 04 2017
On Saturday, 4 November 2017 at 12:20:37 UTC, rikki cattermole wrote:Like signatures which I'm working on! https://github.com/rikkimax/DIPs/blob/master/DIPs/DIP1xxx-RC.mdThe first example kind of reminds me of what I was trying to do with isSubTypeOf [1]. If you know that any function you can call on T can also be called on U, then it has the same effect. That being said, I'm not sure I really understand what you mean in the whole "Why not extend interfaces" part. [1] https://github.com/dlang/phobos/pull/5700
Nov 04 2017
On 04/11/2017 2:14 PM, jmh530 wrote:On Saturday, 4 November 2017 at 12:20:37 UTC, rikki cattermole wrote:Okay so: A signature when it is initiated is aware of the implementation it is referencing. Allowing it to change how it behaves for compatibility reasons. An interface is designed so that a class/interface must know of the interface to inherit from. While signatures can and probably will inherit from others, this is not how it is used unlike with interfaces. Because this is a massive change in how we view them and their usage, extending interfaces is not appropriate. Luckily an already existing concept exists in the literature which does solve most of the goals and that is signatures from the ML family. I will make a mental note to rewrite that section.Like signatures which I'm working on! https://github.com/rikkimax/DIPs/blob/master/DIPs/DIP1xxx-RC.mdThe first example kind of reminds me of what I was trying to do with isSubTypeOf [1]. If you know that any function you can call on T can also be called on U, then it has the same effect. That being said, I'm not sure I really understand what you mean in the whole "Why not extend interfaces" part. [1] https://github.com/dlang/phobos/pull/5700
Nov 04 2017
On Saturday, 4 November 2017 at 13:27:29 UTC, rikki cattermole wrote:On 04/11/2017 2:14 PM, jmh530 wrote:It reminds a lot of traits in Rust. https://doc.rust-lang.org/1.8.0/book/traits.html[...]Okay so: A signature when it is initiated is aware of the implementation it is referencing. Allowing it to change how it behaves for compatibility reasons. An interface is designed so that a class/interface must know of the interface to inherit from. While signatures can and probably will inherit from others, this is not how it is used unlike with interfaces. Because this is a massive change in how we view them and their usage, extending interfaces is not appropriate. Luckily an already existing concept exists in the literature which does solve most of the goals and that is signatures from the ML family. I will make a mental note to rewrite that section.
Nov 04 2017
On 04/11/2017 6:13 PM, bauss wrote:On Saturday, 4 November 2017 at 13:27:29 UTC, rikki cattermole wrote:Rust traits are a variant of ML's signature. Only they decided to add a whole new concept which is 'impl' to it. While it is a nice idea, it would be a pain to use in real life and defeat the purpose of a signature. Which is to act as more of a 'concept' abstraction to other items. Because we have such powerful meta-programming features I see no reason to separate out the two. We can do it all in one which makes it nice and consistent between all the different implementations for a signature type. So far its starting to feel right at home against our structs and class support, I think.On 04/11/2017 2:14 PM, jmh530 wrote:It reminds a lot of traits in Rust. https://doc.rust-lang.org/1.8.0/book/traits.html[...]Okay so: A signature when it is initiated is aware of the implementation it is referencing. Allowing it to change how it behaves for compatibility reasons. An interface is designed so that a class/interface must know of the interface to inherit from. While signatures can and probably will inherit from others, this is not how it is used unlike with interfaces. Because this is a massive change in how we view them and their usage, extending interfaces is not appropriate. Luckily an already existing concept exists in the literature which does solve most of the goals and that is signatures from the ML family. I will make a mental note to rewrite that section.
Nov 04 2017
On Sunday, 5 November 2017 at 03:02:52 UTC, rikki cattermole wrote:On 04/11/2017 6:13 PM, bauss wrote:I like Rust's traits more than our way of ad-hoc specification of compile-time interfaces with is(typeof({...})) or __traits(compiles, ...). Given how most idiomatic D code is written, to me that's the biggest deficiency of the language. Reasonable people may, of course, disagree. AtilaOn Saturday, 4 November 2017 at 13:27:29 UTC, rikki cattermole wrote:Rust traits are a variant of ML's signature. Only they decided to add a whole new concept which is 'impl' to it. While it is a nice idea, it would be a pain to use in real life and defeat the purpose of a signature. Which is to act as more of a 'concept' abstraction to other items. Because we have such powerful meta-programming features I see no reason to separate out the two. We can do it all in one which makes it nice and consistent between all the different implementations for a signature type. So far its starting to feel right at home against our structs and class support, I think.[...]It reminds a lot of traits in Rust. https://doc.rust-lang.org/1.8.0/book/traits.html
Nov 06 2017
On Sunday, 25 June 2017 at 23:21:25 UTC, aberba wrote:Can you share feature(s) in D people are not talking about which you've found very useful?If you need to write a lightweight library or app with no GC and Phobos, you can fall back to C functions in core.stdc, my wavefile codec/utility (ADPCM, interpolation, resampling, etc.) is being written this way.
Jul 03 2017
On Sunday, 25 June 2017 at 23:21:25 UTC, aberba wrote:Can you share feature(s) in D people are not talking about which you've found very useful?How about the compiler option: -release then I don't have to care about your god damn contract anymore. ;-)
Nov 05 2017
On Sunday, 25 June 2017 at 23:21:25 UTC, aberba wrote:Can you share feature(s) in D people are not talking about which you've found very useful?I see none. ¯\_(ツ)_/¯ Everything is more or less discussed and known. I was not surprised when i saw that the topic went OT since (almost) the beginning.
Nov 07 2017
On Sunday, 25 June 2017 at 23:21:25 UTC, aberba wrote:Can you share feature(s) in D people are not talking about which you've found very useful?Some of the best features are in the standard library. I've written about them here: http://nomad.so/2014/08/hidden-treasure-in-the-d-standard-library/ http://nomad.so/2015/08/more-hidden-treasure-in-the-d-standard-library/
Nov 07 2017
On Tuesday, 7 November 2017 at 17:15:02 UTC, Gary Willoughby wrote:On Sunday, 25 June 2017 at 23:21:25 UTC, aberba wrote:It's mentioned in Gary's articles, but std.conv.to is fantastic.Can you share feature(s) in D people are not talking about which you've found very useful?Some of the best features are in the standard library. I've written about them here: http://nomad.so/2014/08/hidden-treasure-in-the-d-standard-library/ http://nomad.so/2015/08/more-hidden-treasure-in-the-d-standard-library/
Nov 07 2017
On Sunday, 25 June 2017 at 23:21:25 UTC, aberba wrote:Can you share feature(s) in D people are not talking about which you've found very useful?How about this feature: i.e. it actually compiles just fine ;-) //------------------------------------------------------------ module test; void main() { void main() { void main() { void main() { void main() { void main() { void main() { //and so on... and so on....and so on.... } } } } } } } //------------------------------------------------------------
Nov 07 2017
On Wednesday, 8 November 2017 at 01:24:57 UTC, codephantom wrote:On Sunday, 25 June 2017 at 23:21:25 UTC, aberba wrote:I laughed. At it's even funnier when you realize that there's actually generated assembly code for the nested main functions: ``` void test.main().main(): push %rbp mov %rsp,%rbp sub $0x10,%rsp mov %rdi,-0x8(%rbp) leaveq retq xchg %ax,%ax ``` However as you can see it only generates for one of the nested functions, the rest are omitted. You can never call the function though :pCan you share feature(s) in D people are not talking about which you've found very useful?How about this feature: i.e. it actually compiles just fine ;-) //------------------------------------------------------------ module test; void main() { void main() { void main() { void main() { void main() { void main() { void main() { //and so on... and so on....and so on.... } } } } } } } //------------------------------------------------------------
Nov 07 2017