[REBOL] Tools for Rebol Coders
From: sunandadh::aol::com at: 6-Jan-2002 4:59
Hi Carl,
Carl Read in [REBOL] Re: source code layout question
> No, in that I would think it's probably impossible with REBOL. For
> instance, how would you optomize 'blk to allow for a later...
>
> change blk whatever
>
> Your "code" from REBOL's point of view is all just data, remember.
True indeed. I was half joking because I know an optimizer would be of
similar difficulty to writing a compiler, given that anything can change into
anything at anytime.
But only half joking. If the other Carl can make his "mental reduction" then
there is no reason why a program can't at least make similar suggestions,
even if they are wring in a wider context.
So my serious suggestion is for lint.r named after the traditional C program
that tells you just how many rules you've possibly broken. A Rebol Lint
checker could for example highlight possible problems in this code:
myFunc: func [Offset Size]
[
MyLayout: layout [button "hello"] Offset
View/New MyLayout "My Layout"
]
-- Function header doesn't specify datatypes
-- "Size" defined in function header but not used
-- "Mylayout" created as global
-- "Offset" in Layout evaluated by not assigned
-- "My Layout" string in View/New evaluated by not assigned
-- No explicit Return statement
Which may immediately lead me to the code I meant to write:
MyFunc: func [Offset [Pair!] Size [Pair!] /local MyLayout]
[
MyLayout: layout/Size/Offset [button "hello"] Size Offset
View/New/Title MyLayout "My Layout"
Return True
]
Of course, with Lint checkers you have to ignore 90% of what they tell you.
But they can spot bugs that the human eye just won't see, so that other 10%
can be lifesaver.
So I am serious about Rebol having some heavyweight tools:
Pretty-print.r with its own dialect for layouting out Rebol code because we
will never get the world to agree on a single style. And even if we did, I'd
still want my code cleaned up at the end of a messy edit session.
Lint.r because an expert eye looking over code is always a useful thing. And
it could help newcomers to the language get up to speed. Again it would need
its own dialect to say what sort of potential errors you want checked.
Andrew's made a start on some of these with the tools he develops in "The
Official Guide"
Sunanda.