@@ -354,31 +354,31 @@ func (nm *NumberMethods) CharArrayInit(size int, init any) []Char {
354354 return ret
355355}
356356
357- func (nm * NumberMethods ) Bytes (x any ) []byte {
358- return x .([]byte )
357+ func (nm * NumberMethods ) Bytes (x any ) []int8 {
358+ return x .([]int8 )
359359}
360360
361- func (nm * NumberMethods ) ByteArray (sizeOrSeq any ) []byte {
361+ func (nm * NumberMethods ) ByteArray (sizeOrSeq any ) []int8 {
362362 if IsNumber (sizeOrSeq ) {
363- return make ([]byte , MustAsInt (sizeOrSeq ))
363+ return make ([]int8 , MustAsInt (sizeOrSeq ))
364364 }
365365 s := Seq (sizeOrSeq )
366366 size := Count (sizeOrSeq )
367- ret := make ([]byte , size )
367+ ret := make ([]int8 , size )
368368 for i := 0 ; i < size && s != nil ; i , s = i + 1 , s .Next () {
369369 ret [i ] = AsByte (s .First ())
370370 }
371371 return ret
372372}
373373
374- func (nm * NumberMethods ) ByteArrayInit (size int , init any ) []byte {
375- ret := make ([]byte , size )
376- if b , ok := init .( byte ); ok {
374+ func (nm * NumberMethods ) ByteArrayInit (size int , initOrSeq any ) []int8 {
375+ ret := make ([]int8 , size )
376+ if b , ok := initOrSeq .( int8 ); ok {
377377 for i := 0 ; i < size ; i ++ {
378378 ret [i ] = b
379379 }
380380 } else {
381- s := Seq (init )
381+ s := Seq (initOrSeq )
382382 for i := 0 ; i < size && s != nil ; i , s = i + 1 , s .Next () {
383383 ret [i ] = AsByte (s .First ())
384384 }
@@ -652,38 +652,40 @@ func AsFloat64(x any) float64 {
652652}
653653
654654var (
655- byteType = reflect .TypeOf (byte (0 ))
655+ // We use int8 to match clojure's (Java's) byte type for consistency
656+ // with other clojure dialects.
657+ byteType = reflect .TypeOf (int8 (0 ))
656658)
657659
658- func AsByte (x any ) byte {
660+ func AsByte (x any ) int8 {
659661 switch x := x .(type ) {
660662 case int :
661- return byte (x )
663+ return int8 (x )
662664 case uint :
663- return byte (x )
665+ return int8 (x )
664666 case int8 :
665- return byte (x )
667+ return int8 (x )
666668 case int16 :
667- return byte (x )
669+ return int8 (x )
668670 case int32 :
669- return byte (x )
671+ return int8 (x )
670672 case int64 :
671- return byte (x )
673+ return int8 (x )
672674 case uint8 :
673- return byte (x )
675+ return int8 (x )
674676 case uint16 :
675- return byte (x )
677+ return int8 (x )
676678 case uint32 :
677- return byte (x )
679+ return int8 (x )
678680 case uint64 :
679- return byte (x )
681+ return int8 (x )
680682 case float32 :
681- return byte (x )
683+ return int8 (x )
682684 case * Ratio :
683685 f , _ := x .val .Float64 ()
684- return byte (f )
686+ return int8 (f )
685687 default :
686- panic ("cannot convert to float64 " )
688+ panic ("cannot convert to int8 " )
687689 }
688690}
689691
@@ -809,11 +811,11 @@ func ByteCast(x any) int8 {
809811 return int8 (l )
810812}
811813
812- func UncheckedByteCast (x any ) byte {
813- if b , ok := x .(byte ); ok {
814+ func UncheckedByteCast (x any ) int8 {
815+ if b , ok := x .(int8 ); ok {
814816 return b
815817 }
816- return byte (AsInt64 (x ))
818+ return int8 (AsInt64 (x ))
817819}
818820
819821func CharCast (x any ) Char {
0 commit comments