Address of a variable: Difference between revisions
Content deleted Content added
Recombinant (talk | contribs) m →{{header|Zig}}: update @ptrToInt() to @intFromPtr() for Zig 0.11.0 |
Added Quackery. |
||
Line 1,786: | Line 1,786: | ||
In addition some folks have written binary Python modules which implement "peek" and "poke" operations, but these are non-standard. |
In addition some folks have written binary Python modules which implement "peek" and "poke" operations, but these are non-standard. |
||
=={{header|Quackery}}== |
|||
Quackery does not have variables, and its memory model is based on dynamic arrays ("nests" in Quackery parlance) rather than a single continuous block of RAM, so, for example, an entry on the return stack has two parts; a pointer to a nest and a numerical offset into the nest (i.e. the location of an item within the nest) If the offset is non-negative, the offset is from the (zero-based) start of the nest, and if the offset is negative it is from the end of the nest, with the last item in the nest being at position -1. |
|||
The word <code>peek</code> returns a item located within a nest, given a nest and an offset. |
|||
The word <code>poke</code> takes a Quackery object, a nest, and an offset as arguments and returns a new nest, similar to the argument nest, except with the contents of the offset location replaced by the specified object. (Nests are immutable except under specific circumstances.) |
|||
Illustrating this as a dialogue in the shell (the Quackery REPL.) |
|||
<pre>/O> [ 10 11 12 13 14 ] is mynest ( create a named nest containing numbers ) |
|||
... ' mynest 2 peek echo ( print the content of item #2 in mynest ) |
|||
... |
|||
12 |
|||
Stack empty. |
|||
/O> 99999 ' mynest 2 poke echo ( replace 12 with 99999 and print result ) |
|||
... |
|||
[ 10 11 99999 13 14 ] |
|||
Stack empty.</pre> |
|||
<code>quid</code> returns a numerical value associated with an object in Quackery. See the discussion of <code>id()</code> in the [[Address of a variable#Python|Python entry]]. Quackery is implemented in Python, and <code>quid</code> in Quackery is equivalent to <code>id()</code> in Python. |
|||
=={{header|QB64}}== |
=={{header|QB64}}== |