Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 Get ready for new Atari users! ? http://rebolforum.com/index.cgi?f=printtopic&permalink=Kaj de Vos28-Oct-2021/13:19:39-7:00&archiveflag=new Quote Link to comment Share on other sites More sharing options...
ilmenit Posted November 19, 2021 Share Posted November 19, 2021 8 minutes ago, Kaj de Vos said: Ah, you can't iterate a constant. You first need to assign flags to a variable reference. how to do it? None of these do the job: flags-ptr: flags flags-ptr: block! flags flags-ptr: [flags] Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 The first should work. What is the error message? Quote Link to comment Share on other sites More sharing options...
ilmenit Posted November 19, 2021 Share Posted November 19, 2021 For the code flags= make static binary! sizepl flags-ptr: flags for-all flags-ptr [ ; change flags-ptr 1 ; "change" has no value poke flags-ptr 0 1 ] I receive ** Script error: "for-all" does not work on types combination: Parameter types: 1: static-binary! [flags-ptr [ ... 2: expressions list block! [ [ poke f... At: [ for-all flags-ptr [ poke flags-ptr 0 1 ... In: [ count: 0 i: 0 flags= make static binary! si... Near: [ while iter <= 10 [ count: 0 i: ... 1 Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 Thanks, made another fix. Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 9 minutes ago, ilmenit said: poke flags-ptr 0 1 Please don't call it a pointer. It's a high-level series. Your indexing is off by one. Indexing in REBOL and Meta is 1-based. In the future, this will produce a bounds error. Quote Link to comment Share on other sites More sharing options...
ilmenit Posted November 19, 2021 Share Posted November 19, 2021 4 minutes ago, Kaj de Vos said: Thanks, made another fix. now the compilations is getting error later on pick: ** Script error: cannot use pick on none! value ** Where: has-arguments any do if case either compile-expression foreach unless either compile-expression foreach unless either compile-expression foreach emit-C-program either do either either either -apply- ** Near: has-arguments third arguments-of code all [ constant: se... the code: natural! [count i] while iter <= 10 [ count: 0 i: 0 flags= make static binary! sizepl flags-ptr: flags for-all flags-ptr [ ; change flags-ptr 1 ; "change" has no value poke flags-ptr 0 1 ] i: 0 while i <= size [ p: pick flags i if p = 1 [ prime: ( i * 2 ) + 3 k: prime + i while k <= size [ poke flags k 0 k: k + prime ] count: count + 1 ] i: i + 1 ] iter: iter + 1 ] 1 Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 It's not on your pick, it's in REBOL code. Bug in the compiler. Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 Should be fixed now. Quote Link to comment Share on other sites More sharing options...
ilmenit Posted November 19, 2021 Share Posted November 19, 2021 24 minutes ago, Kaj de Vos said: Should be fixed now. Compiling file sieve.meta % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1248 100 344 100 904 246 647 0:00:01 0:00:01 --:--:-- 895 ** Script error: insert does not allow none! for its series argument ** Where: either do if case either compile-expression foreach unless either compile-expression foreach unless either compile-expression foreach emit-C-program either do either either either -apply- ** Near: either any [ not has-arguments second arguments-of code 1 Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 16 hours ago, ilmenit said: if you see there any places to improve the code, would be great to get your hints here. Here goes. 16 hours ago, ilmenit said: iter: 1 iter is inferred as integer!. You could optimise it like this: byte! iter It wouldn't matter much for speed here, but it would make the executable a bit smaller. But you don't need iter, because you can just do: repeat 10 [ 16 hours ago, ilmenit said: unsafe!!! constant reference volatile byte! [ ; OS RTCLOK2= ~13 RTCLOK3= ~14 ] Address assignments increment automatically, so you can write: unsafe!!! constant reference volatile byte! [ ; OS RTCLOK2= ~13 RTCLOK3 ] 16 hours ago, ilmenit said: RTCLOK2: 0 RTCLOK3: 0 RTCLOK3: RTCLOK2: 0 is shorter, in source and possibly also in binary code, depending on the back-end. The first 16 hours ago, ilmenit said: i: 0 is superfluous. You can fill the array with change/repeat flags 1 sizepl The second 16 hours ago, ilmenit said: i: 0 is off by one. 16 hours ago, ilmenit said: while i <= size for starts with one by default to match series indexes. Just do for i size [ 16 hours ago, ilmenit said: p: pick flags i if p = 1 p is inferred as integer!. This is inefficient. But you don't need p: if (pick flags i) = 1 Experienced REBOL programmers like to simplify this: if 1 = pick flags i [ Unlike REBOL, Meta supports the C style of treating 0 as an option value, so you can just do if pick flags i [ 16 hours ago, ilmenit said: ( i * 2 ) + 3 This can be optimised as i << 1 + 3 But watch out that you need to adjust for 1-indexing. Whether this produces better code depends on the back-end. 16 hours ago, ilmenit said: count: count + 1 The remaining increment can be optimised as increment count 1 Quote Link to comment Share on other sites More sharing options...
ilmenit Posted November 19, 2021 Share Posted November 19, 2021 17 minutes ago, Kaj de Vos said: You can fill the array with change/repeat flags 1 sizepl flags= make static binary! sizepl change/repeat flags 1 sizepl ** Script error: "change/repeat" does not work on types combination: Parameter types: 1: static-binary! [flags 1 sizepl fo... 2: byte! [1 sizepl for i si... 3: natural16! [sizepl for i size... At: [ change/repeat flags 1 sizepl for i size [ ... In: [ count: 0 flags= make static binary! sizepl ... Near: [ repeat 10 [ count: 0 flags= mak... Quote Your indexing is off by one. Indexing in REBOL and Meta is 1-based. In the future, this will produce a bounds error. It's a topic for a flame war, but are you sure it's good idea to follow 1-based indexing of Rebol? You are dropping compatbility with Rebol anyway. Many algorithms working on arrays (esp. of more than 1 dimension) are much simpler with 0-based indexing (and if you are targeting 8bit machines then you will work with them primarily). Modern languages that primarily 1-based have ability to set arbitrary indices (Julia, Pascal). Also nowadays "a must" are bindings to different libraries... and most of them are done in 0-based languages. Quote This can be optimised as i << 1 + 3 But watch out that you need to adjust for 1-indexing. This one of examples why 1-based indexing is not that great idea. Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 1 hour ago, ilmenit said: Compiling file sieve.meta % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1248 100 344 100 904 246 647 0:00:01 0:00:01 --:--:-- 895 ** Script error: insert does not allow none! for its series argument ** Where: either do if case either compile-expression foreach unless either compile-expression foreach unless either compile-expression foreach emit-C-program either do either either either -apply- ** Near: either any [ not has-arguments second arguments-of code Made a partial fix. Out of time for today. Quote Link to comment Share on other sites More sharing options...
zbyti Posted November 19, 2021 Share Posted November 19, 2021 (edited) Quote Address assignments increment automatically won't work for a last assignment in block: ** Script error: "=" does not work on types combination: Parameter types: 1: unset word! [VCOUNT] Edited November 19, 2021 by zbyti Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 8 minutes ago, ilmenit said: "change/repeat" does not work on types combination Made a fix. Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 9 minutes ago, zbyti said: won't work for a last assignment in block: ** Script error: "=" does not work on types combination: Parameter types: 1: unset word! [VCOUNT] That's a comparison, you should not have a " = " in there. Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 12 minutes ago, ilmenit said: It's a topic for a flame war, but are you sure it's good idea to follow 1-based indexing of Rebol? Yes, and yes, it's more human-friendly. We have plenty of unfriendly languages already. 13 minutes ago, ilmenit said: Also nowadays "a must" are bindings to different libraries... and most of them are done in 0-based languages. Doesn't matter, you just compensate. 14 minutes ago, ilmenit said: This one of examples why 1-based indexing is not that great idea. It's still math. Surely, a mathematically inclined person can easily adapt. Quote Link to comment Share on other sites More sharing options...
zbyti Posted November 19, 2021 Share Posted November 19, 2021 23 minutes ago, Kaj de Vos said: That's a comparison, you should not have a " = " in there. No. unsafe!!! constant reference volatile byte! [ RTCLOK= ~14 P0PF= ~2C0 HPOSM0= ~D004 GRAFM= ~D011 COLPM0 COLPM1 COLBK= ~D01A RANDOM= ~D20A WSYNC= ~D40A VCOUNT ] this don't work, last assignment must have explicit address. 1 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted November 19, 2021 Share Posted November 19, 2021 (edited) 46 minutes ago, Kaj de Vos said: 1 hour ago, ilmenit said: Also nowadays "a must" are bindings to different libraries... and most of them are done in 0-based languages. Doesn't matter, you just compensate. Why not give the programmer the option to set the base like some languages already do Best of both worlds Atari ST BASIC uses OPTION BASE which can be 0 or 1 Edited November 19, 2021 by TGB1718 Update Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 32 minutes ago, zbyti said: No. unsafe!!! constant reference volatile byte! [ RTCLOK= ~14 P0PF= ~2C0 HPOSM0= ~D004 GRAFM= ~D011 COLPM0 COLPM1 COLBK= ~D01A RANDOM= ~D20A WSYNC= ~D40A VCOUNT ] this don't work, last assignment must have explicit address. I see, that problem takes more work. Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 11 minutes ago, TGB1718 said: Why not give the programmer the option to set the base like some languages already do Best of both worlds Atari ST BASIC uses OPTION BASE which can be 0 or 1 Or worst of both worlds. It would take a lot of double implementations. Better standardise. Quote Link to comment Share on other sites More sharing options...
sanny Posted November 19, 2021 Share Posted November 19, 2021 5 minutes ago, Kaj de Vos said: Better standardise. But not to 1 IMHO. Feels unintuitive for normal programmers ? Just my 2 cents.... Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 https://language.metaproject.frl/#for Normal programmers are not the target audience. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted November 19, 2021 Share Posted November 19, 2021 10 minutes ago, sanny said: But not to 1 IMHO. Feels unintuitive for normal programmers ? I agree, 1 just seems wrong and causes it's own problems Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted November 19, 2021 Author Share Posted November 19, 2021 Agree to disagree then. Both have issues. Meta chooses for the human-friendly way. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.