| > When the GC discovers a selector function applied to an evaluated
| > argument, it "evaluates" the selector on-the-fly by just swizzling
| > pointers.  It needs some co-operation from the compiler to make
| > selector functions look obvious, but that isn't too difficult.
| 
| So ghc doesn't do this (or something better)? I'm surprised
| because it seems like a really basic and simple feature to me. I
| implemented a toy FPL a few years ago and even my gc incorporated
| this optimisation. It's a bit strange that this should have been
| overlooked considering in all other respects ghc is far more
| sophisticated than my efforts were :-)

It does; see my reply below

| -----Original Message-----
| From: [EMAIL PROTECTED]
[mailto:glasgow-haskell-users-
| [EMAIL PROTECTED] On Behalf Of Simon Peyton-Jones
| Sent: 17 August 2004 17:25
| To: Malcolm Wallace; [EMAIL PROTECTED]
| Subject: RE: Space usage
| 
| 
| | You probably mean
| |     J. Sparud, "Fixing Some Space Leaks without a Garbage
Collector",
| FPCA'93.
| |     http://citeseer.ist.psu.edu/sparud93fixing.html
| 
| Indeed.
| 
| | as implemented in hbc.  It is also possible to use Wadler's
| | garbage-collector fix for this space leak, as implemented in nhc98.
| |     P Wadler, "Fixing a Space Leak with a Garbage Collector", SP&E
| Sept 1987.
| |
| | When the GC discovers a selector function applied to an evaluated
| | argument, it "evaluates" the selector on-the-fly by just swizzling
| | pointers.  It needs some co-operation from the compiler to make
| | selector functions look obvious, but that isn't too difficult.
| 
| GHC does this, but it does not always work.  What starts as
|       let x = fst t in
|       let h = case x of { True -> 1; False -> 2 } in
|       ...
| may become
|       let h = case t of { (x,_) -> case x of {True->1;False->2} }
|       ...
| and now there is no selector thunk any more.  So the selector stuff is
| fragile to otherwise-valuable optimisations. And that's what's
happening
| in this case.  A non-optimising compiler is fine.
| 
| Simon

| 
| Regards
| --
| Adrian Hey
| 
| _______________________________________________
| Glasgow-haskell-users mailing list
| [EMAIL PROTECTED]
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to