January 08, 2015 Re: idiomatic D: what to use instead of pointers in constructing a tree data structure? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Baz |
>>>
>>> what's wrong with the code above ? i get an error no identifier for declarator node. (I have not used classes much, since structs often seem to be enough for what I need to do mostly).
>>
>> ref is a reserved keyword.
>>
>> --
>> Paulo
>
> this conversation is so funny: well what's wrong with this . It's a keyword...
> Aa Ha ha ha ha , rol.
> Seriously, is it so complicated to use a D editor ? I mean with syntax color...
No need to make fun of anyone.
|
January 08, 2015 Re: idiomatic D: what to use instead of pointers in constructing a tree data structure? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Baz |
> this conversation is so funny: well what's wrong with this . It's a keyword...
> Aa Ha ha ha ha , rol.
> Seriously, is it so complicated to use a D editor ? I mean with syntax color...
Man afraid to ask stoopid questions stays stoopid. And compiler error message far from informative.
Not everyone is very visually oriented, and sometimes vi is quicker.
|
January 08, 2015 Re: idiomatic D: what to use instead of pointers in constructing a tree data structure? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Laeeth Isharc | On Thursday, 8 January 2015 at 11:29:30 UTC, Laeeth Isharc wrote:
>
>> this conversation is so funny: well what's wrong with this . It's a keyword...
>> Aa Ha ha ha ha , rol.
>> Seriously, is it so complicated to use a D editor ? I mean with syntax color...
>
> Man afraid to ask stoopid questions stays stoopid. And compiler error message far from informative.
> Not everyone is very visually oriented, and sometimes vi is quicker.
don't worry about it. use whatever you're comfortable with.
|
January 08, 2015 Re: idiomatic D: what to use instead of pointers in constructing a tree data structure? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On 1/8/15 12:15 AM, Meta wrote:
> On Wednesday, 7 January 2015 at 23:27:19 UTC, anonymous wrote:
>> Don't do this without `dup`ing. Quoting the documentation:
>
> Oh, whoops. I thought those special variadic args were always allocated
> on the heap.
Nope,
Which makes it annoying, what if the argument IS passed on the heap?
Fortunately, there is a solution (one I use in dcollections):
foo(T[] x...)
foo(T[] x)
Can be overloaded. If you ever pass in parameters one at a time, the first is called, and x is guaranteed to be on the stack.
The second is called with an actual array only, you are able to not 'dup', and just warn people that x will NOT be dup'd in that case.
-Steve
|
January 08, 2015 Re: idiomatic D: what to use instead of pointers in constructing a tree data structure? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Laeeth Isharc | On Thu, Jan 08, 2015 at 11:29:29AM +0000, Laeeth Isharc via Digitalmars-d-learn wrote: > > >this conversation is so funny: well what's wrong with this . It's a > >keyword... > >Aa Ha ha ha ha , rol. > >Seriously, is it so complicated to use a D editor ? I mean with > >syntax color... > > Man afraid to ask stoopid questions stays stoopid. And compiler error > message far from informative. > Not everyone is very visually oriented, and sometimes vi is quicker. Vim supports syntax highlighting. But I don't use it either -- I find it distracts from clarity of thought. I use plain vanilla vim in a text-only terminal. T -- Those who've learned LaTeX swear by it. Those who are learning LaTeX swear at it. -- Pete Bleackley |
January 08, 2015 Re: idiomatic D: what to use instead of pointers in constructing a tree data structure? | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On 01/08/2015 09:40 AM, H. S. Teoh via Digitalmars-d-learn wrote: > Vim supports syntax highlighting. > > But I don't use it either -- I find it distracts from clarity of > thought. I use plain vanilla vim in a text-only terminal. I am halfway there: I use syntax highlighting in Emacs but I chose to make keywords and variables the same color. Ali |
January 08, 2015 Re: idiomatic D: what to use instead of pointers in constructing a tree data structure? | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On Thursday, 8 January 2015 at 17:42:23 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
> On Thu, Jan 08, 2015 at 11:29:29AM +0000, Laeeth Isharc via Digitalmars-d-learn wrote:
>>
>> >this conversation is so funny: well what's wrong with this . It's a
>> >keyword...
>> >Aa Ha ha ha ha , rol.
>> >Seriously, is it so complicated to use a D editor ? I mean with
>> >syntax color...
>>
>> Man afraid to ask stoopid questions stays stoopid. And compiler error
>> message far from informative.
>> Not everyone is very visually oriented, and sometimes vi is quicker.
>
> Vim supports syntax highlighting.
>
> But I don't use it either -- I find it distracts from clarity of
> thought. I use plain vanilla vim in a text-only terminal.
>
>
> T
I don't get this, then again I am using syntax highlighting editors since MS-DOS IDEs supported it.
--
Paulo
|
January 08, 2015 Re: idiomatic D: what to use instead of pointers in constructing a tree data structure? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paulo Pinto | On Thu, Jan 08, 2015 at 07:13:28PM +0000, Paulo Pinto via Digitalmars-d-learn wrote: > On Thursday, 8 January 2015 at 17:42:23 UTC, H. S. Teoh via Digitalmars-d-learn wrote: [...] > >Vim supports syntax highlighting. > > > >But I don't use it either -- I find it distracts from clarity of thought. I use plain vanilla vim in a text-only terminal. [...] > I don't get this, then again I am using syntax highlighting editors since MS-DOS IDEs supported it. [...] It's just a personal preference. I find that overuse of colors produces a kaleidoscopic rainbow pattern on the screen which, while pretty, distracts from the essence of the code itself, which is what I'm focusing on. It's like a webpage with every other word italicized and/or bolded -- after a while, your brain just tunes it out and it becomes just meaningless (and distracting) noise. I much rather learn to parse the text (resp. code) accurately by eye and let it speak for itself. T -- Those who've learned LaTeX swear by it. Those who are learning LaTeX swear at it. -- Pete Bleackley |
January 08, 2015 Re: idiomatic D: what to use instead of pointers in constructing a tree data structure? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Laeeth Isharc | On 07/01/15 16:02, Laeeth Isharc via Digitalmars-d-learn wrote: > class node > { > string name; > node ref; > } Small recommendation (apart from the reserved word issue which you fixed): it's generally considered good D style to give structs and classes names that start with capital letters, JustLikeThis. So, I suggest Node rather than node. Very minor point, and of course, your code is yours to style as you wish, but it can be helpful to meet the "standard" style conventions in order to make it as easy as possible for everyone else to understand. See also: http://dlang.org/dstyle.html |
January 10, 2015 Re: idiomatic D: what to use instead of pointers in constructing a tree data structure? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joseph Rushton Wakeling | > Small recommendation (apart from the reserved word issue which you fixed): it's generally considered good D style to give structs and classes names that start with capital letters, JustLikeThis. So, I suggest Node rather than node.
>
> Very minor point, and of course, your code is yours to style as you wish, but it can be helpful to meet the "standard" style conventions in order to make it as easy as possible for everyone else to understand.
Thanks for the reminder. I use D Style when I am writing properly, but haven't yet internalized it for a quick example and old habits die hard.
|
Copyright © 1999-2021 by the D Language Foundation