Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: minforth Newsgroups: comp.lang.forth Subject: Re: 0 vs. translate-none Date: Tue, 23 Sep 2025 22:38:07 +0200 Lines: 75 Message-ID: References: <2025Sep17.185305@mips.complang.tuwien.ac.at> <20250919193929.00000ec0@tin.it> <2025Sep20.092554@mips.complang.tuwien.ac.at> <20250920103435.00002fbe@tin.it> <2025Sep23.192305@mips.complang.tuwien.ac.at> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net LwPot5Yvm/+biDoA5HKivQc7RUcy0A2HVChrWRLPP/a6dw0Xyo Cancel-Lock: sha1:ERLqZWgpuE7whlUt8+7Ap56bKkw= sha256:gucXSMsZa54vUMKZkrjOAgY4rD7QRhdUQWQyH5qI60U= User-Agent: Mozilla Thunderbird In-Reply-To: <2025Sep23.192305@mips.complang.tuwien.ac.at> Xref: csiph.com comp.lang.forth:134196 Am 23.09.2025 um 19:23 schrieb Anton Ertl: > minforth writes: >> FWIW I also use suffixes for recognizers: >> let M be a matrix >> M´ auto-transposed >> M~ auto-inverted > > Can you give an example of a matrix with your matrix recognizer? > To be fair, here MinForth displays the matrix/vector stack in the QUIT prompt: MinForth 3.6 (64 bit) (fp matrix) # 0 0 matrix mat ok # m[ 1 2 3 ; 4 5 6 ] ok M: <1> [ 1 2 3 ; 4 5 6 ] # to mat ok # mat' ok M: <1> [ 1 4 ; 2 5 ; 3 6 ] # m[ 1 2 3 ; 4 5 6 ; 4 3 -2 ] := mat ok M: <1> [ 1 4 ; 2 5 ; 3 6 ] # mat~ ok M: <2> [ -2.333333 1.083333 -0.25 ; 2.666667 -1.166667 0.5 ; -0.6666667 0.4166667 -0.25 ] [ 1 4 ; 2 5 ; 3 6 ] # m. [ -2.33333 1.08333 -0.25 2.66667 -1.16667 0.5 -0.666667 0.416667 -0.25 ] ok M: <1> [ 1 4 ; 2 5 ; 3 6 ] # The implementation won't help you at all because I use my own recognisers. Tt's an eye sore ;-) \ ------ Matrix/Vector Indexing ------ \ Syntax: ( for positional indexing D: _[MVAL] i" mfmx=(mfMx*)mfpop(), mfmd=mfpop();" ; D: _MVAL [,] depth i" mfpush(mfmx);" [,] literal [,] _[mval] ; \ Syntax: ^ for heap addressing : _MVAL^ i" mfpush(mfmx->dat);" ; : _[MVAL^] _mval^ [,] literal ; \ Syntax: ' for implicit transposing : _MVAL' i" mfmup, mfm_set(mfmtos,mfmx), mfm_trans(mfmtos);" ; : _[MVAL'] _mval [,] _mval' ; \ Syntax: ~ for implicit inversion : _MVAL~ i" mfmup, mfm_set(mfmtos,mfmx), mfm_inv(mfmtos);" ; : _[MVAL`] _mval [,] _mval~ ; : __MXLITERAL? \ ( -- .. t | f ) recognize different matrix calls _parsed 2@ 1- _find-word IF dup cell+ @ _vmxmethods = IF C mfmx=(mfMx*)((mfpop())+2*MFSIZE), mfmd=mfsp-mfstk; _parsed 2@ 1- + c@ dup '(' = IF drop ['] noop ['] _mval true EXIT THEN dup '^' = IF drop ['] _mval^ ['] _[mval^] true EXIT THEN dup ''' = IF drop ['] _mval' ['] _[mval'] true EXIT THEN '~' = IF ['] _mval~ ['] _[mval~] true EXIT THEN ELSE drop THEN THEN deferred _literal? ; IS _LITERAL? \ ------ _LITERAL? is a deferrable element in the recognizer chain which is called in the INTERPRET loop (it is also used to recognize floats and complex numbers).