Re: [GHC] #7111: record single inheritance, partial solution to record problem

2012-10-14 Thread GHC
#7111: record single inheritance, partial solution to record problem
-+--
Reporter:  centaurian_slug   |   Owner:  
Type:  feature request   |  Status:  new 
Priority:  normal|   Milestone:  
   Component:  Compiler  | Version:  7.4.2   
Keywords:|  Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  | Failure:  None/Unknown
  Difficulty:  Unknown   |Testcase:  
   Blockedby:|Blocking:  
 Related:|  
-+--
Changes (by igloo):

  * difficulty:  = Unknown


Old description:

 The record system reminded me of the situation in assembly language.
 Could single inheritance of records allow some shared field names as a
 stopgap solution without breaking much of the existing language and
 source, or precluding future solutions to this issue;

 Under this proposal, accessor functions in the same namespace would
 always access the same slot.

 imagine a keyword 'extends' in a data constructor that creates any
 boilerplate behind the scenes.

 data Base = Base { slotA::Int32, slotB::Int32 }
 data Foo = Foo extends Base { foo :: Int32 }
 data Bar = Bar extends Base { bar1 :: Float,bar2 ::Float }

 'slotA' is now always a function to extract the first element of a 2,3,4
 element tuple
 'slotB' is now always a function to extract the second element of a 2,3,4
 element tuple
 'foo' is a functions to extract the 3rd slot.
 'bar1','bar2' are functions to extract the 3rd,4th slots

 by analogy with c++,
 struct Base {
   int32 slotA,int32 slotB;
 };  'a' now corresponds to an memory offset of 0
 'b' now corresponds to an memory offset of 4
 struct Foo : public Base
 {
   int32 foo;
 };
'foo' now corresponds to a memory offset of 8
 struct Bar : public Base
 {
   float bar1;
   float bar2;
 };
  //  'bar1' now corresponds to a memory offset of 8
  //  'bar2' now corresponds to a memory offset of 12
  //  'a' corresponds to a ptr offset of 0, for all types
 //   'b' corresponds to a ptr offset of 4 for all types

 By analogy to  assembly-language:-

 ; declare 'Base' datsstructure elements
 RSRESET ;clear structure offset counter
 slotARW 1   ; reserve 1 word for 'slotA'
 slotBRW 1
 baseSize RW 0

 ; declare 'Foo' datastructure elements
 RSSET baseSize  ; 'Foo' extends 'Base', set counter to end of 'Base'
 foo  RW 1
 fooSize  RW 0

 ; declare  'Bar' datastructure members
 RSSET baseSize ; 'Bar' extends 'Base'
 bar1  RW 1
 bar2  RW 1
 barSize  RW 0

 ;result:- (4byte words)
 ;slotA=0, slotB=4, foo=8,  bar1=8, bar2=12
 ; baseSize=0;  fooSize=12;   barSize=16

New description:

 The record system reminded me of the situation in assembly language.
 Could single inheritance of records allow some shared field names as a
 stopgap solution without breaking much of the existing language and
 source, or precluding future solutions to this issue;

 Under this proposal, accessor functions in the same namespace would always
 access the same slot.

 imagine a keyword 'extends' in a data constructor that creates any
 boilerplate behind the scenes.
 {{{
 data Base = Base { slotA::Int32, slotB::Int32 }
 data Foo = Foo extends Base { foo :: Int32 }
 data Bar = Bar extends Base { bar1 :: Float,bar2 ::Float }
 }}}
 'slotA' is now always a function to extract the first element of a 2,3,4
 element tuple
 'slotB' is now always a function to extract the second element of a 2,3,4
 element tuple
 'foo' is a functions to extract the 3rd slot.
 'bar1','bar2' are functions to extract the 3rd,4th slots

 by analogy with c++,
 {{{
 struct Base {
   int32 slotA,int32 slotB;
 };  'a' now corresponds to an memory offset of 0
 'b' now corresponds to an memory offset of 4
 struct Foo : public Base
 {
   int32 foo;
 };
'foo' now corresponds to a memory offset of 8
 struct Bar : public Base
 {
   float bar1;
   float bar2;
 };
  //  'bar1' now corresponds to a memory offset of 8
  //  'bar2' now corresponds to a memory offset of 12
  //  'a' corresponds to a ptr offset of 0, for all types
 //   'b' corresponds to a ptr offset of 4 for all types
 }}}
 By analogy to  assembly-language:-
 {{{
 ; declare 'Base' datsstructure elements
 RSRESET ;clear structure offset counter
 slotARW 1   ; reserve 1 word for 'slotA'
 slotBRW 1
 baseSize RW 0

 ; declare 'Foo' datastructure elements
 RSSET baseSize  ; 'Foo' extends 'Base', set counter to end of 'Base'
 foo  RW 1
 fooSize  RW 0

 ; declare  'Bar' datastructure members
 RSSET baseSize ; 'Bar' extends 'Base'
 bar1  RW 1
 bar2  RW 1
 barSize  RW 0

 ;result:- (4byte words)
 ;slotA=0, slotB=4, foo=8,  bar1=8, bar2=12
 ; baseSize=0;  fooSize=12;   barSize=16
 }}}

--

-- 
Ticket 

Re: [GHC] #7111: record single inheritance, partial solution to record problem

2012-10-14 Thread GHC
#7111: record single inheritance, partial solution to record problem
---+
  Reporter:  centaurian_slug   |  Owner:  
  Type:  feature request   | Status:  closed  
  Priority:  normal|  Milestone:  
 Component:  Compiler  |Version:  7.4.2   
Resolution:  wontfix   |   Keywords:  
Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown  | Difficulty:  Unknown 
  Testcase:|  Blockedby:  
  Blocking:|Related:  
---+
Changes (by igloo):

  * status:  new = closed
  * resolution:  = wontfix


Comment:

 Thanks for the suggestion. However, I think record system extensions need
 some more discussion and design work, for which the mailing lists and
 wikis are better forums than tickets, so I'm closing this ticket.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7111#comment:3
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs