REBOL 3.0

Comments on: Expanded console return values?

Carl Sassenrath, CTO
REBOL Technologies
29-Sep-2006 22:24 GMT

Article #0046
Main page || Index || Prior Article [0045] || Next Article [0047] || 28 Comments || Send feedback

Do you want to see more values printed as the default return in the console?

In R2.0, if you type:

>> obj: make object! [a: 10 b: 20]

you see no result. This is intentional. It saves you from seeing what could be a very large return value (imagine SYSTEM object here).

Currently, in R3, the console returns this result:

>> obj: make object! [a: 10 b: 20]
== make object! [
    a: 10
    b: 20
]

This has been useful to me, due to the required level of testing necessary for building a new REBOL.

The question for you is this: Would that result be useful to you as well?

It may be possible to make it a "mode" option of the console.

I realize this is a little issue. But, there is a very long list of such little issues that require thought and discussion. Also, it's not really as little it may seem. Consider the shocked reaction a new user may have the first time he types the word SYSTEM at the console.

28 Comments

Comments:

Dan Lee
29-Sep-2006 19:28:38
REBOL 2.0 prints most return values to the console, but only prints the first 128 characters if the output is too large.

It would be nice to have R3 print out all return values to the console. I would imagine that R3 could simply truncate lengthy output, similar to the following R2 behavior:

