Lazy range of hashes?

Era Scarecrow rtcvb32 at yahoo.com
Sun Aug 26 00:55:56 PDT 2012


On Sunday, 26 August 2012 at 07:29:13 UTC, Ali Çehreli wrote:
> Cool! :) If the operator returns the pointer to the element, 
> then the callers can access its value as well

  Reminds me, although not for you Ali, but as a pointer return a 
question came up. I've wondered and haven't tested this but 
hypothetically:

  Due to that you can call structures and class members even from 
a pointer (transparently compared to C/C++), does it 
automatically convert from a pointer to a non-pointer type if the 
return calls for it? In a class that's irrelevant (it's already a 
reference type and should auto-fix itself); But a struct or 
non-class?

  //just to get the idea
  //potentially ref int, rather than int* as well
  int getSomeValue(int[string] x, string someValue) {
    auto sv = someValue in x;
    return x ? x : 0; //auto convert? Or error? If not, why?
  }

  Rather than auto could ref work? Or if it's a exact valueType 
(with postblitz) or (known to be relocatable) would it make a new 
copy? I can see the importance of both, but depending on the 
return type in cases, having it throw an error seems like the 
best policy if it's a non-built in, since it's trivial changing 
return x, with return *x; Also as a built in type it could 
automatically do the copy/conversion for you.


More information about the Digitalmars-d-learn mailing list