r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[rebcode] Rebcode discussion

BrianH
25-Oct-2005
[880x2]
Right now to-dec sets the destination word to none if the source 
word refers to a decimal already.
And to-int works the equivalent way.
Volker
25-Oct-2005
[882x2]
oops. misreaded just for only.
I agree then.
BrianH
25-Oct-2005
[884x6]
This is a place where I'd be willing to add a couple cycles just 
to prevent extremely obscure bugs.
By the way, I would prefer that randz and the trigonometric opcodes 
not be renamed unless you are planning to make versions of them for 
each type. They are already documented as being type-specific and 
there's only one of each, so it shouldn't be a problem.
Sorry, to-dec assigns 0.0 when the source is a decimal, not none. 
At least you can count on the dest being a decimal afterwards...
See what I mean by obscure bugs?
And to-int assigns 1 when the source is an integer. They're not even 
consistent with each other.
Submitted to RAMBO.
Benjamin
26-Oct-2005
[890]
hoo third option seems fineto me
BrianH
26-Oct-2005
[891]
Does anyone still need to vote?
Ladislav
26-Oct-2005
[892]
looking at the checklist I see, that there was somebody not adhering 
to the rules :-)
Henrik
26-Oct-2005
[893]
never send a checklist to do a voting applications' job :-)
BrianH
26-Oct-2005
[894x2]
Yeah, I noticed that the votes didn't add up to a multiple of three.
Whoops, I guess they do now.
Ladislav
26-Oct-2005
[896]
:-)
Alan
26-Oct-2005
[897]
1
DideC
26-Oct-2005
[898x2]
The survey helped (even with those who didn't play the game ;)
Thans to all
thanks
BrianH
26-Oct-2005
[900]
I've written a patch to the assembler that implements a working OFFSET 
directive and label value fixups. I will submit it to RAMBO as an 
enhancement request.
[unknown: 5]
26-Oct-2005
[901]
I don't know enough about rebcode to do any voting - there any docs 
yet?
BrianH
26-Oct-2005
[902x5]
; You use it like this
label x
;...
offset y 5
sub y x
braw y
Note that label, offset and the branches all calculate relative to 
the end of their statements.
Just after the end, rather.
If anyone wants to test the patch, here it is.
REBOL []


use [fixup-rule label-rule label-fixup-rule label-error-rule here] 
[
    ; Initialize the intermediate rules
    label-rule: make block! 0
    label-fixup-rule: make block! 0
    label-error-rule: make block! 0
    ; Build the fixup-rule based on the opcode-rule
    fixup-rule: copy/deep rebcode*/opcode-rule
    parse fixup-rule [
        some [
            here: 
            lit-word! block! '| (

                unless find ['bra 'brat 'braf] here/1 [insert here/2 [label-error-rule 
                |]]
            ) |
            lit-word! 'word! '| (

                unless 'label = here/1 [here/2: [label-error-rule | word!]]
            ) |
            lit-word! | '| | 'block! | 'series! |
            'word! (here/1: [label-error-rule | word!]) |
            'any-type! (here/1: [label-fixup-rule | any-type!]) |
            into ['integer! '| 'word! | 'word! '| 'integer!] (
                insert here/1 [label-fixup-rule |]
            ) |
            block! (insert here/1 [label-error-rule |])
        ]
    ]
    ; Replace the fix-bl function

    rebcode*/fix-bl: func [block /local labels here there label rule] 
    bind [
        labels: make block! 16
        block-action: :fix-bl
        if debug? [print "=== Fixing binding and labels... ==="]
        parse block [
            some [
                here:
                subblock-rule (here/1: bind here/1 words)
                |

                'label word! (here/1: bind here/1 words insert insert tail labels 
                here/2 index? here)
                |
                'offset word! integer! (
                    here/1: bind 'set words
                    here/3: 3 + here/3 + index? here

                    if (here/3 < 1) or (here/3 > 1 + length? block) [
                        error/with here "Offset out of bounds:"
                    ]
                )
                |
                opcode-rule (here/1: bind here/1 words)
                |
                skip (error here)
            ]
        ]
        either 0 < length? labels [
            label-rule: make block! length? labels

            foreach [key val] labels [insert insert tail label-rule to-lit-word 
            key '|]
            clear back tail label-rule

            label-fixup-rule: [there: label-rule (there/1: 2 + select labels 
            there/1)]

            label-error-rule: [label-rule (error/with here "Cannot use label 
            here:")]
            rule: fixup-rule
        ] [
            rule: opcode-rule
        ]
        parse block [
            some [
                here:
                ['bra word! | 'brat word! | 'braf word!] (

                    if not label: select labels here/2 [error/with here "Missing label:"]
                    here/2: label - index? here
                )
                |
                rule
                |
                skip (error here)
            ]
        ]
    ] rebcode*
]
Rebolek
27-Oct-2005
[907]
somebody must really like the add.i/add.d version. It's got priority 
20 now :)
Volker
27-Oct-2005
[908x2]
can i have preincrement/postdecrement then?
if we go 68k. ;)
Rebolek
27-Oct-2005
[910]
I don't like, it doesn't look like REBOL with the dot. Is it tuple 
or url? No, it isn't. So why the dot?
Volker
27-Oct-2005
[911x2]
because its assembler and 68k did it that way. dont like it too.
have you voted already? :)
Rebolek
27-Oct-2005
[913]
Yes, for the addi/addd version.
Pekr
27-Oct-2005
[914]
but it is not an assembly ;-) It is rebol dialect .... I agree with 
Kru ....
Volker
27-Oct-2005
[915]
Have you voted? shall we vote again? :)
Sunanda
27-Oct-2005
[916]
I agree with kru -- pity there is no option for making them look 
like refinements
  add/i
  add/d
  add   -- default is /i or /d or whatever is chosen
Volker
27-Oct-2005
[917]
suggested that to. Was told its technially no option, they must be 
words.
Rebolek
27-Oct-2005
[918]
or add-i/add-d. More REBOLish than dot.
Pekr
27-Oct-2005
[919x2]
exactly ....
I-am-already-used-to-rebolish-way :-)
BrianH
27-Oct-2005
[921x2]
The only advantages I can see to the dot (as opposed to the - ) is 
that it is less visually imposing and that it is easier for me to 
reach on my keyboard. These advantages are not insignificant, though.
Either dot or - would be OK to me.
Ladislav
28-Oct-2005
[923x4]
here is a poll
Carl said: What I am thinking of for BRAW is this:

   BRAB [lab1 lab2 lab3] n


If N is out of range, the BRAB does not happen. That allows DEFAULT 
case without needing to compute it before teh BRAB.
Should BRAB be zero-based or 1-based?
(see checklists for the poll)
BrianH
28-Oct-2005
[927x3]
Are the labels statically replaced with offsets like they are with 
bra, done with runtime lookups of the label declaration, done with 
label offsets assigned to the words, or done some way that hasn't 
occured to me? Can numeric offsets be used, and if so are they absolute 
(within the block) or relative?
As for 0-based versus 1-based, let's compare:
0-based

- would allow branching on the basis of a modulus calculation, or 
other calculations that can result in zero

- would be more useful for implementing Duff's Device style switch 
statements, which I have found useful so far
1-based

- is more REBOL-like (if such a thing can be said of a goto statement)

- effectively has a 0-based branch with the default of continuing 
on (not as useful for Duff's Device stuff, as the 0 branch is usually 
the last in the code)

- is in keeping with the rest of the 0-based opcodes having the letter 
z on the end, while BRAB doesn't
I vote for 0-based, or both (BRAB/BRABZ).