Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

+ALLOT

197 views
Skip to first unread message

dxf...@gmail.com

unread,
Sep 17, 2017, 7:08:23 AM9/17/17
to
Ever had to use HERE in conjunction with
ALLOT and found it becoming clumsy? If so
then try +ALLOT.

: +ALLOT ( +n -- adr ) HERE SWAP ALLOT ;

Several examples:

: C, 1 +allot c! ;

: S, ( adr len)
255 umin dup 1+ +allot place ;

\ old
( size) dup to gsize here to gbuf allot

\ new
( size) dup to gsize +allot to gbuf

I use a similar word for alloting space
in the HOLD buffer.

+HOLD ( +n -- adr )

: HOLD ( char ) 1 +hold c! ;
: SHOLD ( adr len ) dup +hold swap move ;
: NHOLD ( n char ) over +hold -rot fill ;

dxf...@gmail.com

unread,
Sep 19, 2017, 4:04:05 AM9/19/17
to
Looking back over old code I see that I've
previously named HERE SWAP ALLOT as RESERVE
- much nicer.

As I am defining it in the kernel, I found it
preferable to make RESERVE the primitive from
which one can define : ALLOT RESERVE DROP ;

Alex

unread,
Sep 19, 2017, 7:06:13 AM9/19/17
to
On 19-Sep-17 09:04, dxf...@gmail.com wrote:

>
> Looking back over old code I see that I've
> previously named HERE SWAP ALLOT as RESERVE
> - much nicer.
>
> As I am defining it in the kernel, I found it
> preferable to make RESERVE the primitive from
> which one can define : ALLOT RESERVE DROP ;
>

That's a useful factor, but you might want to be mindful that the word
RESERVE commonly has other meanings.

For instance some operating systems make a distinction between reserving
memory and allocating (or committing) memory. Windows:

MEM_RESERVE Reserves a range of the process's virtual address space
without allocating any actual physical storage in memory or in the
paging file on disk.

MEM_COMMIT Allocates memory charges (from the overall size of memory and
the paging files on disk) for the specified reserved memory pages.

There are also lock managers that use RESERVE to mean obtaining a lock
to serialize access to a resource.

How about ALLOT-HERE ?

--
Alex

dxf...@gmail.com

unread,
Sep 19, 2017, 10:16:46 PM9/19/17
to
On Tuesday, September 19, 2017 at 9:06:13 PM UTC+10, Alex wrote:
Name chosen will depend importance.
If defined as an application word then any
name would do. If it's a word from which
ALLOT is derived then something in keeping
with a language keyword.
0 new messages