Add ANY-SERIES/SCALAR/NUMBER to r2r3-future.reb
Add ANY-SERIES/SCALAR/NUMBER to r2r3-future.reb

The r2r3-future.reb file is something of relatively limited interest (for
adapting Rebol2 and R3-Alpha in a way that it might run Ren/C or future
scripts).  That will be impossible in general, but for a limited sense it can
work for a subset of files.  One relevant subset: the make prep scripts.

Because FAIL is a widely relevant change, it has a small shim in the
r2r3-future.r file.  The FAIL shim depended on scalar? which was converted
to any-scalar?, which had no shim.  This adds those shims, and makes a
note that this stub file needs a "Czar" to get it into better shape for those
who would be interested beyond the `make prep` script's needs.

rgchris/ren-c,rgchris/ren-c,rgchris/ren-c,giuliolunati/ren-c,kealist/ren-c,giuliolunati/ren-c,hostilefork/rebol,hostilefork/rebol,giuliolunati/ren-c,codebybrett/ren-c,draegtun/ren-c,codebybrett/ren-c,kealist/ren-c,rgchris/ren-c,hostilefork/rebol,draegtun/ren-c,codebybrett/ren-c,kealist/ren-c,kealist/ren-c,codebybrett/ren-c,draegtun/ren-c,draegtun/ren-c,kealist/ren-c,codebybrett/ren-c,rgchris/ren-c,giuliolunati/ren-c,hostilefork/rebol,giuliolunati/ren-c,draegtun/ren-c,hostilefork/rebol
REBOL [
	Title: "Rebol2 and R3-Alpha Future Bridge to Ren/C"
	Rights: {
		Rebol is Copyright 1997-2015 REBOL Technologies
		REBOL is a trademark of REBOL Technologies

		Ren/C is Copyright 2015 MetaEducation
	}
	License: {
		Licensed under the Apache License, Version 2.0
		See: http://www.apache.org/licenses/LICENSE-2.0
	}
	Author: "@HostileFork"
	Purpose: {
		These routines can be run from a Rebol2 or R3-Alpha
		to make them act more like Ren/C (which aims to
		implement a finalized Rebol3 standard).

		!!! Rebol2 support intended but not yet implemented.

		!!! This file is a placeholder for a good design, at time of writing
		it has repeated patterns that are just for expedience.  It is
		awaiting someone who has a vested interest in legacy code to become
		a "maintenance czar" for the concept.
	}
]

unless value? 'length [length: :length? unset 'length?]
unless value? 'index-of [index-of: :index? unset 'index?]
unless value? 'offset-of [offset-of: :offset? unset 'offset?]
unless value? 'type-of [type-of: :type? unset 'type?]

unless value? 'for-each [
	for-each: :foreach every: :foreach
	;unset 'foreach ;-- tolerate it (for now, maybe indefinitely?)
]

; *all* typesets now are ANY-XXX to help distinguish them from concrete types
; https://trello.com/c/d0Nw87kp
;
unless value? 'any-scalar? [any-scalar?: :scalar?]
unless value? 'any-series? [any-series?: :series?]
unless value? 'any-number? [any-number?: :number?]

; It is not possible to make a version of eval that does something other
; than everything DO does in an older Rebol.  Which points to why exactly
; it's important to have only one function like eval in existence.
unless value? 'eval [
    eval: :do
]

unless value? 'fail [
	fail: func [
		{Interrupts execution by reporting an error (a TRAP can intercept it).}
		reason [error! string! block!] "ERROR! value, message string, or failure spec"
	][
		case [
			error? reason [do error]
			string? reason [do make error! reason]
			block? reason [
				for-each item reason [
					unless any [
						any-scalar? :item
						string? :item
						paren? :item
						all [
							word? :item
							not any-function? get :item
						]
					][
						do make error! (
							"FAIL requires complex expressions to be in a PAREN!"
						)
					]
				]
				do make error! form reduce reason
			]
		]
	]
]

; R3-Alpha and Rebol2 did not allow you to make custom infix operators.
; There is no way to get a conditional infix AND using those binaries.
; In some cases, the bitwise and will be good enough for logic purposes...
;
unless value? 'and* [
	and*: :and
	and?: func [a b] [and* true? :a true? :b]
]
unless value? 'or+ [
	or+: :or
	or?: func [a b] [or+ true? :a true? :b]
]
unless value? 'xor- [
	xor-: :xor
	xor?: func [a b] [xor- true? :a true? :b]
]

REBOL [
	Title: "Rebol2 and R3-Alpha Future Bridge to Ren/C"
	Rights: {
		Rebol is Copyright 1997-2015 REBOL Technologies
		REBOL is a trademark of REBOL Technologies

		Ren/C is Copyright 2015 MetaEducation
	}
	License: {
		Licensed under the Apache License, Version 2.0
		See: http://www.apache.org/licenses/LICENSE-2.0
	}
	Author: "@HostileFork"
	Purpose: {
		These routines can be run from a Rebol2 or R3-Alpha
		to make them act more like Ren/C (which aims to
		implement a finalized Rebol3 standard).

		!!! Rebol2 support intended but not yet implemented.
	}
]

unless value? 'length [length: :length? unset 'length?]
unless value? 'index-of [index-of: :index? unset 'index?]
unless value? 'offset-of [offset-of: :offset? unset 'offset?]
unless value? 'type-of [type-of: :type? unset 'type?]

unless value? 'for-each [
	for-each: :foreach every: :foreach
	;unset 'foreach ;-- tolerate it (for now, maybe indefinitely?)
]

; It is not possible to make a version of eval that does something other
; than everything DO does in an older Rebol.  Which points to why exactly
; it's important to have only one function like eval in existence.
unless value? 'eval [
    eval: :do
]

unless value? 'fail [
	fail: func [
		{Interrupts execution by reporting an error (a TRAP can intercept it).}
		reason [error! string! block!] "ERROR! value, message string, or failure spec"
	][
		case [
			error? reason [do error]
			string? reason [do make error! reason]
			block? reason [
				for-each item reason [
					unless any [
						any-scalar? :item
						string? :item
						paren? :item
						all [
							word? :item
							not any-function? get :item
						]
					][
						do make error! (
							"FAIL requires complex expressions to be in a PAREN!"
						)
					]
				]
				do make error! form reduce reason
			]
		]
	]
]

; R3-Alpha and Rebol2 did not allow you to make custom infix operators.
; There is no way to get a conditional infix AND using those binaries.
; In some cases, the bitwise and will be good enough for logic purposes...
;
unless value? 'and* [
	and*: :and
	and?: func [a b] [and* true? :a true? :b]
]
unless value? 'or+ [
	or+: :or
	or?: func [a b] [or+ true? :a true? :b]
]
unless value? 'xor- [
	xor-: :xor
	xor?: func [a b] [xor- true? :a true? :b]
]
