#3895: "Fix" pervasive-but-unnecessary signedness in GHC.Prim
---------------------------------+------------------------------------------
    Reporter:  pumpkin           |       Owner:              
        Type:  proposal          |      Status:  new         
    Priority:  normal            |   Component:  Compiler    
     Version:                    |    Keywords:              
          Os:  Unknown/Multiple  |    Testcase:              
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown
---------------------------------+------------------------------------------
 I'm talking about the array primitives in particular:

 {{{
 writeFloatArray# :: MutableByteArray# s -> Int# -> Float# -> State# s ->
 State# s
 }}}

 Conceptually, a Word# makes more sense as the index for all the array
 functions. I'm not even sure what the semantics are if the Int# is
 negative... is it checked? The three scenarios I can think of are:

 Negativity is checked, and you get an exception.
 Negativity is unchecked, and you get to write to memory that comes before
 your array.
 Negativity is ignored, and the back-end treats the Int# like a Word#
 already.

 I think the switch would be worthwhile in all of those cases, and could be
 hidden in higher-level APIs that still use Int for indexes with a simple
 int2Word#. Eventually we might even migrate to Word-based APIs at that
 level?

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3895>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to