How best to blockify?

Carl Sassenrath, CTO
REBOL Technologies
15-Mar-2007 1:24 GMT

Article #0063
Main page || Index || Prior Article [0062] || Next Article [0064] || 17 Comments || Send feedback

This is a really common line of code:

unless block? value [value: reduce [value]]

If the value is not a block, make a new block that holds the value. This is frequently used in functions that use block arguments to allow them to accept other values.

I would like a simpler function to do that. Something like:

blk: blockize value

Of course, I don't like the blockize name that much, but it is consistent with dirize.

You might think that:

to block! value


make block! value

could do what we need, but they have special exceptions for some datatypes. For example if the value is a string, it is loaded. If the value is an integer, make creates a block of that size. Those kinds of exceptions are fairly standard in the conversion functions.

So, since reduce creates block, perhaps a cousin could be:

blk: deduce value


blk: enduce value

Those are both good names... so good, I can almost see them for some kind of prologish function; I'm just not sure what.



Updated 24-Mar-2017 - Edit - Copyright REBOL Technologies -