>> mold system
== {make object! [
    version: 1.3.2.4.2
    build: 16-Mar-2006/12:15:41-8:00
    product: 'View
    core: 2.6.3
    components: [...
>> 

Maybe there could be a setting for how much REBOL prints on the console. Sometimes I don't mind lengthy output.

Oldes
29-Sep-2006 20:09:18
Dan, I don't agree, it would be useles. If I mold something I want to see it. But it would be probably good to have same output for "system" as for "? system". I think it's better to see something than nothing and it can help newbies to explore Rebol's guts. If it will be possible to disable such a behaviour in options, I don't see any problem with this issue.
Oldes
29-Sep-2006 20:15:26
ech, you are right Dan, the mold behaviour with truncating is better:-) I just tried to do "? system/words" and I think it would not be too good to see such a big list too often. But I still agree that it's good to see something.
Oldes
29-Sep-2006 20:20:41
And it's related to object values returned from functions as well. I'm sure I don't want to see such a big object as system/words if it's returned from function:
>> test: does [print "something" "a"]
>> test
something
== "a"
>> test: does [print "something" system/words]
>> test
something
>>
Maxim Olivier-Adlhoch
29-Sep-2006 22:58:51
being the power user that I am, I wonder if there might not be a way to actually configure such things via callbacks.

It allows us the flexibility we want and need, and it removes the stress from RT to implement "The right" solution... frankly there is none.

In certain situations, I'd already like there to be NO output. and sometimes I wish there where more. and yet sometimes I wish it printed something ELSE. so what is the right solution?

It could be nice is this and other philosophical kind of details where programable.

simply a global callback you can replace. In this case which either prints or probes whatever you need out of a return value of your console session. sometimes I'd like to realise that something returns unset! this is something not readily obvious to newbies...

an example I can provide is that I have replaced the way probe works. my version probes a mold/all. this makes sure I do not confuse #[none] and the word 'NONE. Many times this detail had me going in circles. But I have no way of fixing this issue in the console directly... so I must always wrap the probe on the command line... which is nagging when you do a lengthy code test.

Maxim Olivier-Adlhoch
29-Sep-2006 23:01:08
a good example is the prompt. that is programmable. and some of us need that flexibility, others do not. I wish more of the interpreter itself where "hookable".
Volker
30-Sep-2006 2:22:03
Want to see objects too. The easiest configuration would be a max-line-count. Callback would be nice too, then objects could be printed with 'help.
Volker
30-Sep-2006 2:24:38
Small objects could be printed in one line, >> obj: make object! [a: 10 b: 20] == make object! [a: 10 b: 20]
Henrik
30-Sep-2006 4:51:41
Size indications could be nice.

>> system
== make object! [
    version: 1.3.2.4.2
    build: 16-Mar-2006/12:15:41-8:00
    product: 'View
    core: 2.6.3
    components: [...
(6789 more lines, 567 elements)
>>

Listing the amount of lines could give an indication of how "bad" the problem is, as you don't normally have indication of the size of the object without doing a bit of digging.

For small objects that fit within the limit, this shouldn't be necessary, of course.

I agree on having a variable limit on the size of the output. NONE could mean no output like now. 0 could mean it would always output the size. N-value would print N lines of the object and then the size.

DideC
30-Sep-2006 5:05:50
I like the callback idea :-)

The standard callback prints a small length like the Henrik's example. And you can customize it to print all the result, the type, nothing, or whatever you need.

Ingo
30-Sep-2006 12:12:09
I like the shortened output, with length indication, as default.

I don't think that I'll have mutch use of any preferences in this regard.

I sometimes would like a way to get the last output again, e.g. I have a function that creates a temp-file and opens an external editor.

This function returns the name of the temp-file. If I no, that I want to further process the file with rebol, I store the name in a word, but sometimes I forget ...

; example
>> ed
== %tmp-xxx.r
>> do last-return
; would now do the file I just edited.

Just an idea.

Rebolek
2-Oct-2006 2:20:49
Why cannot MOLD just print one page with line saying something like "Press ENTER to continue, SPACE to stop" ? You see something, if you want to see more, you can, if you do not want, no problem.
Brian Hawley
2-Oct-2006 8:22:35
The main problem I would have with a callback would be potential security issues, but if security is considered then a callback would be good for me.
Scot
2-Oct-2006 13:04:34
I often dump to a file. Would be nice to have a setting that can be easily turned on that dumps to a file. The file name could be time and date stamped for easy retrieval or something. I would most likely have it open and refresh it in a text editor.
Volker
3-Oct-2006 13:10:59
Scot, echo on ;)
Brian Tiffin
3-Oct-2006 19:53:08
Consistency is important to us almost newbies.

>>obj ; no output
>>
>>obj/a ; output 10
== 10
It can be a little confusing whilst running up the object! learning curve.

So I vote for more output on the console. As long as ESC works, dump everything everytime.

With the caveat that the console stays hidden for view scripts unless prin or printed to.

Scot
4-Oct-2006 11:54:41
Volker...problem with echo is that it still echos to the console, I want to redirect it to the file, without it showing on the console. In fact I'd like to be able to redirect the console output entirely so a console never pops up.
Volker
5-Oct-2006 7:35:41
system/ports/output: open/direct %log.txt

Maybe a echo/only ? And a combination, short output in console, full output in file?

Anton Rolls
5-Oct-2006 11:40:34
Mmm.. I'm pretty happy with the way it is now (no printing of objects). But this was confusing at first and took a while to get used to. Perhaps if there is no molding by default there should be a console command to print out N lines of the last value, molded. Example, this only prints two lines of the molded object value:

>> context [a: b: c: 1]
>> probe-last-n 2
make object! [
a: 1

Kind of like TOP.

Philippe
6-Oct-2006 3:55:41
Scot, Carl talk about redirections in his blog ( http://www.rebol.net/article/0004.html ).

I.e redirections with the shell (OS related): Make a script with the next line or directly in command line :

rebol.exe -wq code.r <infile.txt >outfile.txt 

(Use -wq options )

Content of infile.txt is sent via stdin to the script code.r and outfile.txt is created (at each run)

Example for infile.txt file :

	print "HELLO WORLD"
	blk: copy system/locale/months
	foreach m blk [print m]

Example for code.r file :

 REBOL[]

print "BEGIN TEST" set-modes system/ports/input [lines: false binary: false] buffer: copy system/ports/input do buffer ; not secure print "END TEST" quit

stdin content (system/ports/input) is append to the buffer, and evaluated. All displays are sent to stdout (outfile.txt)

result in outfile.txt :

	BEGIN TEST
	HELLO WORLD
	January
	February
	March
	April
	May
	June
	July
	August
	September
	October
	November
	December
	END TEST
Ladislav
6-Oct-2006 9:49:15
When you are at it, I suggest to upgrade mold to mold/all for: binary! bitset! function! hash! image! list! object! struct!
Carl Sassenrath
6-Oct-2006 15:39:17
Do you mean for R3.0, or for R V2.6.3 release?
Ladislav
7-Oct-2006 4:57:48
Sorry, I meant my suggestion for R3.0 and the list should be: bitset! function! hash! image! list! object! struct!
Carl Sassenrath
7-Oct-2006 16:10:18
Yes, I think it is a good idea to do so. What do other's think?
Ladislav
8-Oct-2006 3:50:27
I noticed a couple of positives, no negative in the blog chat.
Henrik
8-Oct-2006 8:08:29
Ladislav, maybe you could explain the benefits to non-experts?
Ladislav
8-Oct-2006 10:39:35
benefits:

1) it is shorter

2) one value cannot be confused with three

Maxim Olivier-Adlhoch
11-Oct-2006 14:47:25
I suggested the mold/all idea before, I'm all for it!

Henrik: here is a concrete example: when printing out a block which outputs this:

== [none make! object [a: 1]]

It leads to the hardest to debug issues, especially after a load and within nested blocks, where evalutation isn't usually done recursively.

is it a none word or a none value? is make! an unbound word, or is the actual object datatype description? using mold/all you will receive:

== [#[none] #[objet [a: 1]]

so there is no confusion possible.

which is why my probe method is replaced to ALWAYS mold/all. simple values stay the same anyways.

Post a Comment:

You can post a comment here. Keep it on-topic.

Name:

Blog id:

R3-0046


Comment:


 Note: HTML tags allowed for: b i u li ol ul font span div a p br pre tt blockquote
 
 

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

REBOL 3.0
Updated 26-Apr-2024 - Edit - Copyright REBOL Technologies - REBOL.net