ForthHub / discussion

Discussion repository for Forth enthusiasts.
116 stars 4 forks source link

-ROT not in 2012 Standard #61

Closed Budsy closed 6 years ago

Budsy commented 6 years ago

I was puzzled to see that -ROT is not in the 2012 Forth core word list. Ok, I know that ROT ROT would be the equivalent, and 2 ROLL would do the same thing. But, gosh, I have been using -ROT from various Forths for a long time, and use it a lot. If it were part of a standard Forth, it could be optimized in ML, for example. So, arguments for not relying on the inline code:

: -ROT ( n1 n2 n3 -- n3 n2 n1 ) ROT ROT ; \ a pity to have to use this. slower : -ROT ( n1 n2 n3 -- n3 n2 n1) 2 ROLL ; \ sobbing now... have to push a value on stack, slower

Thoughts?

pebhidecs commented 6 years ago

On 10/03/2018 at 12:15 AM, "Budsy" notifications@github.com wrote:

I was puzzled to see that -ROT is not in the 2012 Forth core word list. Ok, I know that ROT ROT would be the equivalent, and 2 ROLL would do the same thing. But, gosh, I have been using -ROT from various Forths for a long time, and use it a lot. If it were part of a standard Forth, it could be optimized in ML, for example. So, arguments for not relying on the inline code:

: -ROT ( n1 n2 n3 -- n3 n2 n1 ) ROT ROT ; \ a pity to have to use this. slower : -ROT ( n1 n2 n3 -- n3 n2 n1) 2 ROLL ; \ sobbing now... have to push a value on stack, slower

Thoughts?

Just had a quick scan and it is not even in the 2012 standard. If you are creating a standard system, there is nothing to prevent you from making a more optimised -ROT available if you properly declare its existence and any dependences your programmes may have on it being there.

Regards

Paul E. Bennett IEng MIET Systems Engineer Lunar Mission One Ambassador --


Paul E. Bennett IEng MIET..... Forth based HIDECS Consultancy............. Mob: +44 (0)7811-639972 Tel: +44 (0)1392-426688 Going Forth Safely ..... EBA. www.electric-boat-association.org.uk..


AntonErtl commented 6 years ago

On Sat, Mar 10, 2018 at 12:15:10AM +0000, Budsy wrote:

I was puzzled to see that -ROT is not in the 2012 Forth core word list.

It's not in Forth 2012 at all. Nobody proposed it.

If you think it's worth the effort, propose it at forth-standard.org.

Arguments:

For: It is widely available.

Against: It adds a word. There are compilers that produce the same code for ROT ROT as for -ROT. It's not among the stack manipulation words that Chuck Moore brought down from the mountain.

Be prepared for a lot of nonsense from others when making a proposal.

forthy42 commented 6 years ago

[DEFINED] should be your friend. Only define -ROT if it is not already defined.

Am 10. März 2018 01:15:08 MEZ schrieb Budsy notifications@github.com:

I was puzzled to see that -ROT is not in the 2012 Forth core word list. Ok, I know that ROT ROT would be the equivalent, and 2 ROLL would do the same thing. But, gosh, I have been using -ROT from various Forths for a long time, and use it a lot. If it were part of a standard Forth, it could be optimized in ML, for example. So, arguments for not relying on the inline code:

: -ROT ( n1 n2 n3 -- n3 n2 n1 ) ROT ROT ; \ a pity to have to use this. slower : -ROT ( n1 n2 n3 -- n3 n2 n1) 2 ROLL ; \ sobbing now... have to push a value on stack, slower

Thoughts?

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/ForthHub/discussion/issues/61

-- Bernd Paysan "If you want it done right, you have to do it yourself" net2o ID: kQusJzA;7?t=uy@X}1GWr!+0qqp_Cn176t4(dQ http://bernd-paysan.de/

Budsy commented 6 years ago

Yes, I do that sort of thing in my code-- conditionally compiling -- but I might be having to do this all the time for what 'feels' like it should be a standard primitive. Acttually, -ROT is in my system (SwiftForth), so it's more of an academic argument for me at this point.