REBOL3 tracker
  0.9.12 beta
Ticket #0002240 User: anonymous

Project:

Previous Next
Short URL: http://issue.cc/r3/2240
rss
TypeWish Statussubmitted Date8-Aug-2015 09:05
Versionr3 master CategoryEvaluation Submitted byfork
PlatformAll Severityminor Prioritynormal

Summary Make non-"special" DO types error until special behaviors conceived
Description Consider:

>> code: "print {Hello}"
>> do code
Hello

>> code: <print {Hello}>
>> do code
<print {Hello}>

While both are strings, one of them triggered an evaluation as code...while the other merely gave back its literal form.

It is the first "special" behavior that is the reason for DO's existence. Having a mundane behavior which may become relied upon weakens the offerings for what the type might do in the future.

For instance, TAG! might be used by DO to search some kind of common module library, as a level of indirection for a full URL.

>> do <matrix>

A PATH! might be used to request a version of that library, and in the NewPath! world it might look like this:

>> do '<matrix>/1.0.5

But right now the default when DO doesn't know what to do with a type is to return the value as-is. There are other questionable behaviors for WORD!, GET-WORD!, LIT-WORD!, and LIT-PATH! for some reason.

(DO'ing an error to activate it makes sense, given there's no other real way to throw an error, so that seems like an okay special behavior...though it might make more sense to make that the default behavior for THROW of an ERROR!, with THROW/ONLY used to have it be caught via catch.)

While on the topic, I'll mention there have already been active challenges to the idea of whether DO should be allowed to work on a FUNCTION!. The reason this is challenged is because it makes DO a "special outlier" in terms of being effectively variable arity:

>> foo: func [x] [print x]
>> do :foo "Hello"
Hello

This could have been achieved equally well with `foo "Hello"`. The theoretical benefit would be that you have something which might be a block, a function, or a string but don't know which...and you want DO to handle it regardless. But that really only makes since for single arity functions then, because the others could not consume parameters.

By that argument it could be kept for single arity functions but not others; although this again points to the weirdness of the other anti-invariants like "runs strings, returns tags as is".
Example code

			

Assigned ton/a Fixed in- Last Update8-Aug-2015 21:42


Comments

Date User Field Action Change
8-Aug-2015 21:42 Fork Description Modified -
8-Aug-2015 09:05 Fork Ticket Added -