Re: Pre-Scheme static allocation
Thomas Hintz <[email protected]> Thu, 29 Oct 2015 21:14:46 -0700
| Newsgroups | gmane.lisp.scheme.scheme48 |
|---|---|
| Message-ID | <1446178486.1246164.424283297.794686A3@webmail.messagingengine.com> |
On Thu, Oct 29, 2015, at 12:46 AM, Michael Sperber wrote: > > Thomas Hintz <[email protected]> writes: > > In this case I would like to keep a buffer of characters that are being > > displayed on the screen. So I need to be able to do operations like > > "string-ref" and "string-set!" on that buffer. But if I try to do this: > > > > (let ((buf "000000")) > > (string-set! buf 0 #\a) > > (string-ref buf 0)) > > Primarily because it's not valid Scheme: The literal is read-only. I > think what you should do is just a regular buffer, and, if you want to > transfer contents from a literal string, do so explicitly. Oh of course. Sorry. I should have gone to bed earlier... What do you mean by a 'regular buffer'? Do you mean like 'make-string'? If so, is there another way to do something like that besides using make-string, make-vector, or allocate-memory? Those appear to always use a form of 'alloc' which ideally I wouldn't have to rely on. Or am I missing something entirely? (I realize now my original confusion was with the type inference making me think I could do something that doesn't make sense Scheme wise, even though it could from C.) Thanks, Thomas Hintz