Pointers and references: Difference between revisions

Content added Content deleted
(→‎{{header|Racket}}: Remove from wrong place)
(→‎{{header|Racket}}: re-add in the right place)
Line 902: Line 902:


[Note: in some ways this task is meaningless for Python given the nature of its "variable" binding semantics].
[Note: in some ways this task is meaningless for Python given the nature of its "variable" binding semantics].

=={{header|Racket}}==

As in many other functional languages, Racket doesn't have pointers to its own values. Instead, Racket uses "boxes" that are similar to "ref" types in *ML:
<lang racket>
#lang racket

(define (inc! b) (set-box! b (add1 (unbox b))))

(define b (box 0))
(inc! b)
(inc! b)
(inc! b)
(unbox b) ; => 3
</lang>

In addition, Racket has a representation of traditional C pointers as part of its FFI, but this is intended only for dealing with foreign code.


=={{header|SAS}}==
=={{header|SAS}}==