Utility Words

Oforth examples. Feel free to post your own code.

Utility Words

Postby Doug » 22 Oct 2018 14:18

Code: Select all
deleted
Last edited by Doug on 16 Nov 2018 22:10, edited 1 time in total.
Doug
 
Posts: 23
Joined: 20 Jul 2018 14:26

Re: Utility Words

Postby Franck » 23 Oct 2018 08:36

Hello Doug,

Currently, #at (and all other methods) checks for boundaries, but returns null if the index is out of bound.
Perhap's that throwing an exception is a better behavior ...

Whatever the behavior, this will have no impact on performances, so the choice is open.

Franck
Franck
 
Posts: 161
Joined: 29 Oct 2014 19:01

Re: Utility Words

Postby Doug » 23 Oct 2018 11:54

Hi Franck,

Here is the behavior that I wanted to avoid if I make a mistake with an index:

[1, 2, 3] >array tvar: a to a
10 88 a put a .s
[1] (Array) [1, 2, 3, null, null, null, null, null, null, 88]

The other issue, for me at least, is that something is returned after #put (null) only if the index is out of bounds. So I don't know when to check with #put.
Maybe I'm not thinking this through clearly.

Good to know speed is not impacted.

Regards,
-Doug
Doug
 
Posts: 23
Joined: 20 Jul 2018 14:26

Re: Utility Words

Postby Franck » 23 Oct 2018 20:41

Yes, I think it would be better to throw an exception when index is out of bounds.

I will change this for the next release.

Thanks,
Franck
Franck
 
Posts: 161
Joined: 29 Oct 2014 19:01

Re: Utility Words

Postby Doug » 16 Nov 2018 22:13

Franck,

I ran into problems with #PUT that I could not resolve. It was giving me false bounds errors, but not always. I couldn't resolve it yet so for now I have deleted the code.

-Doug
Doug
 
Posts: 23
Joined: 20 Jul 2018 14:26


Return to Oforth examples

Who is online

Users browsing this forum: No registered users and 1 guest

cron