00:33:05
##forth
<cleobuline>
forth: : TEST DUP 0 = IF DROP 6 ELSE 1 - THEN DUP . ;
00:33:08
##forth
<cleobuline>
forth: SEE TEST
00:33:18
##forth
<cleobuline>
mforth: : TEST DUP 0 = IF DROP 6 ELSE 1 - THEN DUP . ;
00:33:28
##forth
<cleobuline>
mforth: SEE TEST
00:33:28
##forth
<mforth>
: TEST DUP 0 = IF DROP 6 BRANCH(9) 1 - DUP . ;
00:33:33
##forth
<cleobuline>
bug ...
01:02:44
##forth
<anthk_>
mforth: see see
01:02:44
##forth
<mforth>
Unknown word: see
01:02:48
##forth
<anthk_>
mforth: SEE SEE
01:02:49
##forth
<mforth>
SEE: Unknown word: SEE
12:01:37
##forth
<guanche>
Hi!
12:03:57
##forth
<guanche>
I'm new to forth, and would like somebody to tell me how do I create "objects"? For example, say I want to have a box with different compartment. I'd like to name these like COMPARTMENT-A, COMPARTMENT-B, etc., so that I can set and retriever their values, while being able to allocate as many boxes as neded? wha't the forth way of doing that?
12:06:51
##forth
<guanche>
I'm comming from C, so I'm referinf to the native way of doing data-structures in forth, because defining variables as offsets into a given array works for any array I'd like to use these, but I don't think that how it should be done
12:13:14
##forth
<KipIngram>
Forth is very basic and "baremetal." Any of the things you just mentioned can be done, but you have to construct it, pretty much from scratch. Some Forths have more features than others, but in some cases you'll have to implement the memory management primitives, etc. But Forth does let you create "data storage structures" that have programmable actions associated with them. So it's definitely
12:13:17
##forth
<KipIngram>
possible to set things up so that you can put a "message" on the stack, and then execute the data storage word, and the code associated with it will use that stack value to decide what to do.
12:13:50
##forth
<KipIngram>
The mechanism for making that kind of word is called CREATE / DOES>; generally you write a word for creating your objects along these lines:
12:14:23
##forth
<KipIngram>
: maker <data allocation details> DOES> <actions to run on execution> ;
12:15:11
##forth
<KipIngram>
There are some efforts out there toward "object oriented Forths" you could either use or read to get ideas.
12:15:33
##forth
<_guanche>
thanks, but is this a common paradigm when writing forth or maybe I'm getting it all wrong?
12:16:21
##forth
<KipIngram>
Well, some people definitely are interested in such things. But no, I wouldn't say it's the "most common" way of using Forth. Forth pre-dates object oriented ideas by quite a long time.
12:16:36
##forth
<_guanche>
by the way, I'm using SmithForth, so the low level thing is not a problem for me
12:16:40
##forth
<KipIngram>
It's a very "procedural" language.
12:17:33
##forth
<KipIngram>
Ok. Some folks are just "put off" by having so many things they're accustomed to having be built in not be.
12:17:53
##forth
<_guanche>
so, if you were to write, say a ternary tree, how would you go about it? (you'd need to allocate as many nodes as characters any stirng interned would have, and you might need to access each of these node's internal offsets
12:18:02
##forth
<KipIngram>
A notable one is that often Forth doesn't even have much in the way of string support. You get to build that yourself too.
12:19:40
##forth
<KipIngram>
Well, I'm not sure I fully see what that would require, but if you need a word for every character in a string, somewhere you'd have to write code to scan that string, iterate through it's characters, use your memory allocator to make a node for each one, link them together, etc. It would have to be built all the way up from the very bottom.
12:20:26
##forth
<KipIngram>
Some Forths let you at least express a string as s" <my string>". That leaves an address where the string is on the stack.
12:20:55
##forth
<KipIngram>
Do note the space between s" and the string, so that it's a space delimited word.
12:21:09
##forth
<_guanche>
yes, I understand that, but what I mean is, in this case, a "Node" would need to keep the character it refers to, a two other pointers (because it's a ternary tree, so you need left and right pointers). I would need to access all these, for every node I'd need to allocate
12:21:55
##forth
<KipIngram>
Yes. The usual way of doing that is that once you get the address of the node you then get to the fields yourself by adding the right offset.
12:22:18
##forth
<KipIngram>
But everything in there you access using c@ or @ etc. and treating as a character or an integer etc.
12:22:31
##forth
<KipIngram>
There aren't any built ins for "fields," or "types."
12:23:03
##forth
<KipIngram>
Well, I say that, but that's another thing some people have tried to extend. It's just not standard.
12:23:12
##forth
<_guanche>
do you happen to know of an example of something like this I could look at, a binary tree or something close?
12:23:35
##forth
<_guanche>
I'm not actually willing to extend, but rather to use with what I have
12:24:10
##forth
<_guanche>
or said otherwise, to learn forth as it is, I'll worring about extendin it later
12:24:21
##forth
<KipIngram>
No, I'm sorry - I'm not terribly familiar with the landscape out there. I tend to write my own Forths. I've done some singly and doubly linked lists, but I haven't done much with trees. I've thought about using b* trees to do a file system, but I've not actually done it.
12:24:46
##forth
<KipIngram>
But it feels like something someone else here likely has seen somewhere.
12:24:55
##forth
<_guanche>
linked lists could keep me going, do you happen to have publicly available code?
12:25:56
##forth
<KipIngram>
Nn, not personally; I'm sorry. Most of the US guys here are probably still sleeping, but there are some folks across the pond that hang out here too - hopefully someone else will be able to help you.
12:26:00
##forth
<_guanche>
tree are just "linked lists" with an extra field for data
12:26:05
##forth
<KipIngram>
Yes.
12:26:29
##forth
<_guanche>
no problem, thanks so much. I'll look for linked lists out there to see what I can find
12:26:50
##forth
<KipIngram>
Hey, good luck. Sounds like a fun application.
12:27:12
##forth
<_guanche>
thanks :D
12:28:03
##forth
<_guanche>
I always use ternary trees for language tokens and such, are quite efficient, so it's the first thing I'd like to modify in SmithForth
15:58:19
##forth
<KipIngram>
It's the sort of thing I'd just think about for a while, to decide exactly how I wanted my tree nodes laid out in memory, and then just build up from the bottom, bit by bit. Some kind of a heap to let me allocate and free the nodes, then the usual things, add a node, delete a node, etc. Clearly you've got a good picture of what you want to do, so my bet is you won't have a whole lot of trouble
15:58:22
##forth
<KipIngram>
putting it together.
15:58:30
##forth
<KipIngram>
Just a bunch of tedious bits to tend to.
15:59:32
##forth
<KipIngram>
Since your nodes will all be the same size (I think), the memory allocator will be pretty easy - I've done simple fixed size allocators several times - usually I just have a "frontier" variable I can push up as I need new space and a free list pointer.
16:00:05
##forth
<KipIngram>
Then it's just a matter of how fancy I want to try to get, like do I also pull the frontier BACK when it's possible to do so, etc.
17:15:21
##forth
<cleobuline>
mforth: LOAD "test.fth"
17:15:27
##forth
<cleobuline>
mforth: LOAD "test2.fth"
17:15:39
##forth
<cleobuline>
mforth: SEE CAL
17:15:40
##forth
<mforth>
: CAL 2DUP SWAP MONTH-NAME DROP 32 EMIT NUM-TO-STR CR ." Mo Tu We Th Fr Sa Su " CR 2DUP ZELLER DUP 0 = IF DROP 6 ELSE 1 - THEN DUP OFF ! OFF @ 0 > IF OFF @ 0 DO 32 EMIT 32 EMIT 32 EMIT LOOP THEN DROP 2DUP 2DUP DAYS-IN-MONTH 1 + 1 DO I 10 < IF 32 EMIT 32 EMIT ELSE 32 EMIT THEN I NUM-TO-STR OFF @ I + 7 MOD 0 = IF CR THEN LOOP 2DROP CR ;
17:15:49
##forth
<cleobuline>
fix issue with SEE
17:17:08
##forth
<cleobuline>
should recompile words of SEE with no errors
17:17:22
##forth
<cleobuline>
mforth: : CAL 2DUP SWAP MONTH-NAME DROP 32 EMIT NUM-TO-STR CR ." Mo Tu We Th Fr Sa Su " CR 2DUP ZELLER DUP 0 = IF DROP 6 ELSE 1 - THEN DUP OFF ! OFF @ 0 > IF OFF @ 0 DO 32 EMIT 32 EMIT 32 EMIT LOOP THEN DROP 2DUP 2DUP DAYS-IN-MONTH 1 + 1 DO I 10 < IF 32 EMIT 32 EMIT ELSE 32 EMIT THEN I NUM-TO-STR OFF @ I + 7 MOD 0 = IF CR THEN LOOP 2DROP CR ;
17:17:35
##forth
<cleobuline>
mforth: 4 2025 CAL
17:17:35
##forth
<mforth>
April 2025
17:17:36
##forth
<mforth>
21 22 23 24 25 26 27
17:17:36
##forth
<mforth>
28 29 30
17:36:40
##forth
<cleobuline>
mforth: 88 40 MULTI-CHAR
17:36:40
##forth
<mforth>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
17:37:08
##forth
<cleobuline>
fine to edit your stats
17:43:44
##forth
<anthk_>
cleobuline: no today word?
17:45:03
##forth
<cleobuline>
i do not hilith the current day sorry
17:45:40
##forth
<cleobuline>
you whant today word ?
17:46:11
##forth
<anthk_>
no, I was curious
17:46:21
##forth
<cleobuline>
you have the tools
17:46:27
##forth
<cleobuline>
mforth: MILLI
17:46:34
##forth
<cleobuline>
mforth: .S
17:46:35
##forth
<mforth>
<4> 4 2025 4 1744818387862
17:46:54
##forth
<cleobuline>
so you can convert in todat date
17:47:11
##forth
<anthk_>
unix epoch?
17:47:14
##forth
<cleobuline>
yes
19:48:36
##forth
<cleobuline>
mforth: LOAD "test2.fth"
19:49:06
##forth
<cleobuline>
mforth: TODAY .S
19:49:06
##forth
<mforth>
<7> 4 2025 4 1744818387862 16 4 2025
19:49:22
##forth
<cleobuline>
mforth: CLEAR-STACK
19:49:25
##forth
<cleobuline>
mforth: TODAY .S
19:49:25
##forth
<mforth>
<3> 16 4 2025
19:49:33
##forth
<cleobuline>
happy anthk_ ?
19:50:01
##forth
<cleobuline>
a piece of shit to calculate
19:50:53
##forth
<xentrac>
ew
20:00:35
##forth
<identity>
one time i needed the current date and only had seconds since UNIX epoch, looked up a way to calculate the date, after about an hour of trying to understand the solution i threw my code away and just used a library...
20:00:55
##forth
<identity>
mforth: LOAD "test2.fth"
20:00:55
##forth
<mforth>
Unknown word in definition: NUM-TO-STR
20:00:56
##forth
<mforth>
Error: Definition discarded due to error
20:00:56
##forth
<mforth>
Unknown word in definition: NUM-TO-STR
20:00:57
##forth
<mforth>
Error: Definition discarded due to error
20:00:57
##forth
<mforth>
Unknown word in definition: NUM-TO-STR
20:00:58
##forth
<mforth>
Error: Definition discarded due to error
20:00:58
##forth
<mforth>
Unknown word in definition: NUM-TO-STR
20:00:59
##forth
<mforth>
Error: Definition discarded due to error
20:01:04
##forth
<identity>
right
20:01:07
##forth
<identity>
mforth: LOAD "test.fth"
20:01:12
##forth
<identity>
mforth: LOAD "test2.fth"
20:01:25
##forth
<identity>
mforth: SEE TODAY
20:01:25
##forth
<mforth>
: TODAY MILLI 1000 / 86400 / DAYS ! CALC-YEARS CALC-MONTHS CALC-DAY DAY @ MONTH @ YEAR @ ;
20:01:51
##forth
<identity>
mforth: SEE CALC-MONTHS
20:01:51
##forth
<mforth>
: CALC-MONTHS 1 MONTH ! BEGIN DAYS @ 0> WHILE MONTH @ 2 = IF 28 ELSE MONTH @ 4 = IF 30 ELSE MONTH @ 6 = IF 30 ELSE MONTH @ 9 = IF 30 ELSE MONTH @ 11 = IF 30 ELSE 31 THEN DUP DAYS @ >= NOT IF DAYS @ SWAP - DAYS ! MONTH @ 1 + MONTH ! ELSE DROP EXIT THEN REPEAT DROP ;
20:01:56
##forth
<cleobuline>
lol
20:02:29
##forth
<cleobuline>
identity: you are curious :)
20:03:07
##forth
<cleobuline>
yes i do it in 2 hours :)
20:04:42
##forth
<cleobuline>
mforth: TODAY CAL
20:04:42
##forth
<mforth>
April 2025
20:05:04
##forth
<cleobuline>
mforth: LOAD "test2.fth"
20:05:07
##forth
<cleobuline>
mforth: TODAY CAL
20:05:08
##forth
<mforth>
April 2025
20:05:08
##forth
<mforth>
21 22 23 24 25 26 27
20:05:28
##forth
<cleobuline>
next i have to hilight today :)
20:07:20
##forth
<xentrac>
yay!
20:08:02
##forth
<xentrac>
identity: oh, you don't understand Zeller's congruence either? I'm not sure even Zeller did
20:08:22
##forth
<cleobuline>
mforth: SEE ZELLER
20:08:22
##forth
<mforth>
: ZELLER >R DUP 3 < IF 12 + R> 1 - >R THEN R@ 100 MOD R@ 100 / SWAP DUP 4 / + SWAP 2 * 0 SWAP - + SWAP 1 + 13 * 5 / 1 + + R> 100 / 4 / + 6 + 7 MOD ;
20:10:53
##forth
<cleobuline>
mforth: 4 2
20:10:53
##forth
<cleobuline>
mforth: 4 2025 ZELLER .
22:56:04
##forth
<cleobuline>
mforth: LOAD "tes2.fth"
22:56:04
##forth
<mforth>
Error: Error: LOAD: Cannot open file 'tes2.fth'
22:56:09
##forth
<cleobuline>
mforth: LOAD "test2.fth"
22:56:37
##forth
<cleobuline>
mforth: TODAY CAL-IRC-HIGHLIGHT
22:56:37
##forth
<mforth>
April 2025
22:56:38
##forth
<mforth>
21 22 23 24 25 26 27
22:56:38
##forth
<mforth>
28 29 30
22:56:51
##forth
<cleobuline>
it works only with irssi
22:57:11
##forth
<cleobuline>
on my macos client it look italic
23:00:07
##forth
<cleobuline>
does someone look different ?
23:01:39
##forth
<xentrac>
I see 16 in reverse video: 16 which is to say that instead of being orange on black it's black on a little orange square
23:01:51
##forth
<cleobuline>
ok
23:02:32
##forth
<cleobuline>
so it works :)
23:04:51
##forth
<cleobuline>
on my macos client i see 16 in italics
23:05:39
##forth
<xentrac>
so yo usaid
23:05:55
##forth
<cleobuline>
je radote ...