Re: Interview with InformIT part 2/3

2010-08-19 Thread ponce
> In the meantime that Reddit thread is one of the worst I've seen on that 
> usually interesting site. Some C++ programmers seem to hate D a lot.

In my experience, convincing someone who have personally  invested a lot in C++ 
is _hard_. People who care about big teams are not convinced at all by language 
features, and need to be told more about the safety concerns, gettting less 
bugs, improved productivity.


Re: dmd 1.063 and 2.048 release

2010-08-19 Thread Jordi

On 08/17/2010 02:35 AM, Walter Bright wrote:

Jordi wrote:

Found it. It took me 7 iterations of binary search across the svn
repositories for dmd, druntime and phobos. The commit causing the
issue is 505 in dmd. It is related to structs returning *this, which
indeed i do in my maths structs.

Now, i don't know if the bug is in dmd or in my code, but i suspect
that something is being treated as a reference when it shouldn't.
Should i add an issue even if i am not sure?


Try to reduce it to the smallest possible reproducible test case, and
then post it to bugzilla.


Instead of "peeling off" my project, which is hundreds of files and a 
lot of code, i tried to reproduce it in a small test case emulating the 
matrix operations i was suspecting of. I didn't succeed though.


I will try again when i come back from some holidays. I don't explicitly 
use "inline" anywhere though. I guess the compiler does some inlining 
anyway. Maybe if i can disable it, i can see if anything changes.


I do "return this" however in some struct methods, for example:

Transform opMulAssign( const Transform t )
{
m_origin += m_basis * t.m_origin;
m_basis *= t.m_basis;
m_type |= t.m_type;
return this;
}

and others. But even if "this" is a reference like Lars pointed out, the 
method should return a copy of the struct by value, right?


Regards,

j.


Re: Interview with InformIT part 2/3

2010-08-19 Thread Leandro Lucarella
Walter Bright, el 18 de agosto a las 12:25 me escribiste:
> Leandro Lucarella wrote:
> >Walter Bright, el 18 de agosto a las 10:08 me escribiste:
> >>bearophile wrote:
> >>>Currently in the D2 GC there is no notion of pinned/unpinned class 
> >>>instances,
> >>>but eventually an attribute as @pinned may be added to D3, plus its related
> >>>semantics. It adds complexity to the language and it needs to interact with
> >>>the GC, so it will get useful as the D GC becomes more modern (with 
> >>>different
> >>>zones for newly allocated objects, etc).
> >>There is no need for a pin attribute, the gc can determine if a
> >>class needs pinning or not.
> >
> >As long as the precise heap scanning patch is applied (and much better
> >if we can manage to scan the static data precisely too). Otherwise you
> >simply just can't move stuff around because you don't know what is
> >a pointer and what is not (thus you can't update pointer that point to
> >moved stuff).
> 
> Hence the objects with ambiguous references to them get
> automatically pinned by the gc. I've implemented such a gc before,
> it works fine. It's called a "mostly copying collector".

Even when you say is true, the GC can automatically determine if
something should be pinned when *EVERYTHING* is pinned, it's not very
useful :)

> Besides, any scheme where you have to manually mark pinnable objects
> is doomed to have disastrously subtle and hard-to-find bugs.

I'm not arguing in favor of manual pinning, I completely agree is a bad
idea. I'm just saying that, as things are, in D you can't implement
a moving collector, because *ALL* the memory is pinned because if fully
conservative.

With the precise heap scanning patch for DMD the GC can automatically
pin memory, because it has enough information to differentiate between
real pointers and words which types are not really known, so a block can
be moved *only* if is only pointed to by real pointers, otherwise is
pinned because we can't update the words with unknown type if we moved
that block.

-- 
Leandro Lucarella (AKA luca) http://llucax.com.ar/
--
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
--
Hey you, out there in the cold
Getting lonely, getting old
Can you feel me?


Re: Interview with InformIT part 2/3

2010-08-19 Thread Leandro Lucarella
Walter Bright, el 18 de agosto a las 15:31 me escribiste:
> bearophile wrote:
> >Walter Bright:
> >
> >>There is no need for a pin attribute, the gc can determine if a class needs
> >> pinning or not.
> >
> >The same is probably true for pure functions too, the compiler can determine
> >what functions are pure and what are not pure.
> >
> >But the purpose of a @pinned is that: 1) The default becomes unpinned. This
> >is good for the GC, because moving memory around is good to compact the heap,
> >etc. 2) The programmer states hir/her/his purpose, this is documentation, but
> >it's an alive documentation because as with pure the compiler is able to
> >determine if the attribute is used wrongly, and give a compile time error in
> >such case.
> 
> The other problem with a pinned/notpinned object is the object
> itself cannot control who or how someone is pointing to it.

Exactly, manually pinning is really completely unpractical, the analogy
between pure and pinned makes very little sense.

I can see some very very weird use case where you want to arbitrarily
mark some block pinned, but I think manual unpinning is just to
dangerous to be useful. And for the former, you can easily force pinning
by having a pointer to it in a portion of memory that is scanned
conservatively.

-- 
Leandro Lucarella (AKA luca) http://llucax.com.ar/
--
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
--
Y2K
 hmm, nothing major has happend, what an anticlimax
 yeah
 really sucks
 I expected for Australia to sink into the sea or something
 but nn


Re: dmd 1.063 and 2.048 release

2010-08-19 Thread Walter Bright

Jordi wrote:
But even if "this" is a reference like Lars pointed out, the 
method should return a copy of the struct by value, right?


Yes.


Re: Interview with InformIT part 2/3

2010-08-19 Thread Walter Bright

Leandro Lucarella wrote:

With the precise heap scanning patch for DMD the GC can automatically
pin memory, because it has enough information to differentiate between
real pointers and words which types are not really known, so a block can
be moved *only* if is only pointed to by real pointers, otherwise is
pinned because we can't update the words with unknown type if we moved
that block.



I know. That's how a mostly copying collector works.


Re: Interview with InformIT part 2/3

2010-08-19 Thread Leandro Lucarella
Walter Bright, el 19 de agosto a las 13:08 me escribiste:
> Leandro Lucarella wrote:
> >With the precise heap scanning patch for DMD the GC can automatically
> >pin memory, because it has enough information to differentiate between
> >real pointers and words which types are not really known, so a block can
> >be moved *only* if is only pointed to by real pointers, otherwise is
> >pinned because we can't update the words with unknown type if we moved
> >that block.
> 
> I know. That's how a mostly copying collector works.

If you know, I guess you agree on the utility of the patch and the
impossibility of implementing a mostly moving collector in D, so I hope
you apply the patch eventually =)

-- 
Leandro Lucarella (AKA luca) http://llucax.com.ar/
--
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
--
Hey you, standing in the road
always doing what you're told,
Can you help me?