I’m not a real Geek, I prefer “User Friendly” Stuffs (like the Easy yUML Language) and because I’m lazy I hate to over-repeat myself (happily the Good DRY principle will support me!). Programming Syntax in any languages even Rebol tend to create Procrastination inside my head so I always think about ideas to alleviate them by any mean or almost as here I will give up this is why :).
For example, instead of having to write all these instructions:
temp: to-rebol-file "temp.txt"
write temp now
temp: read temp
print temp
I would like rather to be able to write them exactly as I think them without variable temp definition pollution:
to-rebol-file "temp.txt"
write it now
read it
print it
So I need to override the system or native functions so as to store their return value implicitly to the it variable. In many programming languages that would be impossible as Native means Untouchable but in Rebol that’s a blessing, you are free to do so. So we need to overwrite to-rebol-file and read system functions here by doing this:
1. Copy the native function implementation to another Word.
2. Assign the new function implementation to the native word.
Here’s how to do so with the to-rebol-file function:
;copy native implementation to ~to-rebol-file
~to-rebol-file: :to-rebol-file
;redefine to-rebol-file as
to-rebol-file: func[path [file! string!]][
it: ~to-rebol-file path
]
and for the read function … Oh my this is going to be much more complicated as when you type in Rebol Console, you can see a bunch of functions refinement:
>> help read
USAGE:
READ source /binary /string /direct /no-wait /lines /part size /with end-of-line /mode args /c
ustom params /skip length
DESCRIPTION:
Reads from a file, url, or port-spec (block or object).
READ is a native value.
ARGUMENTS:
source -- (Type: file url object block)
REFINEMENTS:
/binary -- Preserves contents exactly.
/string -- Translates all line terminators.
/direct -- Opens the port without buffering.
/no-wait -- Returns immediately without waiting if no data.
/lines -- Handles data as lines.
/part -- Reads a specified amount of data.
size -- (Type: number)
/with -- Specifies alternate line termination.
end-of-line -- (Type: char string)
/mode -- Block of above refinements.
args -- (Type: block)
/custom -- Allows special refinements.
params -- (Type: block)
/skip -- Skips a number of bytes.
length -- (Type: number)
Oops, looking over the Internet, I found this article about Passing refinements between functions it seems clearly not easy to be able to just forward to the native ~read function. If the system allows to override native functions then it should facilitate the process to call the base parent (kind of inheritance mechanism that exists in traditional OOP).
This limit is not conceptual limit of a Prototyped OOP language as far as I can see, it’s rather an implementation limit so I hope this will be alleviated in Rebol 3.
For now on, I could use this syntax instead though not quite as elegant:
WriteIt now
ReadIt
PrintIt

















