Re: peek/poke

new topic     » goto parent     » topic index » view thread      » older message » newer message

Brian Broker wrote:

>On Mon, 27 Mar 2000 20:19:48 -0500, Everett Williams wrote:
>
>>As for an example of a poke of the form that you say makes no sense,
>
>I didn't say that it makes no sense.<--period!  I said that it didn't make
>sense in the context of the procedure description.  Let's break it down
>again: Poke let's you write one or more bytes into memory.  A byte can only
>be represented by an atom.  Poke let's you pass either an atom or a
>sequence.  Since a byte can only be represented by an atom, it follows that
>your sequence must a sequence of atoms.  Now that is how I think and that's
>why I said it doesn't make sense to pass a sequence of sequences.  It just
>doesn't fit into the definition of the procedure.

I think that I said that you might have been able to guess that. My point was
that you should not have to guess. Your suggested change to the
documentation was entirely adequate and wouldn't have cost much. Another
way to handle such things is to have an appendix with the formal
definitions in it. They are needed and could save much fiddling. In the
absence of your additional doc, one could think that sequences of
sequences of atoms might work when the string form might not....though
that runs against the definition that says those forms are equal. In any case,
one has to get an error message before one really knows.

>>what if I wanted to poke a series of lines from an editor contained as
>>subsequences within a sequence. List items are another possibility.
>>Since poke only takes one byte from each atom, it readily fits with the
>>model for expression of strings in memory. Seems logical to me. Maybe
>>you don't do things like that.
>
>Now that I've elaborated on the "it doesn't make sense" (that you ripped
>out of context), let's take a look at your case:  seems like it would be a
>neat feature (one that would surely be documented if it was something
>that 'poke' could do).  So why not write a function similar
>to 'allocate_string' (in machine.e) and modify it to suit your needs?  It's
>a rather trivial solution (just make sure to null-terminate your strings).
>I'll leave it as an exercise for the reader to do this one.
>
>So I guess another point is:  If it doesn't do what you want "out of the
>box" then take some initiative and make something that will do what you
>want.  This is how many great libraries get started and this is how the
>language grows.
>
Remember, this was Kat's request, not mine. I would only use peek and
poke if I had to do it in Euphoria and couldn't find any other way. The
method would be fairly trivial. Extract each second level sequence, poke it,
and add the length to the location in memory. Her second request was
a little more obscure, but I think I know the general heading. Writing bytes
to an IO location and toggling the IRQ would be an IO technique for
several types of IO. In some situations, no IRQ is necessary, polling is
used, so you just have to wait for the byte to change, indicating it has
been read. The IBM mainframes had a fantastic system level instruction
for this purpose called compare and swap.

Everett L.(Rett) Williams
rett at gvtc.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu