What’s Wrong with OOP and FP
John Colvin
john.loughran.colvin at gmail.com
Wed Nov 13 06:43:21 PST 2013
On Wednesday, 13 November 2013 at 12:05:51 UTC, logicchains wrote:
> On Wednesday, 13 November 2013 at 11:30:14 UTC, eles wrote:
>> On Wednesday, 13 November 2013 at 10:19:34 UTC, logicchains
>> wrote:
>>> On Wednesday, 13 November 2013 at 09:12:40 UTC, Jonathan M
>>> Davis wrote:
>>
>>> struct, then I have to write (*pt).X to access field X of that
>>
>> It is in our guidelines too. I almost never write "->".
>
> Ah, right. I just tested, and turns out Go does actually
> automatically dereference pointers to structs, but not to
> arrays. So if arrp is a pointer to an array, writing arrp[0] is
> a syntax error in Go, and it must be written as (*arrp)[0]. D
> on the other hand, as far as I'm aware (correct me if I'm
> wrong), would automatically dereference the pointer.
nope. a pointer can be indexed like in C. ptr[n] is equivalent to
*(ptr + n) irrespective of what the target type of the pointer
is. Fully expanded for T* ptr : *(cast(T*)( (cast(void*)ptr) +
(T.sizeof * n) ))
More information about the Digitalmars-d
mailing list