3 ms·
"even integers are boxed by default" Um... why? For example, 2 is.. 2. 2 is not 3. If I "box" 2, can I then make it 3? Some very old FORTRAN implementations a
by ratboy666 11y ago
"even integers are boxed by default"
Um... why? For example, 2 is.. 2. 2 is not 3. If I "box" 2, can I then make it 3?
Some very old FORTRAN implementations actually allowed this:
subroutine x(j)
write(,)j
j = 3
return
do 1 i = 1,2
1 x(4)
4
3
(sorry... it's been years). Note that the reference is
immutable (j refers to a single location) -- but the value
is boxed (4 is put into a memory location). And this is
why this can even work.
FredW
- Veedrac 11y agoYour code is quite hard to read, especially as I don't know Fortran. Can I have it with indentation (indent each line 2+ spaces to make a code block)? --- Integers are boxed because Haskell's semantics almost exclusively deal with boxed types (eg. you can't pass unboxed types to most functions). The optimizer might specialize some functions for boxed types, but this is a transparent optimization and does not affect semantics.