Skip to content

To, make, load, transcode given string sources

hiiamboris edited this page Feb 10, 2024 · 13 revisions

Drafting notes to facilitate discussion of string conversions to different types.

String conversions

type to make load transcode/one Notes

unset!

any

any

N/A

N/A

Can’t produce unset with load/transcode

none!

any

any

" #[none] "

" #[none] "

Leading and trailing whitespace allowed

logic!

see note

see note

true

true

Only (true)/(false), not on/off or yes/no; leading and trailing whitespace allowed. For to/make see [this](https://github.com/red/red/wiki/%5BDOC%5D-%60to%60-vs-%60make%60)

char!

#"a"

a

a

#"a"

to/make use the first char of the string only; leading and trailing whitespace allowed for load/transcode

integer!

123

123

123.45

123.45

Given "123.45" to/make don’t allow leading whitespace; trailing whitespace is OK. Load/transcode load floats as floats.

float!

123.45

123.45

123.45

123.45

Given "123.45" to/make don’t allow leading or trailing whitespace.

percent!

50%

50%

50%

50%

Given "50%" to/make allow trailing whitespace, but not leading whitespace.

pair!

1x2

1x2

1x2

1x2

Given "1x2" to/make allow leading whitespace, but not trailing whitespace.

tuple!

1.2.3

1.2.3

1.2.3

1.2.3

Given "1.2.3" to/make allow leading whitespace, but not trailing whitespace.

TBD

date! now/date 10-Jun-2018 10-Jun-2018 10-Jun-2018 10-Jun-2018

time!

now/time

21:07:47

21:07:47

21:07:47

21:07:47

word!

'abc

abc

abc

abc

abc

set-word!

quote abc:

abc

abc

abc:

abc:

lit-word!

quote 'abc

abc

abc

'abc

'abc

get-word!

quote :abc

abc

abc

:abc

:abc

refinement!

/abc

abc

abc

/abc

/abc

issue!

#abc

abc

abc

#abc

#abc

block!

[1 2 3]

123

1 2 3

[1 2 3]

[1 2 3]

paren!

quote (1 2 3)

123

1 2 3

(1 2 3)

(1 2 3)

hash!

make hash! [1 2 3]

123

1 2 3

make hash! …​

make hash! …​

path!

'a/b/c

a/b/c

a/b/c

a/b/c

a/b/c

lit-path!

quote 'a/b/c

'a/b/c

'a/b/c

'a/b/c

'a/b/c

set-path!

quote a/b/c:

a/b/c:

a/b/c:

a/b/c:

a/b/c:

get-path!

quote :a/b/c

:a/b/c

:a/b/c

:a/b/c

:a/b/c

string!

"abc"

abc

abc

"abc"

"abc"

file!

%abc.def

abc.def

abc.def

%abc.def

%abc.def

url!

http://abc.def

http://abc.def

http://abc.def

http://abc.def

http://abc.def

tag!

<a href="red-lang.org">

a href="red-lang.org"

<a href="red-lang.org">

<a href="red-lang.org">

<a href="red-lang.org">

email!

user@host.com

user@host.com

user@host.com

user@host.com

user@host.com

vector!

make vector! [1 2 3]

1 2 3

1 2 3

make vector! …​

make vector! …​

image!

make image! 2x2

make image! …​

make image! …​

make image! …​

make image! …​

binary!

#{313233}

123

#{313233}

#{313233}

#{313233}

bitset!

charset "abc"

make bitset! …​

make bitset! …​

make bitset! …​

make bitset! …​

map!

#[a: 1 b: 2]

a: 1 b: 2

a: 1 b: 2

#[ a: 1 b: 2 ]

#[ a: 1 b: 2 ]

object!

object [a: 1 b: 2]

a: 1 b: 2

a: 1 b: 2

make object! …​

make object! …​

error!

try [1 / 0]

* Math Error: …​

* Math Error: …​

make error! …​

make error! …​

native!

:if

?native?

?native?

make native! …​

make native! …​

action!

:add

?action?

?action?

make action! …​

make action! …​

op!

:+

?op?

?op?

make op! …​

make op! …​

function!

func [a b][a + b]

?function?

?function?

func[…​][…​]

func[…​][…​]

routine!

:event?

?routine?

?routine?

routine[…​][…​]

routine[…​][…​]

datatype!

action!

action

action

action!

action!

typeset!

number!

make typeset! …​

make typeset! …​

make typeset! …​

make typeset! …​

Clone this wiki locally