From: Trans Date: 2005-03-25T00:29:49+09:00 Subject: Re: RCR 296: Destructive methods return self Matt Maycock wrote: > > Yet that doesn't seem at all useful for non-destructive methods. > > "obj->strip" would be pointless, I think. It would be more useful if > > any method could act destructively. As I suggested earlier: "obj!sort". > > Perhaps a better notation for this would be your suggestion > > "obj->sort". But this is all quite speculative given that matz has > > never seemed too keen in pursing generalized in-place modification. > > But it is useful if you are not self-destructive (ie, you are still > doing side effects, but effecting the world instead of just self). Ah, fair point. > Matz may be against generalized in-place modifications (so am I - I'm > a haskell kid at heart), but it does get used. When efficiency is > needed, fp is dropped for scripting, and then for more efficient > scripting, and then for C. But what I'm suggesting has nothing to do > with in place scripting, but is really just a sort of with statement, > but I think rather more elegant than the kind that comes with VB, and > is syntactically pleasant. Right, I realize. Just seemded to me that a "with" statement is primarily useful with in-place methods. So I thought to take your suggestion all the way to that point. But you are right, there is a potential use without destructive methods, albiet less common. > I think that without a stricter type system, having the interpretter > make good use of turning a invocation into a modification might be > harder than you think (maybe even in general impossible - but good > enough in practice) - leaving the details up to us at this particular > level might be a good idea. Yes, I imagine you are right. I am an unclear as to exactly how this works. I know some have done such a thing (evil.rb for instance). But I have also heared the phrase "segmentation fault" in reference to such things too. There must be complications that I am unaware-of. T.