Skip to content

Commit

Permalink
Finalize decision that TRASH doesn't display in console
Browse files Browse the repository at this point in the history
  • Loading branch information
hostilefork committed Mar 3, 2024
1 parent 852d9fb commit 316f821
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 55 deletions.
20 changes: 14 additions & 6 deletions extensions/console/ext-console-init.reb
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,23 @@ export console!: make object! [
v: first v ; items in pack are ^META'd
]

=== PRINT NOTHING FOR VOID ===
=== PRINT NOTHING FOR TRASH ===

; VOID lacks any representation. So there's nothing we can print
; like `== void` (which would look like the WORD! void), and no special
; syntax exists for them...only meta/quasiforms...that's by design.
; By default, we've decided that some value needs to not display in
; the console, to suppress output from things like HELP or PRINT,
; because it's noisy to have `== xxx` produced in that case.
;
; So giving *no* output is the most natural case for such a situation.
; (Of course, a console customization could be done which displayed
; all results...but the default should look somewhat streamlined.)
;
; Whatever doesn't display will be a "lie" in some sense. The two
; competing lies are VOID (a.k.a. the ~void~ WORD! antiform) and
; TRASH (a.k.a. ~, the antiform of blank). The decision has flipped
; many times, but trash is the winner.
;
; https://forum.rebol.info/t/console-treatment-of-void-vs-trash/2045

if v = void' [
if v = trash' [
return ~
]

Expand Down
4 changes: 2 additions & 2 deletions extensions/debugger/mod-debugger.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ bool Do_Breakpoint_Throws(
//
// "Signal breakpoint to the host, but do not participate in evaluation"
//
// return: [nihil?]
// return: [~]
// ]
//
DECLARE_NATIVE(breakpoint_p)
Expand All @@ -130,7 +130,7 @@ DECLARE_NATIVE(breakpoint_p)
if (not Is_Quasi_Word(SPARE))
fail ("BREAKPOINT is invisible, can't RESUME/WITH code (use PAUSE)");

return Init_Nihil(OUT);
return Init_Trash(OUT);
}


Expand Down
4 changes: 2 additions & 2 deletions src/core/d-dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void Dump_Stack(Level* L)
//
// "Temporary debug dump"
//
// return: [nihil?]
// return: [~]
// :value [word!]
// ]
//
Expand Down Expand Up @@ -174,6 +174,6 @@ DECLARE_NATIVE(dump)
PROBE(var);
}

