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

World: r3wp

[!REBOL3]

BrianH
12-Oct-2010
[5222]
Maxim, to answer your questions about cause-error: Three arguments, 
the first two being words from system/catalog/errors, the last one 
eiither being a single value of any type or a block of up to three 
values, depending on which error you are generating. All the info 
you need about a particular error is in system/catalog/errors. The 
number of arguments in the argument block is fixed, per error. The 
usage is in the phrasing of the error message. Pick arguments that 
when molded and put in that position in the error message would make 
the error message make sense.
Maxim
12-Oct-2010
[5223]
thx  :-)
BrianH
12-Oct-2010
[5224x3]
For instance, when I needed to come up with the right error to trigger 
when a function refinement was incompatible with the datatype of 
another argument, there wasn't an explicit error for that. But after 
looking through the catalog, I came up with this:
>> cause-error 'script 'cannot-use [load-module/as block!]
** script error: cannot use load-module/as on block! value
It will do until there is a better error for that situation.
CAUSE-ERROR is mezzanine in R3 and 2.7.7, so just source it :)
Gregg
12-Oct-2010
[5227]
Could the above notes be added to cause-error docs?
BrianH
12-Oct-2010
[5228]
Sounds like a good idea.
Maxim
12-Oct-2010
[5229]
yes, that would be a good first clue, since the current docs give 
no indication on how to proceed right now... 


I should have sourced cause-error, and I usually do... but this time 
well... I guess I assumed it was a native  :-)
BrianH
12-Oct-2010
[5230]
First thing I do when wondering about a function is HELP it. That 
tells me the basics, and also mentions its datatype.
Maxim
12-Oct-2010
[5231x2]
yep.
step 2 is source it  ;-)
BrianH
12-Oct-2010
[5233x2]
Yup :)
Step three is experiments at the console, calling it with test data.
Maxim
12-Oct-2010
[5235]
Q:  does reflect unbind the blocks it returns?
BrianH
12-Oct-2010
[5236]
It unbinds function code blocks, but intentionally binds object word 
blocks.
Maxim
12-Oct-2010
[5237x3]
is there a way to get a bound copy of a function's body?  sometimes, 
its nice to be able to figure out why a sub-function isn't doing 
what its supposed to...


this could be subject to protection schemes... so that a protected 
member cannot be shown via its function body.
this is also true of the stack function... it should not cross any 
protection... since doing so reveals what *it* calls...
(though I'm not saying it currently does just raising up the issue 
if it wasn't planned already)
Andreas
12-Oct-2010
[5240x2]
http://www.rebol.com/r3/docs/functions/cause-error.html
I took Brian's notes from above and edited some basic CAUSE-ERROR 
docs around them.
BrianH
12-Oct-2010
[5242x2]
No bound copy of a function body, for security reasons. The kind 
of hot-patching that was possible in R2 was always a security hole. 
Plus, it's not task-safe. For that matter, BODY-OF always returns 
a copy or constructed value, never the original, and code that currently 
uses it relies on this.
BODY-OF doesn't return the original for objects or modules either.
Maxim
12-Oct-2010
[5244x2]
the copy I don't mind... that's cool, its the fact that it always 
unbinds (which is what you seem to say).  its not a security hole 
if the functions aren't hidden or protected in some way.


I just want to know what a function within a function actually is 
calling... if its unbound... well I can't make any real inspection 
tool or debugger... right now I can go a lot further than R2, except 
this ... unless I didn't properly understand you.
its a bit like a dll, you only have access to the dll within a debugger 
if it was compiled with debugging... I'd like that to still be the 
case within rebol.
BrianH
12-Oct-2010
[5246]
There are two ways of hiding values. The tricky way is to use PROTECT/hide 
on a publically visible context. The more common, easier way is to 
use contexts that aren't publically accesible. There is no way that 
a reflector can tell if a bound context is not accessible, but the 
unbind trick prevents that kind of hack. And since inaccesible contexts 
might contain private information like encryption keys that might 
not belong to the person running the R3 process, there is no security 
setting that can make this safe to not do.
Maxim
12-Oct-2010
[5247]
I just finished a very powerfull new version of the search tool... 
it now even allows you to search for any value, even unset!. ( I 
just did a search to find all unset words in the whole system and 
it works without a hitch... )


also, if some data in the system is a string, it tries to find a 
formed value of your search value inside of it:-)
Steeve
12-Oct-2010
[5248]
Maxim, I felt the same back In time. A tool like anamonitor is not 
anymore possible. (cry on my face)
BrianH
12-Oct-2010
[5249]
But DRM is. Whether you consider that an advantage or not though...
Maxim
12-Oct-2010
[5250]
well, we can, but its severely limits debugging and frankly there 
is a way to do .   any context should have the possibility of having 
a private/public flag on it... its that simple. whenever you try 
to reflect a private context, it returns unset! (unbound) values.
BrianH
12-Oct-2010
[5251]
It is assumed that people doing debugging have access to the source. 
And in the case of source written in REBOL, that is likely the case 
now.
Steeve
12-Oct-2010
[5252]
Though debuging the source and a runtime session, is not the same 
thing.
Maxim
12-Oct-2010
[5253x2]
but you cannot resolve the run-time in data. since things are bound 
dynamically.  the name of a func is useless... we need to be able 
to trace it back to its context by getting its value.


