~rabbits/uxn

6 3

UF Version 3 released

Details
Message ID
<16581499220.768748@mail.networkname.de>
DKIM signature
missing
Download raw message
Hello!

UF, version 3 is now available. There have been a few bugfixes
and quite a number of ergonomic improvements (block navigation,
multi-line snarf/yank). For details, see here:

    http://www.call-with-current-continuation.org/uf/uf.html


felix
Details
Message ID
<CAKis=aFv6VDY_-_-+A=0t6xVN0ba97Eg-x+CLmLdeJbB2vtDyQ@mail.gmail.com>
In-Reply-To
<16581499220.768748@mail.networkname.de> (view parent)
DKIM signature
pass
Download raw message
That's excellent news :) I've been teaching someone Forth via email
using UF-2 these past few days, and it has been such a pleasure to
use. Being able to paste large chunks of code with lines will make
things easier for me.

I hope you're not annoyed by my looking over your code yet(which is
very well written by the way) Here's a little tip that anyone can use:

whenever you write

- `DUP2 #0000 EQU2`, instead use `ORAk #00 EQU`, to save a byte.

Gonna take a deep dive into UF3 today!
Details
Message ID
<16581594850.948321@mail.networkname.de>
In-Reply-To
<CAKis=aFv6VDY_-_-+A=0t6xVN0ba97Eg-x+CLmLdeJbB2vtDyQ@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
> That's excellent news :) I've been teaching someone Forth via email
> using UF-2 these past few days, and it has been such a pleasure to
> use. Being able to paste large chunks of code with lines will make
> things easier for me.

My pleasure - make sure to report bugs or shortcomings!

> 
> I hope you're not annoyed by my looking over your code yet(which is
> very well written by the way) Here's a little tip that anyone can use:
> 
> whenever you write
> 
> - `DUP2 #0000 EQU2`, instead use `ORAk #00 EQU`, to save a byte.
> 

Ah, thanks. I don't mind at all, I'm always eager to find out about
useful Uxntal coding tricks.


felix
Details
Message ID
<YyegxJXfpNcNd/ME@localhost.lan>
In-Reply-To
<CAKis=aFv6VDY_-_-+A=0t6xVN0ba97Eg-x+CLmLdeJbB2vtDyQ@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
Hi Felix, I have a question if you don't mind (hope this is the best 
place for it?)

I'm looking to store a byte literal in a uf program, kind of like this 
example in uxntal:

https://git.sr.ht/~rabbits/uxn/tree/main/item/projects/examples/demos/dvd.tal#L61

I notice that most of the examples in your uf code write each byte with 
c, -- eg 00 c, 1f c,

I was wondering if there was some simpler way to use metaprogramming of 
some sort in order to write bytes directly to a word definition. 
something like:

create foo b# 001f 3f38 #

(or whatever the word definition would look like in idiomatic forth)

but I'm still very new to forth, so I'm not sure how you'd do this (or 
if it's a good idea)

best,

Alex
Details
Message ID
<16635760080.430663@mail.networkname.de>
In-Reply-To
<YyegxJXfpNcNd/ME@localhost.lan> (view parent)
DKIM signature
missing
Download raw message
> Hi Felix, I have a question if you don't mind (hope this is the best 
> place for it?)
> 
> I'm looking to store a byte literal in a uf program, kind of like this 
> example in uxntal:
> 
> https://git.sr.ht/~rabbits/uxn/tree/main/item/projects/examples/demos/dvd.tal#L61
> 
> I notice that most of the examples in your uf code write each byte with 
> c, -- eg 00 c, 1f c,
> 
> I was wondering if there was some simpler way to use metaprogramming of 
> some sort in order to write bytes directly to a word definition. 
> something like:
> 
> create foo b# 001f 3f38 #
> 
> (or whatever the word definition would look like in idiomatic forth)
> 

`c,` and `,` are the most straightforward words to include literal
data in a piece of code, but may indeed look a bit inconvenient.

Here is an implementation for the notation you suggest:

    \ scan words until the word "#" is found:
    : b#  ( | n ... # -- )
      begin  bl word dup c@ 0=  if  drop  query  \ read new line 
        else  dup count s" #" compare 0=  if  drop  exit
          else  number 0= abort" not a number"
            ,  then  then   \ store in memory
      again ;

To have it also available inside colon definitions (not sure if
this is useful, but I add it here for completeness), we must
add it to the "compiler" vocabulary:

    also compiler definitions
    : b#  b# ; immediate  \ just reuse existing def, but make it immediate
    \ switch back to default vocabulary
    only forth definitions

You use it like this:

    create cross hex b# 0ff0 ffff ffff 0ff0 # decimal

I hope this helps.


felix
Details
Message ID
<YzJjVJTbzLjqXdGc@localhost.lan>
In-Reply-To
<16635760080.430663@mail.networkname.de> (view parent)
DKIM signature
pass
Download raw message
Hi Felix --

I had a question about how stdin works in uf. If I have a file like foo.f with the content:

2 2 +

and I redirect it to ufx.rom, e.g.

uxncli ufx.rom < foo.f

I no longer see the prompt afterwards. How can I still see the prompt 
after reading input from the command line?

BTW -- is there a better place than this thread I can ask q's like this?

Alex
Details
Message ID
<16642686450.165329@mail.networkname.de>
In-Reply-To
<YzJjVJTbzLjqXdGc@localhost.lan> (view parent)
DKIM signature
missing
Download raw message
> Hi Felix --
> 
> I had a question about how stdin works in uf. If I have a file like foo.f with the content:
> 
> 2 2 +
> 
> and I redirect it to ufx.rom, e.g.
> 
> uxncli ufx.rom < foo.f
> 
> I no longer see the prompt afterwards. How can I still see the prompt 
> after reading input from the command line?

The Forth prompt will read only from foo.f in this case, it does not
automatically switch back to the console when foo.f has been completely
consumed, that is simply how I/O redirection works. The graphical UF
on the other hand reads both from stdin and the SDL event loop, so
there you still have a working prompt, even if stdin is at EOF.

> 
> BTW -- is there a better place than this thread I can ask q's like this?

Sorry, currently there is no public forum or channel for UF, but you can 
of course always mail me directly, if you have questions.


felix
Reply to thread Export thread (mbox)