return Init_Nihil(OUT);
return Init_Trash(OUT);
#endif
}
10 changes: 3 additions & 7 deletions src/main/main-startup.reb
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ boot-banner: [

about: func [
"Information about REBOL"
return: [nihil?]
return: [~]
][
print make-banner boot-banner
return nihil
]


Expand All @@ -116,7 +115,7 @@ about: func [
;
usage: func [
"Prints command-line arguments."
return: [nihil?]
return: [~]
][
; --cgi (-c) Load CGI utiliy module and modes
; --version tuple Script must be this version or greater
Expand Down Expand Up @@ -161,16 +160,13 @@ usage: func [
REBOL
REBOL -q --about --suppress "%rebol.reb %user.reb"
}

return nihil
]

license: func [
"Prints the REBOL/core license agreement."
return: [nihil?]
return: [~]
][
print system.license
return nihil
]

host-script-pre-load: func [
Expand Down
13 changes: 6 additions & 7 deletions src/mezz/base-defs.r
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ to-lit-path: func* [return: [quoted?] value [element?]] [
print: func* [
{Output SPACED text with newline (evaluating elements if BLOCK!)}

return: "See NIHIL docs for caution on casually making vaporizing routines"
[nihil?]
return: "Returns null if line outputs nothing, e.g. print [void]"
[~ ~null~]
line "Line of text or block, [] has NO output, CHAR! newline allowed"
[<maybe> char? text! block! quoted?]
][
Expand All @@ -336,7 +336,7 @@ print: func* [
fail "PRINT only allows CHAR! of newline (see WRITE-STDOUT)"
]
write-stdout line
return nihil
return ~
]

if quoted? line [ ; Speculative feature: quote mark as a mold request
Expand All @@ -345,15 +345,15 @@ print: func* [

write-stdout (maybe spaced line) then [
write-stdout newline
] else [
return null
]

return nihil
]

echo: func* [
{Freeform output of text, with @WORD, @TU.P.LE, and @(GR O UP) as escapes}

return: [nihil?]
return: [~]
'args "If a BLOCK!, then just that block's contents--else to end of line"
[element? <variadic>]
<local> line
Expand All @@ -380,7 +380,6 @@ echo: func* [
]
]
write-stdout newline
return nihil
]


Expand Down
5 changes: 2 additions & 3 deletions src/mezz/mezz-files.r
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ confirm: func [
list-dir: func [
"Print contents of a directory (ls)."

return: [nihil?]
return: [~]
'path [<end> file! word! path! text!]
"Accepts %file, :variables, and just words (as dirs)"
/l "Line of info format"
Expand Down Expand Up @@ -328,7 +328,7 @@ list-dir: func [
let files: attempt [read %./] else [
print ["Not found:" :path]
change-dir save-dir
return nihil
return ~
]

for-each file files [
Expand Down Expand Up @@ -356,7 +356,6 @@ list-dir: func [
all [text? l, not empty? l] then [print l]

change-dir save-dir
return nihil
]


Expand Down
32 changes: 16 additions & 16 deletions src/mezz/mezz-help.r
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ browse: func [
help: func [
"Prints information about words and values (if no args, general help)."

return: [nihil?]
return: [~]
'topic [<end> element?]
"WORD! whose value to explain, or other HELP target (try HELP HELP)"
/doc "Open web browser to related documentation."
Expand Down Expand Up @@ -144,7 +144,7 @@ help: func [
upgrade - check for newer versions
usage - program cmd line options
}
return nihil
return ~
]

; HELP quotes, but someone might want to use an expression, e.g.
Expand All @@ -157,7 +157,7 @@ help: func [
if match [group! get-word! get-path! get-tuple!] topic [
topic: reeval topic else [
print "NULL is a non-valued state that cannot be put in arrays"
return nihil
return ~
]
]

Expand Down Expand Up @@ -187,7 +187,7 @@ help: func [

browse join https://r3n.github.io/topics/ as text! topic
print newline
return nihil
return ~
]

text! [
Expand All @@ -201,7 +201,7 @@ help: func [
] else [
print ["No information on" topic]
]
return nihil
return ~
]

path! word! [
Expand All @@ -212,12 +212,12 @@ help: func [
null? binding of topic
] then [
print [topic "is an unbound WORD!"]
return nihil
return ~
]

if '~attached~ = binding of topic [
print [topic "is ~attached~ to a context, but has no variable"]
return nihil
return ~
]

switch/type value: get/any topic [
Expand All @@ -231,7 +231,7 @@ help: func [
print [topic "is not defined (e.g. has a trash value)"]
]
] then [
return nihil
return ~
]
enfixed: (action? :value) and (enfix? :value)
]
Expand All @@ -247,7 +247,7 @@ help: func [
if free? topic [keep "a *freed*"]
keep any [mold kind of topic, "VOID"]
]
return nihil
return ~
]

; Open the web page for it?
Expand Down Expand Up @@ -294,7 +294,7 @@ help: func [
] else [
print [topic {is a datatype}]
]
return nihil
return ~
]

match [frame! action?] :value else [
Expand All @@ -317,7 +317,7 @@ help: func [
]
]
]
return nihil
return ~
]

; The HELP mechanics for ACTION! are more complex in Ren-C due to the
Expand Down Expand Up @@ -410,14 +410,14 @@ help: func [
print-args/indent-words refinements
]

return nihil
return ~
]


source: func [
"Prints the source code for an ACTION! (if available)"

return: [nihil?]
return: [~]
'arg [<unrun> word! path! frame! tag!]
][
let name
Expand All @@ -437,7 +437,7 @@ source: func [
name: arg
f: get arg else [
print [name "is not set to a value"]
return nihil
return ~
]
]
] else [
Expand All @@ -459,7 +459,7 @@ source: func [
]
]
] then [
return nihil
return ~
]

; ACTION!
Expand Down Expand Up @@ -488,7 +488,7 @@ source: func [
print "...native code, no source available..."
]

return nihil
return ~
]


Expand Down
24 changes: 12 additions & 12 deletions tests/misc/help.test.reb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
; It has had a tendency to break, so these tests are here even though they
; spew a large amount of output, in the interests of making HELP stay working.

(nihil? help)
(nihil? help help)
(nihil? help system)
(nihil? help to)
(nihil? help "to-")
(nihil? help "to")
(nihil? help void)
(nihil? help xxx)
(nihil? help function)
(trash? help)
(trash? help help)
(trash? help system)
(trash? help to)
(trash? help "to-")
(trash? help "to")
(trash? help void)
(trash? help xxx)
(trash? help function)

(
for-each w words of lib [
Expand All @@ -30,7 +30,7 @@
(compose/deep [assert [trash? help (w)]])
else [
if not issue? get w [ ; "don't open web browser"
assert [nihil? help (get w)]
assert [trash? help (get w)]
]
]
]
Expand All @@ -50,7 +50,7 @@
)

[https://github.com/metaeducation/ren-c/issues/1106
(nihil? help "any")
(trash? help "any")
]

(nihil? about)
(trash? about)

0 comments on commit 316f821

Please sign in to comment.