this doesn't give us the context, but at least we can see what the 
function really is.
if things really need to be private, then anything which comes from 
a private context could just be flagged as such and inspection routines 
wouldn't return their values.
Pekr
12-Oct-2010
[5255]
if we can't have full fledget debugger, then we are crap :-)
Steeve
12-Oct-2010
[5256]
maybe we could have a FUNC idiom that doesn't protect anything for 
debugging purposes ?
Maxim
12-Oct-2010
[5257]
right now, the only thing I can't "anamonitor" is a function body. 
 I can get that function's body, but can't resolve what the functions 
*it* contains really do.  


all the rest works pretty much as is did, actually it works better, 
since we have real inspection routines now.
BrianH
12-Oct-2010
[5258]
If we want to be able to use R3 to show third-party content, then 
full debugging without the original source won't be allowed. It's 
the way of the world now.
Maxim
12-Oct-2010
[5259]
brianh, we can't debug *with* the source right now  :-)
Steeve
12-Oct-2010
[5260]
Ok, but for our own work, we still need to do so.
Maxim
12-Oct-2010
[5261]
hehe
BrianH
12-Oct-2010
[5262]
I can (and do) want the world to be open and all information to be 
free, but it's just not the way the world is now.
Maxim
12-Oct-2010
[5263]
huh? BrianH this has nothing to do with 3rd party.  we can't debug 
functions of any kind right now.  with source, hot chocolate or from 
the movie wizard of Oz.
BrianH
12-Oct-2010
[5264]
And you can debug if you have the source. However, some of the process 
will go through your head, in the form of knowledge of where functions 
are defined. Or you can take portions of the source without the protections 
and debug them independently.
Maxim
12-Oct-2010
[5265]
debugging implies that a tool shows you that information... the name 
of a function or word is irrelevant in REBOL.
BrianH
12-Oct-2010
[5266]
If you need to debug your own source, you can do so. You just can't 
use a debugger to get past the protections.
Maxim
12-Oct-2010
[5267]
for example, if I want to do a real time debugger which shows me 
the current content of the block which is being stepped through by 
a loop... 

I can't since I can't get access to the block which is being used 
by that function...
Steeve
12-Oct-2010
[5268]
Yes Maximn, to do runtime debugging, we must be allowed to construct 
observable functions
BrianH
12-Oct-2010
[5269]
There are other methods of debugging at runtime if you have the source. 
Heck, even good old print statement debugging would work.
Steeve
12-Oct-2010
[5270x2]
it could be simulated with a special mezz. A function which executes 
an indirect DO on one code block instead of building a function.
So that the code block could still be inspected by a debuging tool.