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

World: r3wp

[rebcode] Rebcode discussion

BrianH
12-Oct-2005
[146]
BUG (possibly): The SETI and SETD opcodes don't work unless the variable 
has already been set to a value of the appropriate data type.
Volker
12-Oct-2005
[147]
Maybe optimisation?
BrianH
12-Oct-2005
[148x3]
BUG: The decimal math opcodes can take an integer value in the second 
argument, but if that value is specified literally the syntax checker 
rejects it. The integer! datatype needs to be added as an alternate 
to the second argument.
Volker, that's why I said possibly. If so it should be documented.
REQUEST: I would like the LOG-2 opcode to be added to the existing 
LOG-10 and LOG-E. Log-2 is the only one of those I actually use regularly 
:)
Gabriele
12-Oct-2005
[151]
APPLY is just what is in the works :) and... some kind of GET and 
SET for indirection is being discussed too.
BrianH
12-Oct-2005
[152]
How about LOG-2 :)
Gabriele
12-Oct-2005
[153x3]
about the compose/deep, i think that's what most people will want. 
note that my either paren? has nothing to do with it (it is to handle 
parens in the expressions, not to workaround compose/deep)
SETI and SETD: that's intended. they only work on initialized variables... 
but they are faster than normal SET (SET has to copy 16 bytes, SETI 
only 32 bits for example)
log-2: going to ask Carl.
BrianH
12-Oct-2005
[156x2]
I meant the other, literal paren in your code that you clearly needed 
to be composed at rewrite time rather than at rule adding time like 
it is now.
(either paren? val [compose [rv: (to block! val)]] [ ])
Gabriele
12-Oct-2005
[158]
how would compose without /deep help there?
BrianH
12-Oct-2005
[159]
Compose would just compose the parens directly in the production; 
compose/deep composes all of the inner parens inside the code as 
well.
Gabriele
12-Oct-2005
[160x5]
it does not compose parens inside parens
it only composes parens inside blocks.
>> compose/deep [([something (something)])]
== [something (something)]
that's why i need an extra compose there.
if you have either or if or while or something like that in your 
production, you'll need /deep, and you'll be screaming if you don't 
have it ;)
BrianH
12-Oct-2005
[165x2]
OK then, I thought /deep meant /deep, my mistake :)

I thought you needed the extra compose since it was to be applied 
later, at rewrite time.
That makes compose/deep more useful than I thought.
Gabriele
12-Oct-2005
[167]
:-)
BrianH
12-Oct-2005
[168]
I've been thinking about temporary variables generated by rewrite 
rules. I have a way to generate extremely unlikely variable names, 
but no way to bind them in the rebcode function after they've been 
added. Any ideas?
Gabriele
12-Oct-2005
[169x2]
the rewriting process preserves binding.
so, you can also use extremely likely names, but just have them bound 
to your own context.
BrianH
12-Oct-2005
[171]
I mean adding new bindings, say for intermediate values of complex 
expressions that need to be changed to sequences of simple expressions 
using temporary variables that don't exist in the original code.
Gabriele
12-Oct-2005
[172x2]
use [x val] [rebcode-define ['my-op set val integer! #==> set x (val) 
?? x .]]
you can consider X a temporary variable here.
BrianH
12-Oct-2005
[174x2]
Expressions like (x * (y + z)) + (w * y)
To use only one temporary variable may require a topological sort 
of the expression, if it is at all possible. I want to be able to 
generate anonymous temporaries if necessary.
Gabriele
12-Oct-2005
[176x5]
(there's an infinite loop in my compiler using your example, i'll 
need to debug it later - too sleepy now ;)
but, it works removing one paren.
>> f: rebcode [] [res: x * (y + z) + (w * y)]
>> print mold second :f

[set res x set rv y addd rv z muld res rv set rv w muld rv y addd 
res rv]
only RV is used as a temp var... and it's always the same rv.
if you can find an example where this would not work... please let 
me know; i guess you will, since this compiler is just a quick test, 
and i didn't expect it to work this well ;)
BrianH
12-Oct-2005
[181]
Well finding an example is simple: Just convert to stack code and 
figure out when the stack would be used more than one deep between 
ops. That means more than one temp var. What we get for going to 
a register machine in a stack language :)


This would all be solved by a built-in USE directive with literal 
blocks that acts like USE in REBOL except only binding at rebcode 
creation time. It could be implemented as a built-in rewrite rule, 
changing the temporary variables to local variables, renaming if 
necessary. This rewrite would be done after the user-defined rewrites 
were done, but before the binding to the opcodes.


Let me think about how this could be implemented - I am late for 
a class.
Pekr
13-Oct-2005
[182]
rebcode 10 was released .....
Gregg
13-Oct-2005
[183]
Pekr, yes, rebcode docs will be forthcoming.
Pekr
13-Oct-2005
[184]
thanks ... the docs will be pretty comples - soooo many opcodes in-there 
:-) I just wonder, if Gabriele does only some wrappers or even C 
internal coding? :-) And if he is so good at it and RT is working 
on a low-level stuff for a while - there were few wishes to improve 
library interface and callback support. Imo it is still in versio 
like Jeff did it initially and some update which would make wrapping 
easier would be handy :-)
Gregg
13-Oct-2005
[185]
I have a dialect to simplify routine! writing, but I don't know if 
there is anything else planned for the library interfaces right now.
Pekr
13-Oct-2005
[186x2]
imo callback  support is weak, dunno if other languages have such 
a limit as 16 possible callbacks ... well, there is many indications 
in dll.so group. It surely will not be a priority for RT right now, 
as it simply works as a solution, but I just thought that those two 
things (dll C interface and VM assembler) could be related somehow 
...
besides that, yesterday I played part of Carl's speech, and in QA 
part I noticed something like a mention of interfacing via plug-ins, 
but I could easily misunderstood because of my "ability" to distinguish 
natively spoken English :-))
Gabriele
13-Oct-2005
[188x2]
from Carl:

log2:
   log n
   div n 0.6931471805599453

Do you still want it as an opcode?
note, that rebcode10.zip has APPLY. see notes.txt.
Pekr
13-Oct-2005
[190]
Gabriele - who does low-level coding - you or Carl? :-) It already 
seems to me, that rebcode is more powerfull than initially planned, 
that is really nice :-)
Gabriele
13-Oct-2005
[191x4]
Carl.
i only wrote the new assembler (print mold rebcode*)
btw, about log2, you could write:
use [w] [
	rebcode-define [
		'log2 set w word! #==>
			log (w)
			div (w) 0.6931471805599453
			.
	]
]
Pekr
13-Oct-2005
[195]
Gabriele - some time ago you also did interesting script - parse-rules 
or anything like that? Or was it script to make own datatypes? You 
now seem to be an expert in that regard, providing us the assembler 
part. Maybe stuff I mentioned could be added to rebol in some extent? 
Would it be worth it? :-)