Archived messages from: gitter.im/red/help from year: 2019

AiguyGary_twitter
01:20@nedzadarek Worked great. All I had to do was add the word wrap to what I already had!
nedzadarek
09:59If I have an image (e.g. i: make image! 20x20) when I get a pixel (e.g. i/(2x2)) is it going to always return colour in the ... format?
:+1: @AiguyGary_twitter
GiuseppeChillemi
11:02@nedzadarek

> @GiuseppeChillemi about links:
> How about using the fact that 2 words can point to the same block:

I will investigate on it.
lepinekong_twitter
13:02set in system/words doesn't seem to work in Context:

Context [
    set in system/words 'create function [
        'keyword
        func-body
    ][

        keyword: to-word form keyword
        ?? keyword ; test OK -> hello-test
        ?? func-body ; test OK -> [print "hello test"]

        set in system/words keyword does func-body
        test: get in system/words keyword
        ?? test ; test OK -> test: func [][print "hello test"]
        test ; test OK -> "hello test"
        system/words/test ; test KO ; -> Script Error: system/words/test has no value
    ]

    ; load from config
    extern>config: [hello-test: [print "hello test"]]
    foreach [keyword func-body] (extern>config) [
        ?? keyword
        ?? func-body
        create (keyword) func-body 
    ]     
]

JLCyclo
13:04@9214
13:07 group/paren: not perfect about nested/deeper structures.. I modify my tool to use preprocessor/fetch-next and to analyse nested/deeper structures
13:09My goal : to analyse a red script to insert specific functions to interrupt/continue the script without disturbing the original well-formed script
13:15Some ideas to halt/interrupt/continue at each "code instruction": 1- to analyse the script and to insert specific call function at every "code instruction"/"possible breakpoint"
13:16where are the "possible breakpoints": 1 - before a set-word
13:172- case word, after preprocessor/fetch-next
13:22question - how to find nested body/code (block! type ?) after the overall analyse of preprocessor/fetch-next ?
9214
13:33You should rather ask yourself how you gonna find "code instructions" in a language where code and data are indistinguishable.
JLCyclo
13:43About preprocessor/fetch-next : if the 1rst element is a word!, preprocessor/fetch-next goes to the end of the whole "code instruction" relative to this word (it analyses the whole call including the parameters)
13:45I think to insert enable breakpoints: - before set-word and after preprocessor/fetch-next
13:46of word!
13:48for nested bodies ? maybe to analyse blocks to see if they contain a set-word!
toomasv
15:01@lepinekong_twitter If it doesn't work, then how do you reach this error: system/words/test ; test KO ; -> Script Error: system/words/test has no value?
It works but is not needed in your case. set 'create ... and set keyword ... would work as well.

You get this error, because you try to access test in system/words but you never set it there. You define create as function, which by default keeps all set-words local. set 'test ... would work.
greggirwin
17:01@nedzadarek, yes, you should always get a 4 segment tuple as an image's pixel.
17:05@JLCyclo, how long have you used Red? If you're relatively new to it, I suggest you spend more time just using it, as that will lead to more understanding of the design and how things work. That will, in turn, make it easier to think about your own tool's design and implementation.
nedzadarek
17:28Should the Red recycle unused image! values? It doesn't seems to recycle it on the stable and 26-Dec-2018 version.
@greggirwin thank you.
17:53ps. and on the Red 0.6.4 for Windows built 1-Jan-2019/15:22:21+01:00 commit #8bf2cbe
9214
18:12@nedzadarek how did you determine that?
18:13It was noted that bitmap objects allocated by OS for image! values are currently not freed by GC, which results in a memory leak. I don't know if it's still the case.
bferris413
20:59General question: Am I able to add new fields to an existing object at runtime, without makeing a new object?
21:00Specific implementation: I'm trying to add on-key actors to a bunch of controls
21:00after the controls have already been defined
21:00or bound, or whichever the correct word is
21:05The best I have is
21:06
foreach control reduce controls [
    either control/actors = none [
        control/actors: object [ on-key: … ]
    ] [
       control/actors: make control/actors [ on-key: … ]
    ]
]

21:11I've experimented with things like put and bind, and also explored red by example and the official docs. Since it's not mentioned, I'm generally assuming you have to extend the object
greggirwin
22:20@bferris413, you can't extend objects in place currently. The extend func *may* allow it in the future, but that's not guaranteed to happen.
rebolek
22:28@bferris413 Widgets are derived from face object, that has all actors, so you don't need to extend it to add on-key, it's already there.
nedzadarek
23:19@9214 I have been creating images (e.g. 1000x1000) in the repl and I had the Task manager opened.
Thank you for the info.

dockimbel
05:28@bferris413 What is your use-case for that? Why don't you include on-key field in actors at their creation?
GiuseppeChillemi
10:08Blocks created inside an object could not be referenced from source code lines before their definition, otherwise you get an error. Do you confirm this is correct ?
lepinekong_twitter
13:55@toomasv that's the problem and my question: it works when I test with get in system/words, it doesn't work when I test with system/words/test
13:56@toomasv so when I get out of context system/words/test doesn't work of course. The way I circumvent the problem was to concatenate system/words with keyword and apply do but that's not very elegant.
toomasv
14:21@lepinekong_twitter Sorry, I don't get what problem you have there. You have several ways to make your example code work without error:
1) change function on line 2 to func
2) change test: get in system/words keyword on line 12 to set 'test get in system/words keyword (or set 'test get keyword)
3) Not to try to evaluate test in context where you never set it.
endo64
14:57@GiuseppeChillemi Can you give an example? if your object created already how your block is not there?
toomasv
15:39@GiuseppeChillemi If you do this in the following way,
>> ob: object [a: none] s: ob/a
== none
>> ob/a: copy [some words]
== [some words]
>> s
== none

then, yes, as s is not bount to series, but immediate! value, it doesn't "know" about changes in ob/a.

But if you define ob/a with empty series, then you can reference it before filling its value, and get the value later:
>> ob: object [a: copy []] s: ob/a
== []
>> append ob/a [some words]
== [some words]
>> s
== [some words]

I hope I understood your problem correctly.
nedzadarek
15:52@toomasv :+1: for empty series
Another way is to use lit-path!(which is translated to a path! to be precise):
obj: object [a: none] s: 'obj/a
reduce s
; == none
obj/a: 42 reduce s
; == 42

ps. I haven't followed the discussion.
toomasv
15:57Or get s.
endo64
16:14That means it is not a block yet ;)
toomasv
16:24:smile:
JLCyclo
18:51@greggirwin I use Red/Rebol as a hobby to make some scripts when I need it (not often). I am a software developper and I like the concept of Red/Rebol. Many languages have tools to debug with breakpoints (for example pydb for python). Some years ago, I used anamonitor, a rebol/view script to explore/debud words in a script. I think that a simple debug tool can help beginners to encourage to make red coding.
rebolek
19:08@JLCyclo Anamonitor was nice, it should be easy to do something like that in Red. Breakpoints can be done in Red, but you have to forgot about line numbers, they have no meaning in Red.
JLCyclo
21:45I think: rdb tool functionalities:
21:471- analyse script to debug, so that it identifies possible breakpoint locations
21:492- simple command interface like pdb to execute debug of the script
rebolek
21:50@JLCyclo re 1) given Red's extremely dynamic nature, to analyze script it basically means to running it.
JLCyclo
21:57The difficulty is the 1 functionnality: the more it identifies breakpoints locations without disturbing the originate script the more it is (for this functionnality, I think to use preprocessor/fetch-next
rebolek
22:04@JLCyclo Take a look at this code: [print 1]. Where to put a breakpoint there in following example?
>> rules: ['print (prin "hello ") integer! (print "world!")]
== ['print (prin "hello ") integer! (print "world!")]
>> o: context [do: func [series][parse series rules]]
== make object! [
    do: func [series][parse series rules]
]
>> code: [print 1]
== [print 1]
>> do code
1
>> o/do code
hello world!
== true
greggirwin
22:23As with compilation, there may be a lot of Red code that could be handled, but not all. The design work is finding the limit. Start with the easiest thing you can do and make that work.
nedzadarek
23:27@rebolek
> you have to forgot about line numbers, they have no meaning in Red.

Without line numbers, error messages would be cryptic.
GiuseppeChillemi
23:52@endo64 @toomasv

obi: make object! [
	
	a: db/two
	
	db: [one two [xyz] theee]


]



*** Script Error: db has no value
*** Where: a
*** Stack: 
>>


Now, let's define A after DB


obi: make object! [
		
	db: [one two [xyz] theee]

	a: db/two
	
]


>>>


No Errors
greggirwin
23:56> Blocks created inside an object could not be referenced from source code lines before their definition, otherwise you get an error. Do you confirm this is correct ?

@GiuseppeChillemi that's correct.
GiuseppeChillemi
23:58@greggirwin Didn't expect this. It is the same behaviour I have found working on VID layouts.

nedzadarek
00:07@GiuseppeChillemi it's not only blocks:
>> obj: object [
[    a: b
[    b: 42
[    ]
*** Script Error: b has no value
greggirwin
03:43@GiuseppeChillemi I don't know how else you would expect it to work. Evaluation is done in a single pass; there are no forward references.
GiuseppeChillemi
06:54@greggirwin I expected "deferred" evaluation to a second pass or at runtime use
06:57Also, another question: Print seems to not return any value and give error when used as last function in a function.

c: function [some][print ["some"]]

d: c "a string"


some
*** Script Error: d: needs a value
*** Where: d
*** Stack: 
>>

endo64
07:23@GiuseppeChillemi That is correct, not all functions return values, print is one of them.
07:28This would work:

>> c: function [some][also some print ["some"]]
== func [some][also some print ["some"]]
>> c "x"
some
== "x"
>> d: c "x"
some
== "x"

07:31Additionally, the words of spec block bounds to newly created object hence it cannot get bs value from global context: (same as R2, but differs from R3. a would be none in R3)

>> b: 1
== 1
>> o: object [a: b b: 2]
*** Script Error: b has no value
laturk
08:09Hi friends, This is rebview 2 VID code:
'''
08:09Great code, right? I'll try again.
08:11'''
c-query: rejoin [
"INSERT INTO churches ("
(either ch/text != "" ["ch,"][""])
(either cty/text != "" ["cty,"][""])
(either st/text != "" ["st,"][""])
") VALUES ("
(either ch/text != "" ["'" ch/text "',"][""])
(either cty/text != "" ["'" cty/text "',"][""])
(either st/text != "" ["'" st/text "',"][""])
")"
]

print c-query
INSERT INTO churches (ch,cty,st,) VALUES (',',',)

Please note that ch/text, cty/text, and st/text are not returning their values. Why?

If I print them immediately below the rejoin block their value is printed:

print ch/text
print cty/text
print st/text

Metro Church
Kansas City
KS
'''
NjinN
08:12let me try
08:12 c-query: rejoin [
"INSERT INTO churches ("
(either ch/text != "" ["ch,"][""])
(either cty/text != "" ["cty,"][""])
(either st/text != "" ["st,"][""])
") VALUES ("
(either ch/text != "" ["'" ch/text "',"][""])
(either cty/text != "" ["'" cty/text "',"][""])
(either st/text != "" ["'" st/text "',"][""])
")"
]

print c-query
INSERT INTO churches (ch,cty,st,) VALUES (',',',)

Please note that ch/text, cty/text, and st/text are not returning their values. Why?

If I print them immediately below the rejoin block their value is printed:

print ch/text
print cty/text
print st/text

Metro Church
Kansas City
KS
laturk
08:13@NjinN Thanks!
NjinN
08:19(either ch/text != "" ["'" ch/text "',"][""]) just return "',"
laturk
08:23@NjinN Sorry, I copied wrong. It returns "','"
08:25It should return "'Metro Church,'"
NjinN
08:26Maybe you should try like this (either ch/text != "" [ rejoin ["'" ch/text "',"]][""])
laturk
08:38@NjinN That works! Many thanks!
08:54One more problem. Out of 37 fields, there are 2 that return as "object", even if the field is actually empty. What might be causing this?
NjinN
08:59Make sure you have initialized every text like that text: copy ""
laturk
09:26@NjinN That doesn't seem to help. Could something else be wrong?
09:35You mean
ch/text: copy ""
right?
NjinN
09:36@laturk Need to see the whole code
laturk
09:47It is over 400 lines of code, and some of the lines are very long. I'll have to post it tomorrow after getting some sleep. You've been very helpful. Thank you!
nedzadarek
10:19@GiuseppeChillemi
> Print seems to not return any value and give error when used as last function in a function.

You can use probe. This function prints (not the same as print) an argument and returns the argument. For example:
>> probe [1 + 2]
[1 + 2]
== [1 + 2]

You may want to reduce an argument:
>> probe reduce [1 + 2]
[3]
== [3]

As for print and other functions that "does not return a value":
print (and for example do with an empty block - do []) returns values... but they are just simply discarded by most functions. if seems to work (if print 2 [42]).

You can get/set that value by using /any refinement of get/set:
>> print get/any 'sadfad

>> print get 'sadfad
*** Script Error: sadfad has no value
10:23@laturk @NjinN view [a: field button [print a/text]] "clicks button" -> none. It is not an object.
NjinN
10:29@nedzadarek I don't underst what you mean. a is a face!, but what's the difference
nedzadarek
10:30@laturk are you sure you are returning a text field of that 2 fields? Can you output it using normal button, for example: view [f: field button "check f" [print f/text probe f/text]. What that objects looks like? Maybe they are error!s? Maybe you are creating some object with /text by a mistake?
10:30@NjinN I mean that a/text is not an object, not a.
10:31In normal cases it's either none or some text.
lepinekong_twitter
11:25@toomasv thanks will try again later.
AiguyGary_twitter
13:48I was a editing a large Red pogram that I've got syntax error in either a missing ] or maybe a a double " I get the message *** Syntax Error: missing #"]" at "]"
*** Where: do
*** Stack: load

I there an easy way to tell what line number the error occurred on?
nedzadarek
14:18@AiguyGary_twitter I think you are missing closing square bracket (]) near nested blocks, for example like this:
arr: [
   [
       b
       c
   ]
; missing ]
GaryMiller
14:27Yeah, I've got a lot of data as code in there and did a count of [ and then a count of ] and had two more ] than [ so I know it's some where. It would just be nice if Red could give you an approximate line number. Same problem as Lisp one unmatched parenthesis and can be difficult to figure out where. I've also seen some of those type errors when I've missed closing a quoted string.
nedzadarek
14:30@GaryMiller can't you "reflow" it using text editor?
Or can you divide your code into "loadable chunks" and try load it into repl?
dockimbel
14:43@GaryMiller Red's lexer needs some improvements for properly pinpointing such kind of syntax error. It is a non-trivial task to achieve. Here is [a function](https://gist.github.com/dockimbel/709247c676640d867f62ca8c4585e7ff) for doing so (to be used from the console) as a starting point. It does not account for strings and comments, such features are left as an exercice for whoever wants to play with it. ;-)
I am curious if it would have been helpful in your case...
laturk
18:07@NjinN @nedzadarek After a little sleep I found the problem in about 5 minutes. In 2 places I used a - when a _ was required.
meijeru
18:07Some source code editors show matching brackets. Mine, Crimson, does that but it has the same problem with strings and comments...
nedzadarek
20:28Neither notepad++ nor Atom can handle ". In the case of Atom, I might turned something off - I have not used it for a long time.
@laturk :+1:
JLCyclo
20:55@rebolek For my tests, I copy/paste your previous code. The tool finds 9 breakpoints (some of them will not be executed). Then, I define the specific breakpoint function with empty code, it seems that there is no major modification of the originate code.
20:56code:[Red brk 1 [
Title: "Debug script"
] brk 2
rules: ['print (prin "hello ") integer! (print "world!")] brk 3
o: context [brk 4 do: func [series] [parse series rules brk 5] brk 6] brk 7 code: [print 1]
do code brk 8
o/do code brk 9
]
20:58What is the tag to use to insert to display code with black background ?
9214
21:01@JLCyclo Ctrl + Shift + Alt + M.
JLCyclo
21:12@9214 thanks
21:12the new code with breakpoints
21:14`[Red brk 1 [
Title: "Debug script"
] brk 2
rules: ['print (prin "hello ") integer! (print "world!")] brk 3
o: context [brk 4 do: func [series] [parse series rules brk 5] brk 6] brk 7 code: [print 1]
do code brk 8
o/do code brk 9
]
9214
21:18And how is your debugger different from manually inserting probe at specific places?
dsunanda
21:46Is this a deliberate change in the nature of tags, or an oversight in replace ?
str: copy "aaa <tag> ccc"
replace str <tag> "bbb"
R2 and R3 == "aaa bbb ccc"
Red == "aaa <bbb> ccc"
`
gltewalt
22:13
>> replace str "<tag>" "bbb"
== "aaa bbb ccc"
endo64
22:15@dsunanda Nope, it is not on purpose.
See the source of replace function, when you follow with your parameters this part runs:
if pos: do compose [(do-find) series :pattern] [
                remove/part pos len
                insert pos value
            ]


here is the reason:

>> pos: do compose [find "aaa <tag> ccc" <tag>]
== "tag> ccc"
>> length? <tag>
== 3


So "tag" is removed (3 chars) and then "bbb" inserted there.
22:16We should raise a ticket for that, replace should form its pattern argument
22:17There is already a part for that in it:
if system/words/all [char? :pattern any-string? series] [
        pattern: form pattern
    ]

we should change it to: if system/words/all [any [char? :pattern tag? :pattern] any-string? series] ...
22:18Then it works as expected:
>>  replace "aaa <tag> ccc" <tag> "bbb"
== "aaa bbb ccc"
dsunanda
22:18@gltewalt - thanks - I know how to fix it if the tag is a string, but there's further complications if the replacement is in a variable:
tg: copy <tag> str: copy "aaa <tag> ccc" replace str tg "bbb"

This works differently in R2/R3 vs Red
22:20@endo64 Thanks for the analysis. For R2/R3 compatibility and (for me) sheer common sense, your fix makes it work the way I think it should :)
Can you raise the issue - as you also found the fix
endo64
22:21Sure, I will.
dsunanda
22:21Cool!
endo64
22:36#3703
AiguyGary_twitter
22:51@dockimbel
Thanks for the check-brackets function I ran it and got the following.

>> do check-brackets %/C/Red/ZandraGUI.red
Opening [ at line 126 not closed
>>

It correctly identified the switch statement that had the missing ]

Unfortunately the switch had 700 lines in it.

Luckily I had a pair of brackets in each line so I just had to hit end in NotePad++ go to the end of a line and down arrow until I found one missing.

I'll probably put that switch statement in a seperte script and include it just to keep my main file smaller.
nedzadarek
23:34@endo64 formed file would loose % so checking for tag! in your commit is a good solution.

ps. is it intended (in both the Red and the Rebol) that replace does not replace % when pattern is a file, for example replace "aa %a/n.red f" %a/n.red "*" ; == "aa %* f"?
23:35@AiguyGary_twitter
> Unfortunately the switch had 700 lines in it.

If you can manage 700 lines of code like this you are my "programming hero". 100 lines of code is a sign for me to re-factor it (into some functions/objects).
endo64
23:44@nedzadarek I think that's because >> form %file ;== "file", % is a notation it is not part of the file name itself.
Just like >> form #(a: 1 b: 2) == "a: 1^/b: 2", because #( and ) are not part of the value itself, they are just a notation of the literal syntax.

PaulBanks
00:32Hi, am new to Red, please help with some file handling.
;; I can read the contents of the working Red folder with this;
dr: read %.
print dr
;; And can read the contents of the folder that contains the Red exe with this:
dr: read %..
print dr
;; but how can I read the contents of sub- directories of the working Red folder ?
;; also I can do this: write %myfile.txt ;; but how do i do it if myfile.txt is contained
;; within a variable ;; i.e. write file or write %file where file holds the path to myfile.txt

thanks.
nedzadarek
00:35@PaulBanks f: %myfile.txt write f "something"
00:37for subdirectories something like this foreach file read %. [if dir? file [print file probe read file]]
PaulBanks
01:18thanks @nedzadarek but its not clear, sorry for being useless. if a file path is contained within a variable - how can i read or write it using the variable ?
bferris413
01:22accidentally removed mine
01:22read %dirname/
01:23to read a directory in the current directory ^
01:23file: %filename
01:23read file works fine, assuming filename is the name of a file in the current directory
PaulBanks
01:27yes thanks, but how can i read a sub-directory? not the current directory
bferris413
01:27replace dirname with a directory name in the current directory
01:28or continue the path downward
01:28read %directory/subdirectory/another-directory/
PaulBanks
01:29how can i continue the path downward - sorry for being so stupid
nedzadarek
01:29@PaulBanks let me give you examples. Let's say you want to add 2 and 3. You can use +: 2 + 3. Now, your 2 and 3 are in the words (not variables): a: 2 and b: 3. You can add the values that a and b points to: a + b.
So you want to write something: e.g. write %path/to/file.red "something". Using above knowledge you can substitute values for words: file: %path/to/file.red and use it: `write file "something".
bferris413
01:46On an unrelated note, should I be doing something differently with load and image!? The below code consumes 2x memory per image load, but doesn't release it on subsequent function calls
01:46noticed this in a basic CRUD app I'm working on
01:46
get-image: function [ /local pic /extern picture ][
    f: request-file

    unless f = none [
        pic: load f  ; never collected?
    ]
]

gui: [
    button "Get file" [ get-image ]
]
view/no-wait gui
PaulBanks
01:48@nedzadarek bit confused - just wanted to know how to read, write, from within variables,the file path is contained within a variable - so how to write the contents of the variable to disk.... but thanks for your help
nedzadarek
01:50@PaulBanks it's the same knowledge: write %path/to/file.txt YOUR-VARIABLE, where `YOUR-VARIABLE: "content of the variable".
dockimbel
04:32@bferris413 You need to remove all references to your image, though the image bitmap allocated from the OS is not yet garbage-collected (it's on our todo-list). Some comments about your code:
* /local pic is not needed there as you are using the auto-collecting function constructor, and you have a set-word instance of pic, so it will be properly collected and auto-declared as local (you can do a probe :get-image in the console to check that).
* unless f = none can be reduced to just if f, as any value that is not false or none is treated as a truthy value in Redbol.
laturk
05:42This is a question about the "choice" VID drop-down menu style for Rebol 2. When the fields are cleared, whatever menu item was chosen is erased from the menu. How can this be prevented from happening?
dockimbel
07:50@AiguyGary_twitter Thanks for the feedback.
xqlab
08:16@toomasv By the way using a call to firefox with every url with "tree" within and a wait afterwards gives me all datetimes of the wanted github pages. Of course this is not a practical way. It just shows that my assumptions about cacheing the github pages are true
toomasv
09:12@xqlab :+1:
PaulBanks
14:54@nedzadarek @bferris413 Yes got it now - thanks for your help
bferris413
18:25@dockimbel ok, thanks for the tips, I'll follow them up this evening
JLCyclo
18:33The goal of this tool debug is to be analoguous with pdb. You do not have to modify manually a script for debugging.You specify a Red script to debug as input parameter. And then it prompts for commands. In fact, it generates an intermediary script with insertion of specific call for breakpoints. The user will see its script with lines number corresponding with possible breakpoints to enable/disable. The list of commands at prompt includes red command.



greggirwin
20:40@PaulBanks, to add to the file chat, you can store the path part, then use either a literal or dynamic path syntax to reference a file. e.g.
>> print mold new-line/all read %. on
[
    %proj/ 
    %Red/ 
    %sw-dev/ 
    %temp/
]
; Read a literal dir
>> read %temp/
== [%red-code/ %test1 %test2 %TEST3 %UES/]
; Use a word to ref the dir
>> dir: %temp/
== %temp/
; Read using the variable dir, and a literal filename
>> read dir/test1
== "1"
; Use a word to ref the file
>> file: %test1
== %test1
; Use get-word syntax in the path to use the file variable
>> read dir/:file
== "1"
bferris413
23:56@rebolek @greggirwin @dockimbel Thank you for your assistance a few days ago regarding adding on-key to preexisting objects. haven't been able to get back to it until now. The only use-case was generally to save typing, as there's nothing really stopping me from giving it a handler on creation.
23:57Just need to get more comfortable working with data before its evaluated as a 'face object I think

lepinekong_twitter
11:39@toomasv I forget to show the instruction that calls create:

Context [
    set in system/words 'create function [
        'keyword
        func-body
    ][

        keyword: to-word form keyword
        ?? keyword ; test OK -> hello-test
        ?? func-body ; test OK -> [print "hello test"]

        set in system/words keyword does func-body
        test: get in system/words keyword
        ?? test ; test OK -> test: func [][print "hello test"]
        test ; test OK -> "hello test"
        system/words/test ; test KO ; -> Script Error: system/words/test has no value
    ]

    ; load from config
    extern>config: [hello-test: [print "hello test"]]
    foreach [keyword func-body] (extern>config) [
        ?? keyword
        ?? func-body
        create (keyword) func-body 
    ]     
]

create test [print "hello test"]
test

*** Script Error: system/words/test has no value
*** Where: create
*** Stack: Context create

11:41@toomasv what I want to do is pass any keyword (test or any other) to create from the console while definining it in a context module.
11:42@toomasv I still suspect there is a red bug here.
11:45So instead I have to do this which I shouldn't have to do:
;instead of
                ;set in system/words keyword does func-body
                ;i have to do this:
                command: rejoin ["system/words/" keyword ": " mold/only (does func-body)]
                do command
OneArb
13:17How would I go about parsing patterns such as
"**" "*" "+-" "+" "++"
I am trying to avoid for "+" to be a match when "++" is present
meijeru
13:24Always put the longest match first.
toomasv
13:26@lepinekong_twitter Bear with me, I am slow-minded :flushed:. Please explain further what you want to achieve. I started from stripped-down version of your code:
context [
    set 'create function ['keyword func-body][
        set to-word keyword does func-body
    ]
    foreach [keyword func-body] [
        test1 [print "Hi test1!"] 
        test2 [probe skip tail body-of system/words -4]
    ][
        create :keyword func-body 
    ]
]

From here on:
create test [print "hello test"]
test
;hello test
test1
;Hi test1!
test2
[test1: func [][print "Hi test1!"] test2: func [][probe skip tail body-of system/words -4]]

But I don't quite understand why you have to do foreach inside context, or why do you need context at all. OK, let's say you want to easily create a bunch of simple funcs and encapsulate this in object:
ctx: context [
    set 'create function ['keyword func-body][
        set to-word keyword does func-body
    ]
    make-funcs: func [specs][
        foreach [keyword func-body] specs [
            create :keyword func-body 
        ]
    ]
]
ctx/make-funcs [test1 [print "Hi test1!"] test2 [probe skip tail body-of system/words -4]]
test1
;Hi test1!
test2
;[test1: func [][print "Hi test1!"] test2: func [][probe skip tail body-of system/words -4]]

Still, there is no reason why create should be created from inside context. IMO, there is sense to create functions inside context if you want to keep them local to context or if they use some words/values from the context.
AiguyGary_twitter
20:19I was try to translate the following Python function to calculate the Levenshtein distance to Red (Python as comments on the bottom) the message I got is a bit cryptic though.

print LD "dog" "log"
*** Script Error: LD has no value
*** Where: print
*** Stack:

Red[]

[

LD: function [s [string!] t [string!] ]
[
if s = t [return 0] ; String identical so zero distance between them
if length? s = 0 [return (length? t)]
if length? t = 0 [return (length? s)]

repeat i length? t + 1 [ poke v0 i = None ]
repeat i length? t + 1 [ poke v1 i = None ]

repeat i length? v0 [ poke v0 i = i]

repeat i length? s
[
poke v1 1 copy I + 1
repeat j length? t
[
either peek s i = peek t j [cost: 0] [cost: 1]
m1 = min (peek v1 (j + 1)) peek v0 (j + 1)
poke v1 (j + 1) copy min m1 (peek v0 j + cost)
]
repeat j length(v0) [poke v0 j copy (peek v1 j)]

]

return peek v1 length? t

]


print LD "dog" "log"

]

;def LD(s, t):
; if s == t: return 0
; elif len(s) == 0: return len(t)
; elif len(t) == 0: return len(s)
; v0 = [None] * (len(t) + 1)
; v1 = [None] * (len(t) + 1)
; for i in range(len(v0)):
; v0[i] = i
; for i in range(len(s)):
; v1[0] = i + 1
; for j in range(len(t)):
; cost = 0 if s[i] == t[j] else 1
; v1[j + 1] = min(v1[j] + 1, v0[j + 1] + 1, v0[j] + cost)
; for j in range(len(v0)):
; v0[j] = v1[j]
;
; return v1[len(t)]



bferris413
20:28
LD: function [s [string!] t [string!] ][
    if s = t [return 0] ; String identical so zero distance between them
    if length? s = 0 [return (length? t)]
    if length? t = 0 [return (length? s)]

    repeat i length? t + 1 [ poke v0 i = None ]
    repeat i length? t + 1 [ poke v1 i = None ]
    repeat i length? v0 [ poke v0 i = i]

    repeat i length? s [
        poke v1 1 copy I + 1
        repeat j length? t [
            either peek s i = peek t j [cost: 0] [cost: 1]
            m1 = min (peek v1 (j + 1)) peek v0 (j + 1)
            poke v1 (j + 1) copy min m1 (peek v0 j + cost)
        ]
        repeat j length(v0) [poke v0 j copy (peek v1 j)]
    ]

    return peek v1 length? t
]

20:29the above runs, albeit with runtime errors. You could probably start debugging it now
9214
20:29@AiguyGary_twitter have you considered:
* to format your code according to style guide and wrap it in code fences (like @bferris413 did), so that others can read it and help you without peeling their eyes off?
* to put function definition out of a block, or to precede block with do?
* to define non-existent v0 and v1 vectors?
20:57Well, there are much more mistakes here (too many to count) on top of that. I'd suggest to learn [the basics](http://www.rebol.com/docs/core23/rebolcore.html) first.
olivier_lp_twitter
22:19Lengh (V0) should be replaced by lengh? V0 to start

toomasv
08:29@bferris413 @AiguyGary_twitter Rewrite:
LD: function [s [any-string!] t [any-string!]][
    s: mold s
    t: mold t
    case [
        s = t [return 0]
        0 = length? s [return (length? t)]
        0 = length? t [return (length? s)]
    ]
    v0: append/dup make block! 1 + length? t none 1 + length? t
    v1: copy v0
    repeat i length? v0 [v0/:i: i - 1]
    repeat i length? s [
        v1/1: i ;+ 1
        repeat j length? t [
            cost: pick [0 1] s/:i = t/:j
            v1/(j + 1): min min v1/:j + 1 v0/(j + 1) + 1 v0/:j + cost
        ]
        repeat j length? v0 [v0/:j: v1/:j]
    ]
    v1/(1 + length? t)
]
LD "dog" "log"  
== 1
LD <dog> @log  
== 3
dockimbel
09:23 0 = length? s => empty? s
toomasv
10:42Ah, of course! :flushed:
dockimbel
nedzadarek
11:15@toomasv 0 = length? s is not bad, especially in cases where you want check lengths, for example:
s: "ab"
case [
    0 = length? s [print 'zero]
    1 = length? s [print 'one]
    2 = length? s [print 'two]
]
; two

9214
11:160 = length? s is a code smell, so as code duplication in multiple case branches.
>> pick [zero one two] add length? "ab" 1
== two
toomasv
12:03Hmm, actually there is no reason why the LD func should have any type restrictions. Why not e.g.
LD [dog: 1] [dog 1]
== 1
;or
LD #(dog: 1) #(dog 1)
== 0
9214
12:10@toomasv what can be useful is returing a set of all insertions, deletions and substitutions, which you can apply to source and derive the target. Levenshtein distance then is just a length of this set.
toomasv
13:11Something to do with Hirschberg algorithm?
9214
13:19Not really.
>> source: [dog: 1]
== [dog: 1]
>> target: [dog 1]
== [dog 1]
>> length? [(change source to word! source/1)]
== 1 ; Levenshtein distance
>> do [(change source to word! source/1)]
== [1]
>> source = target
== true
nedzadarek
13:54@9214 It depends what are you doing and what you want to achieve. You want one-liner (your code) or something more readable (my code).
ps. code duplication - I do not want to introduce more complex example. I have just made it "runnable".
9214
14:01If you say so.
nedzadarek
14:03Yes.
toomasv
14:13@9214 First step:
lev: function [s t /block][
	unless block [
		unless string? s [s: mold s]
		unless string? t [t: mold t]
	]
    case [
        s == t [return 0]
        empty? s [return (length? t)]
        empty? t [return (length? s)]
    ]
    v0: append/dup make block! 1 + length? t none 1 + length? t
    v1: copy v0
    repeat i length? v0 [v0/:i: i - 1]
    repeat i length? s [
        v1/1: i
        repeat j length? t [
            cost: pick [0 1] s/:i == t/:j
            v1/(j + 1): min min v1/:j + 1 v0/(j + 1) + 1 v0/:j + cost
        ]
        repeat j length? v0 [v0/:j: v1/:j]
    ]
    v1/(1 + length? t)
]
lev/block [dog: 1] [dog 1]  
== 1

But it does not go deep into sub-blocks.
lepinekong_twitter
17:19@toomasv thanks will look at it :) https://pbs.twimg.com/media/DtL4RYnWoAEqqX5.jpg
17:20if you want a drink :) https://www.wearerebol.com/
17:24Can I talk to Alexa in Red instead of Rebol 3 ;) https://www.youtube.com/watch?v=QZQlMmlR5l8
GiuseppeChillemi
22:37@9214

>> The reason is that you use function without understanding how it works. function gather all set-word!s inside body as locals, and your usage of level: prompted it to collect that word. Formal parameters of refinements (/local is a refinement too) are set to none by default.

I supposed "function" makes local only set-word!s of words which weren't first used in main code. Is there a way to obtain this ?
22:38Also,is there a way to avoid LEVEL being set to none in my code ?
9214
22:41Either don't use function or specify /extern level in function's spec. Or rely on set instead of using set-word!.
GiuseppeChillemi
22:47@9214 Thanks, now I have some more knowledge
23:44I am trying to access a path using a word containing it but I get an error one I add elements to the path.

DB: [
	CURRENT-SERVERNAME [DATABASES [CURRENT-DBNAME [RAN ["HERE!"]]]]
]

internal-path: to-path "DB"
probe reduce internal-path
internal-path: to-path "DB/CURRENT-SERVERNAME"
probe reduce internal-path


output


[
    CURRENT-SERVERNAME [DATABASES [CURRENT-DBNAME [RAN ["HERE!"]]]]
]
*** Script Error: path must start with a word: DB/CURRENT-SERVERNAME
*** Where: reduce
*** Stack: probe


23:45Also, is there a way to access the path stored in "internal-path" without "reduce" ?

9214
00:00
text
>> get load "db/current-servername"
== [DATABASES [CURRENT-DBNAME [RAN ["HERE!"]]]]


Don't use to path!, as its a loosely defined type-casting. In your case it creates a path where path itself is the only element.
>> first to path! "ab/cd"
== ab/cd
>> last to path! "ab/cd"
== ab/cd

That is, elements are not flattened.
>> first 'ab/cd
== ab
>> last 'ab/cd
== cd
nedzadarek
00:08@GiuseppeChillemi
> I supposed "function" makes local only set-word!s of words which weren't first used in main code.

I have used a:
>> a: 1
== 1
>> f: function [] [a: 2]
== func [/local a][a: 2]
>> f
== 2
>> a
== 1

> Is there a way to obtain this ?

You want to get all local words? You should just find /local in the spec-of a function:
>> f: function [a ] [b: a * 10]
== func [a /local b][b: a * 10]
>> spec-of :f
== [a /local b]
>> find (spec-of :f) /local
== [/local b]
>> find/tail (spec-of :f) /local
== [b]
dockimbel
02:37@GiuseppeChillemi Why are you constructing paths from strings in your code examples?
lepinekong_twitter
05:19@dockimbel Red 0.6.4 is crashing with
do https://readable.red
whereas it works with Red 0.6.3
05:22which points to do https://readable.red/index.red
05:26I'll have a lot of work to debug and refactor it for 0.6.4. And I have other systems broken also.
GiuseppeChillemi
06:40@dockimbel I am creating a structure to maintain databases and access them via ODBC URI like strings. While the developer will be able to access them in a server:db/table format, they are internally stored as BLOCKS built with the following storage structure block-name/servers/server-name/tables/table-name. The path to access the storage block will be translated to the short URI form, available to the coder, to the long internal rappresentation to access each part of the storage. So, the needing to build the access path from a string composing it from building blocks and URI parts mapped to block path access parts.
dockimbel
06:49@GiuseppeChillemi Thanks. I'm still not sure to get why you use strings instead of path values directly.
07:22@lepinekong_twitter Have you tried with a recycle/off at the beginning of your code? New crashes in 0.6.4 are often related to the GC, so this check is the first thing to do on crashes (and the second thing is to properly report them on our issue tracker so we can fix them).
GiuseppeChillemi
08:37@dockimbel ODBC URI paths coming from outside are strings so I feel more "safe" manipulating them and converting the result to paths. Also I have never manipulated paths stored in blocks and single chars inside paths and directly joining, composing them. As this usage pattern seems to me not so common too, my fear is that something could be still not implemented. This is the reasong I am currently working with strings. Feel free to show me I am wrong !
08:50*reasong sounds good to me, I like this typo !
nedzadarek
16:29About view: can we create/detect/send our own events?
It seems that we can append events' names into system/view/evt-names - append system/view/evt-names [foo on-foo]. Then we can capture an event like view base on-foo [print "do something with foo event"].
How do we create an actual event and pass it? I have tried faking it but it doesn't work:
view [
    b: base on-up [face event] [
    face/actors/on-foo face #(type: 'foo offset: 42x42 baz: 'bar)] 
    on-foo [face event] [print "******" print 'foo-foo print event/baz] ]

event in the on-foo is not my map.
So, is this possible? Or will it be possible in the future?
meijeru
16:32@nedzadarek I don't understand - events are triggered by user (or system) actions _outside_ the program. How could you create these from _within_ the program?
nedzadarek
16:44@meijeru I'm confused because every action is from the outside: clicks, mouse movement, key presses.
GiuseppeChillemi
18:08@9214 what does " loosely defined type-casting" mean ? Do you have any link for me ?
9214
18:13Why should I have any link for you? It simply means that conversion from string to path does the least expected thing, and will likely change in the future.
GiuseppeChillemi
18:17@9214 didn't know what "losely defined" term was, so " loosely defined type-casting" sounded me like soething I could learn ...
18:17Thanks
18:29@9214
>
text
> >> get load "db/current-servername"
> == [DATABASES [CURRENT-DBNAME [RAN ["HERE!"]]]]
>


Once laoded, is there a way to know if the current block is an element of a bigger one and access the previous level ?
greggirwin
18:30@GiuseppeChillemi coercing values between types is something you need to experiment with, to understand how each one works. Some are easy, but when you get into words, paths, binding issues, etc. it can be quite tricky.
9214
18:31@GiuseppeChillemi no, at least not from user-space.
greggirwin
18:31> Once laoded, is there a way to know if the current block is an element of a bigger one and access the previous level ?

You need to write that kind of logic yourself.
GiuseppeChillemi
18:33You can navigate to the inner side but not to the outher site, this not sound good as it does not sound good in life !
18:36@greggirwin
> @GiuseppeChillemi coercing values between types is something you need to experiment with, to understand how each one works. Some are easy, but when you get into words, paths, binding issues, etc. it can be quite tricky.

Yes, I know. In the following situation I expected to have "a" string as return value, instead I get a char... it's quite confusing sometime.

>> probe type? first "a string!"
char!
== char!
>>

9214
18:37This has nothing to do with type coercion. string! is simply a series of char! values. You ask for the first element - you get the first character.
GiuseppeChillemi
18:39@9214
> @GiuseppeChillemi no, at least not from user-space.

It would be nice to navigate to the upper path level in when you are exploring a structure a block or when something needs to know where it come from.
18:40@9214
> This has nothing to do with type coercion. string! is simply a series of char! values. You ask for the first element - you get the first character.

I know but I was answering to the concept "things must be tried to understand how they works" because they may be complex and different than expected.
18:45@9214
> This has nothing to do with type coercion. string! is simply a series of char! values. You ask for the first element - you get the first character.

I have understood but it sound more "natural" having back a string like you have from:

>> probe type? copy/part "a string!" 1
string!
== string!


To me the first element of a string is string of one character, I do not expect a different type. However, as said, I have to learn how things works in RED.
greggirwin
18:45> It would be nice to navigate to the upper path level in when you are exploring a structure a block or when something needs to know where it come from.

So store the path and use that. Unless, as 9214 alludes to, you want to hack into the path evaluation on the stack, in the guts of Red (not a good idea IMO).
GiuseppeChillemi
18:47@greggirwin I am going this way but in the future, when I will be able to extend RED/System functionality I'll work on it !
9214
18:54@greggirwin I had a similar idea in mind recently, but in my mind it would require an extension of cell size and making node! a two-way table - essentialy a double-linked list between parent and children series. This raises design and security concerns, I think. Like, what if I don't want to reveal from where block comes? What if user will get down to the root node and crash the system?
GiuseppeChillemi
19:34@9214 protected paths should be implemented to avoid this.
19:34I mean, one way nodes should coexist with two way ones.
9214
19:35But we already have "one way nodes". Perhaps what should be implemented (by you) is a double linked list.
GiuseppeChillemi
20:28@9214 When I will have the skill to implement two way nodes, I'll do this together with help of your team. See you in a couple of years !
GaryMiller
20:36If you have a large number of instances of a class with the same class member names and the same standard function name in every instance (but different code in each instance's function) is there a way to iterate through the instances? Or do I need to wait until arrays are added and then iterate through the array of instances?
toomasv
21:04@GaryMiller Something like this?
obs: copy [] 
loop 10 [append obs object [
    pr: does reduce ['print rejoin ["I am " random "ABCDEFGHIJKLMNOP"]]
]]
>> forall obs [obs/1/pr]
I am LOPIMNKBFCHGAEJD
I am MNIPDEKJAGLBCFHO
I am CJFMENGPADLBHIOK
I am EINGCKOLPHBFDAMJ
I am JNAOPDLCEFGMBIHK
I am DAGCLHMOPIJFBENK
I am LKENCJGODFMIPAHB
I am BJFMGDLOPNIAHECK
I am HFBDELPKAONIGCJM
I am KMPNHIBFLCDEOAGJ
nedzadarek
21:06@9214 "a two-way table" - but then you would have to store many parents. For example, let's suppose that a function parent return parent. With this blocks:
a: [1 2 3]
one: reduce [a 'one]
two: reduce [a 'two]

and when I call parent a, should it returns one, two or both?

> Like, what if I don't want to reveal from where block comes? What if user will get down to the root node and crash the system?

Correct me if I'm wrong, but an user can do this already. Unless you mean an Operating System (like MS Windows).
endo64
21:11@GaryMiller Just a reminder, in Red & Rebol, there is no classes. It's all prototype based, so there are objects and functions in it (contexts and words referring to functions).
meijeru
21:26@nedzadarek Precisely, "every action is from the outside: clicks, mouse movement, key presses" and therefore, it makes no sense to create new event types from within the program. If you need an action on a certain -- internal -- condition, you can detect that condition in your program (it is not an event in that case) and do the action from within the program. If you need an action on an other -- external -- condition, that can only be detected through the outside clicks etc. which are already defined. If you want another external condition to be detectable, you need to formulate a wish for an extension to Red. By the way, throw and catch are also useful for detecting conditions and and reacting on them.
nedzadarek
21:44@meijeru
> If you need an action on an other -- external -- condition, that can only be detected through the outside clicks etc. which are already defined.

But maybe you want to refine or group some pre-defined events?

> If you need an action on a certain -- internal -- condition, you can detect that condition in your program (it is not an event in that case) and do the action from within the program.

Now that I thought about it, you could detect some changes in something and update a face. Though react would probably work like that.

gltewalt
01:00Can someone remind me how to use context? again?
nedzadarek
01:15@gltewalt
v: 42
context? 'v
; main or global context:
== make object! [
    datatype!: datatype!
    unset!: unset!
    none!: none!
    logic!: logic!
    bl...
v2: bind 'b context [b: 42 c: 44]
; == b
; context of the word "b" stored in the v2:
context? v2 
; == make object! [
;     b: 42
;     c: 44
; ]
GiuseppeChillemi
07:41ehm... and what is the global contex ?
rebolek
07:42system/words
GiuseppeChillemi
07:43Are there different contexts ?
rebolek
07:43of course, you can create new context easily
GiuseppeChillemi
07:44and in each context I define... words ?
07:44And that is the needing for it ?
rebolek
07:44context is collection of words and their values
GiuseppeChillemi
07:44*what is the needing for having a separate context ?
rebolek
07:45
>> context-1: context [a: 1]
== make object! [
    a: 1
]
>> context-2: context [a: 2]
== make object! [
    a: 2
]
GiuseppeChillemi
07:45I see a "make object!" statement...
07:45So a context is an object with words and their values
07:46And, are all context objects ?
rebolek
07:46> *what is the needing for having a separate context ?

What is return? In one context it's a function that returns value from function. In different context it's a keyword that ends row or column of widgets in GUI.
GiuseppeChillemi
07:47Are words not defined in the local context searched in the global one, aren't they ?
rebolek
GiuseppeChillemi
07:57And what is the purpose of bind ?
rebolek
07:58If you want to change word's context (or assign an context to a word that has none), then you use bind.
GiuseppeChillemi
07:58When a word has no context ?
rebolek
07:59Look at this code print a. What is a's context there?
NjinN
07:59global
rebolek
08:00
>> do [print a]
*** Script Error: a has no value
*** Where: print
*** Stack:
08:00@NjinN right, global, but it has no value in global context.
08:00But with bind I can do
>> do bind [print a] context-1
1
NjinN
08:00I found do awalys use the global context, is it right?
rebolek
08:01Unless you rebind the block just like in the example above
NjinN
08:02I need help, how to set the buffer-size of a port?
rebolek
08:03@NjinN what port?
NjinN
GiuseppeChillemi
08:04@rebolek
So in that context it has meaning
NjinN
08:04my-port/buffer-size doesn't work
rebolek
08:05@GiuseppeChillemi right
GiuseppeChillemi
08:05@rebolek but you have bound a whole block, not a word. It seems you do not bind only words.
rebolek
08:07@NjinN what branch are you using?
NjinN
08:07@rebolek Sorry, I'm asking things about rebol2
rebolek
08:08@NjinN Oh, now it makes sense :)
08:08As there's no TCP in Red yet.
dockimbel
08:16@GiuseppeChillemi
> So a context is an object with words and their values

No, the other way around, an object is a context.
08:19@GiuseppeChillemi
> @rebolek but you have bound a whole block, not a word. It seems you do not bind only words.

Only words have a context. bind allows you to bind to a context a single word or many words at the same time using a block (all non-word values are ignored then).
9214
08:19Rather, object! *provides* a context, so as function!. You can bind only any-word! values.
dockimbel
08:22Objects are very thin wrappers over the internal context! type. In Rebol, objects are just a first-class version of contexts. In Red, they can also include object event handlers.
08:25@GiuseppeChillemi You cling too much on irrevelant knowledge from other languages. You need to jump into the water if you want to learn to swim. First rule of Red's Fight Club: forget everything you think you know about programming languages (this does not apply if you are also part of a Lisp's Fight Club). ;-)
9214
08:26@nedzadarek perhaps you should learn a bit about internals of Red before commenting.
hiiamboris
09:35May I use the debugger too, for a change? ☺
https://gitlab.com/snippets/1795878 this script gives me quite a headache. I expect it to trigger a reaction and can't understand why it does not.
09:37(sure I tried to minimize it but it starts working when I do...)
nedzadarek
10:51@9214
> @nedzadarek perhaps you should learn a bit about internals of Red before commenting.

Commenting on what?
9214
10:58On topics of which you know very little and don't have anything worthwhile to say.
nedzadarek
11:00@9214 well... could you at least point to message I have sent? Or do I have to learn **whole** red internals before I can comment on anything here?
olivier_lp_twitter
14:16Hi, on a field test (or drop-down) is it possible to know where the cursor is (begiining, end or in the middlle of the test)?
gltewalt
17:54https://github.com/red/red/wiki/%5BNOTES%5D-Community-Communication-Values
GiuseppeChillemi
19:22@dockimbel
> @GiuseppeChillemi You cling too much on irrevelant knowledge from other languages. You need to jump into the water if you want to learn to swim. First rule of Red's Fight Club: forget everything you think you know about programming languages (this does not apply if you are also part of a Lisp's Fight Club). ;-)

Yes, you are right. I am deep using "prior knowledge". This happens because they are the fundamentals of my learnings and my mind use them to explain what I new it encounters.
Here I have to throw away really everything with no disrupting resources available to break the old and build the new one.
19:25@dockimbel @9214 is there any deep text, together with diagrams, on contexts topic ? How they work, why they have been created and their purpose ?
19:30@nedzadarek
> @9214 well... could you at least point to message I have sent? Or do I have to learn **whole** red internals before I can comment on anything here?

I think he may refer to this: https://gitter.im/red/help?at=5c33f9b28b6399655e23dcc3

I suppose his fear is to put users on the wrong path. I can understand this.
19:31And about the *whole* RED internals.. I would like it !
dander
20:08 @GiuseppeChillemi Maybe you would find [this spec section](https://github.com/meijeru/red.specs-public/blob/master/specs.adoc#words-contexts-and-binding-1) helpful. I also bookmarked [this conversation](https://gitter.im/red/help?at=58c91845dd08b4b859d361a6), when it turned on a light bulb for me.
nedzadarek
21:18@GiuseppeChillemi right, I have made a mistake.

> Here I have to throw away really everything with no disrupting resources available to break the old and build the new one.

You don't have to throw everything but, as fair I remember, there are not many X vs Red posts.
metaperl
21:24if myBirthday: 30/07/1963 then what is the difference between: partyDay: myBirthday and partyDay: :myBirthDay ?
dsunanda
21:26The two are the same.....You can test for sameness with same?
var: 99
same? var :var
== true
`
metaperl
21:28what is the difference between do %myprogram.txt and do load %myprogram.txt?
21:30Is it the case that everything that is not false , off or no is considered true?
nedzadarek
21:32@metaperl
Error (the Red tries to call f):
f: func [a] [a]
g: f

Good:
f: func [a] [a]
g: :f
dsunanda
21:33Not really - integers for example are neither true or false. Generally, only a logic value is true or false
true = 1
== false
false = 1
== false
metaperl
21:35How do you create a 2-tuple in Red?
21:35type? 2.3.4 versus type? 2.3
dsunanda
21:37Tuples have a mimimum of three values - 2.3 is a floating point number.
to-tuple [1 2]
== 1.2.0
metaperl
21:37I dont think this guide is correct here - http://helpin.red/Datatypes.html
> And any any of the following datatypes is also a scalar! datatype: char!, integer!, float!, pair!, percent!, tuple!, time!, date!

21:38a tuple is not scalar is it?
dander
21:39@dsunanda they are not equivalent to the logic values, but they are considered 'truthy', because you can do if 1 ["do it"]. Only false (and related synonyms) and none are falsy
dsunanda
21:42Thanks -- technically, they are of type LOGIC! - which includes TRUE and FALSE (and ON and OFF etc)
type? false
== logic!
type? true
== logic!
21:44A tuple in Red is a specialised datatype that can contain 3 to 12 dot separated values. The values themselves can only be 0 through 255:
>> type? 1.2.3.4.5.6.7.8.9.10.11.255
== tuple!
dander
21:46@metaperl pair! could be what you're looking for...
>> p: 2x3
== 2x3
>> p/x
== 2
>> p/y
== 3
metaperl
21:52Is probe receiving a single block or two in this expression: probe [3 + 2] [3 + 2]
dander
21:55probe passes through the first value it encounters, in this case [3 + 2]. Try ? probe
AiguyGary_twitter
23:01if I ode does
append AIResponse random/only Color
append AIResponse "!"]

I get an extra space before the "!" that is not at the end of the string inside AIResponse

Is there a way to avoid the extra spaces that append seems to add?
Ungaretti
23:03@metaperl I think you are right. According to [Red official docs](https://doc.red-lang.org/en/datatypes/tuple.html) "Tuple! is a member of the following typesets: immediate!, scalar!", but I don't think a typeset can be called a datatype! (?). I'll fix that when I find the time.
AiguyGary_twitter
23:03rejoin does it ok but requires me to assign quoted string to words first which for me would be a lot of extra lines of code. I can write a function to do it but sometimes I want to concatenate different number of strings
23:11Figured it out all the examples assigned the quoted string to words but this works too.

CD: lev UserInput/text "Give me a color."
if CD < ShortestDist [ShortestDist: CD
AIResponse: rejoin ["Ok how about " random/only Color "!"]]

lepinekong_twitter
05:59@dockimbel I didn't know about recycle/off will try. Nevertheless it's code I made a few months ago which is a big spaghetti so I'll have to refactor it anyway :)
06:10do-thru doesn't seem to work with #include in this case, why ?


>> do-thru/update https://redlang.red/debug/do-thru/index.red
section loaded
exist-section?: false ; instead of true
>> do https://redlang.red/debug/do-thru/index.red
section loaded
exist-section?: true


index.red:

unless value? '.section [
    #include https://redlang.red/section.red  
    print "section loaded"  
]

exist-section?: value? '.section 
?? exist-section?


There is no problem if index doesn't use #include:

>> do-thru/update https://redlang.red/debug/do-thru/index0.red
section loaded
exist-section?: true


index0.red:

unless value? '.section [
    do https://redlang.red/section.red  
    print "section loaded"  
]

exist-section?: value? '.section 
?? exist-section?


06:13In case it matters but I don't think it matters:
.section: func [
    'param>description [any-type!]
    param>code [block!]
    /vars param>vars [block!] 
    /_show
    /_debug
][

    _debug: false
    _debug: _debug or __DEBUG_MODE__
            
    if _debug or _show [
        print ["start section" {<!--} (param>description) {-->}]
    ]
    unless vars [
        param>vars: copy []
    ]
    do bind (param>code) make object! collect [
        forall param>vars [keep to set-word! param>vars/1]
        keep none
    ]
    if _debug or _show [
        print ["finish section" {<!--} (param>description) {-->}]
    ]              
]

section: :.section
toomasv
07:35@olivier_lp_twitter Do you mean something like:
view [field all-over on-down [probe event/offset]]
08:15Er.. all-over is irrelevant ^
olivier_lp_twitter
08:53@toomasv no, i mean by cursor offset, is when i'm filling the field the cursor is moving forward one char by one char, I'm tryning to filter a drop-down list while filling the face/text value but it always put the cursor at the beginning of the text
metaperl
15:35At http://helpin.red/BlocksSeries.html we read
> Other languages have a data type called array. It is not difficult to realize that a one dimensional array is simply a series, and multi-dimensional arrays are series that contain other series as elements.

but the question is: "is this an efficient way to process multi-dimensional arrays"?
dockimbel
16:04> a one dimensional array is simply a series

That's not true. A series is the combination of a collection and an head offset. That is not exactly the "array" datastructure found in other languages.
nedzadarek
16:41@metaperl
> "is this an efficient way to process multi-dimensional arrays"?

Define "efficient". It depends what you want to do. I guess if you want to create many small arrays then "series in the series" would use more memory (not tested). You have to test it. btw. SERIES! is a typeset! value: make typeset! [block! paren! string! file! url! path! lit-path! set-path! get-path! vector! hash! binary! tag! email! image!] and one user used image! for storing 2D arrays... so, test it.
toomasv
18:50@olivier_lp_twitter Second try:
view [
	size 180x190 
	below 
	fl: field 100 
	extra ["one" "two" "three" "four" "five" "six" "seven" "eight" "nine" "ten"] 
	on-focus [
		tl/data: face/extra 
		tl/selected: either found: find tl/data face/text [index? found][1]
		tl/visible?: yes
	] 
	on-enter [face/text: copy pick tl/data tl/selected tl/visible?: no] 
	on-change [
		tl/visible?: yes 
		either empty? face/text [
			tl/data: face/extra
		][
			tl/data: collect [
				foreach element face/extra [
					if find/match element face/text [keep copy element]
				]
			] 
		]	
		tl/selected: 1
	] 
	at 0x0 tl: text-list hidden data [] 
	on-change [fl/text: copy pick face/data face/selected] 
	do [tl/offset: fl/offset + 0x24]
]
metaperl
20:28How would I convert this Scheme to Red: (+ 21 35 12 7)
20:29i.e. - apply a binary operator to a series of values
9214
20:35
text
scheme: function [:s-expr [paren!]][
    op: take s-expr
    do next collect [
        forall s-expr [keep op keep s-expr/1]
    ]
]
20:35
text
>> scheme (+ 21 35 12 7)
== 75
metaperl
21:02I want to load [this file](https://github.com/metaperl/sicp-red/blob/master/ch1/abs.rd) so that my-abs is in memory and then type my-abs -12 and see the result... load and do dont seem to add my-abs to memory.
21:04@9214 I'm sorry ... I shouldve made myself clearer... what if I had nums: [21 35 12 7] and then I wanted to sum them up... preferably without using sum but rather with something that applies + to all elements of a block
9214
21:05@metaperl there's no apply native yet, so you can just insert + in-between elements and then do everything. The idea is the same as I showed above.
21:07Not sure what you mean by "memory". doing script should behave as you expect.
>> do https://raw.githubusercontent.com/metaperl/sicp-red/master/ch1/abs.rd
== func [x][either (x >= 0) [x] [x * -1]]
>> my-abs -5
== 5
giesse
21:59@metaperl I believe you're looking for something like this?

>> accumulate: function [zero f list] [foreach n list [zero: f zero n] zero]
== func [zero f list /local n][foreach n list [zero: f zero n] zero]
>> accumulate 0 :add [21 35 12 7]
== 75


Perhaps it there should be a more general version of collect, however in practice it may not be worth it.
metaperl
22:17I will check on that in a second.... I have a new question.


I am trying to implement the sqrt-iter function shown [here](https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book-Z-H-10.html#%_sec_1.1.7)

But I am getting a cryptic error message when I try to call my-sqrt 9 in [my code](https://github.com/metaperl/sicp-red/blob/master/ch1.rd)
22:17wow, that is pretty cool @giesse
9214
22:34@metaperl FYI, before you delve into SICP too deep - you should realise that Red is different from Scheme in many aspects, and one of them are "scoping" rules. Scheme has a lexical scope with deep binding of function's bodies (so you get closures for free and can write in idiomatic FP style as in the book). Red doesn't have scopes at all, and its concept of "binding" is a bit different from other languages. Another thing to keep in mind is that we don't have tail-call optimization yet, so you'll blow up the stack rather quickly writing in Scheme style.

I think you'll manage to complete first two chapters, but part with lambda calculus will get tricky (although at that point we might get a closure! datatype). Third part should be tackled in a more idiomatic way - with object!s and block!s, and specific care should be taken with "mutable data" section. As for concurrency and streams - thunk is a "freezed" evaluation, which is just a block!. Streams can be build on top of them rather easily.

I haven't read 4th and 5th chapters, but 4th one should be definitely tackled with Parse, and with 5th you might go Rambo and study Red/System :wink:
22:43Here's my rewrite:
sqrt-iter: func [guess x][
    either good-enough? guess x [guess][
        sqrt-iter improve guess x x
    ]
]

improve: func [guess x][average guess x / guess]

average: func [x y][divide x + y 2]

good-enough?: func [guess x][
    lesser?
        absolute subtract guess * guess x
        0.001
]

sqrt: func [x][sqrt-iter 1.0 x]
22:46On a quick review, I think your improve function should be changed to:
improve: func [guess x] [average reduce [guess (x / guess)]]

PavelVozenilek
00:52I am reading a discussion about Red on Hacker News, and there's very useful explanation, possibly worth to be linked from somewhere:
https://news.ycombinator.com/item?id=18866864
9214
01:11@PavelVozenilek (author here) thanks! I plan to extend it into a dedicated blog post at some point. Your feedback is appreciated, as newcomers and newbies alike are the main target audience.
PavelVozenilek
01:30@9214 : Heh. I am trying to grok Red and the documentation is a torture.
9214
01:32@PavelVozenilek fair enough. We have a [list of learning resources](https://github.com/red/red/wiki/[LINKS]-Learning-resources) to get you started. I'd recommend to pick [Rebol/Core user guide](http://www.rebol.com/docs/core23/rebolcore.html) first, and follow it through with [this](https://github.com/red/red/wiki/%5BDOC%5D-REBOL-Core-Users-Guide-__-A-walkthrough-with-Red) wiki page.
01:33You can always ask questions here or in [/welcome](https://gitter.im/red/red/welcome) room - someone will always jump in to give a guiding hand.
gltewalt
02:06@PavelVozenilek Which documentation is a torture?
greggirwin
03:40@9214, WRT your messages: https://gitter.im/red/help?at=5c345e9957c6883f9b7ebf72 and https://gitter.im/red/help?at=5c34826026d86e4d5643e372 to @nedzadarek, understand that you are expected to abide by our codes of conduct, per the link @gltewalt posted. This is a warning.
hiiamboris
09:43Hi! Any ideas how to turn window's event/offset into a face object at that offset? (apart from looping thru all faces)
dockimbel
10:23@hiiamboris If you have access to the event object, then just event/face. If you want to avoid looping, then there's a get-child-xy function in the GUI backends, that would return you a face object from a pair of coordinates. But those are OS-specfic functions, so their interface may vary with the OS.
hiiamboris
10:29@dockimbel event/face isn't exactly helpful: I want wheel event to go into a face that's under mouse pointer, rather than face that has focus (which event/face returns)
10:30well, no big deal really, I just thought there would be some mezz or native for that
PavelVozenilek
12:15@gltewalt : the official Red documentation is unusable for me. I tried to read through the online Rebol docs, but didn't like the style. Out of several books about Rebol I found the "Rebol - A programmer's guide" feels least painful. The style I really loved is this blog article linked from Red wiki:
http://www.michaelsydenham.com/reds-parse-dialect/
This is something even I was able to understand. Another eye opener was the post I linked before.

I am bad with long texts written by programmers, but have no troubles with short commented examples.
lepinekong_twitter
14:24@PavelVozenilek well geeks don't like to write tutorials : when you master something you don't want to lose time with trivial stuffs ;) I had same problem so I wrote also tutorials I wish I could have read https://dev.to/lepinekong/red-for-hopeless-programmers---part-ii-258
14:36@toomasv OK I wasn't clear with what I want: I want to call create function inside an other function f, for example if I use your sample code https://gitter.im/red/help?at=5c30b07d12db9607e73e17b6 it cannot work:

context [
    set 'create function ['keyword func-body][
        set to-word keyword does func-body
    ]
    test: "local var"
    foreach [keyword func-body] [
        test1 [print "Hi test1!"] 
        test2 [probe skip tail body-of system/words -4]
    ][
        create :keyword func-body 
    ]
]

f: function [][
	create test [print "hello test"]
]

test
>> test
*** Script Error: test has no value
*** Where: catch
*** Stack:

14:39@toomasv create function should be in context because I try to implement the module pattern example in javascript https://dzone.com/articles/module-pattern-in-javascript I have hundreds of small functions, I now need to isolate them ;)
toomasv
14:55@lepinekong_twitter :eyes:
>> f
== func [][print "hello test"]
>> test
hello test

nedzadarek
15:19@lepinekong_twitter I cannot speak about others but I don't like writing tutorials, readmes, licenses etc. However such things are very important.
So articles like you posted are very appreciated :+1:
lepinekong_twitter
15:31Why do I get unset! instead of function! with get-type below that just return type? :

get-type: function [arg][
	?? arg
	return type? arg
]

afunc: function[][]
functype1: type? :afunc ; -> function

functype2: get-type :afunc
?? functype2 ; -> unset! ???

15:32@nedzadarek I don't like too in fact because it takes 10 times more time but it helps remember things after you don't practice for weeks or months :)
15:36@rebolek ok mystypo I fixed it doesn't change result
rebolek
15:36RIght, deleted.
lepinekong_twitter
15:37@toomasv what do you mean ? that it works ? for me it doesn't I pasted the console ;)
nedzadarek
15:39@lepinekong_twitter I got it. arg in the type? arg will run your function. You should use :arg.
metaperl
15:56@9214 regarding [line 9 in your code](https://gist.github.com/metaperl/f6cd95260672f4c5724c846c85236783#file-sicp117-lsp-L9) are you aware that Red 0.6.4 has an average word built-in?
16:21Is there a case function in Red?
rebolek
16:22@metaperl
>> ? case
USAGE:
     CASE cases

DESCRIPTION: 
     Evaluates the block following the first true condition. 
     CASE is a native! value.

ARGUMENTS:
     cases        [block!] "Block of condition-block pairs."

REFINEMENTS:
     /all         => Test all conditions, evaluating the block following each true condition.
metaperl
16:23average is not listed here but is part of Red - http://www.red-by-example.org/
16:23thanks @rebolek
16:29Red does not like the (n-1) expression here -
`
16:29
factorial: func [n][
    either n = 1 [1][
        n * factorial (n-1)
    ]
]
16:30How are you all adding code blocks to this gitter channel?
rebolek
16:35@metaperl red-by-example is not official page, so the updates are done as author'đ time permits.
16:36@metaperl n-1 is a word!. You need to put some whitespace between values: n - 1. That's important rule.
16:37Code blocks: **`** on separate line at start and also at end.
Ungaretti
17:17> @metaperl red-by-example is not official page, so the updates are done as author'đ time permits.

@metaperl So is Helpin.red.
toomasv
17:27@lepinekong_twitter :eyes: :eyeglasses:
>> f
== func [][print "hello test"]
>> f
== func [][print "hello test"]
>> f
== func [][print "hello test"]
...
...

Don't forget to call your functions :smile:
9214
17:30> are you aware that Red 0.6.4 has an average word built-in

@metaperl I'm perfectly aware of it, and, if you haven't noticed, just ported SICP code as it was written in the first chapter.
metaperl
19:46[main.red executes do %argument_list.red](https://github.com/nedzadarek/Red-Memoi/blob/master/main.red#L8) but if this repo is sibling to mine and I do do ../Red-Memoi/main.red then the import of argument_list.red will fail because of my current working directory.
9214
19:47@metaperl you can use [this](https://github.com/9214/whatnot/blob/master/red/memoize.red) instead.
metaperl
19:47How can I get my import of the memoization functionality to work - https://github.com/metaperl/sicp-red/blob/master/ch1.rd#L27
19:54@9214 after do %../whatnot/red/memoize.red what should I type to memoize the fib function? memorize fib and memoize 'fib both fail.
9214
19:54@metaperl you can cd into directory first and then evaluate do %main.red directly.
metaperl
19:55ok but I trying to use this other one in whatnot
9214
19:55@metaperl memoize accepts a function! argument, so you should either pass an anonymous function or use get-word! to suppress application, e.g. :fib.
metaperl
20:03Well the stack still blows with memoization even on a call to fib 3 - https://github.com/metaperl/sicp-red/blob/master/ch1.rd#L26
20:03but I was warned the Red was not tail-recursive
20:05I thought memoization would prevent stack overflow
9214
20:06Try to remove memoize from example above and compare the timing.
>> fib: memoize func [n][case [n <= 1 [n] 'else [add fib n - 2 fib n - 1]]]
== func [n][
    any [
        recall [n] remember [n] apply restore [n] fix [n]
    ]
]
>> fib 45
== 1134903170
metaperl
20:08you mean you cant simply put memoize :fib after the definition of fib?
9214
20:09No. memoize is a high-level function that takes another function and returns its memoized version (as evident from the output above).
20:09So you should rather do fib: memoize :fib and then call fib as usual.
metaperl
20:10the other one is easier to use.. you would just call memoize fib - https://github.com/nedzadarek/Red-Memoi/blob/master/tests/main.red#L25
9214
20:14But you can't use anonymous function with it as in my example. It simply re-sets the word to a memoized function implicitly, thereas in my version this is explicit and optional.
20:19:point_up: [s/above/below/](https://gitter.im/red/help?at=5c37a5d9a57b501bcfe3c82f)
nedzadarek
21:16@metaperl Good evening
> [main.red executes do %argument_list.red](https://github.com/nedzadarek/Red-Memoi/blob/master/main.red#L8) but if this repo is sibling to mine and I do do ../Red-Memoi/main.red then the import of argument_list.red will fail because of my current working directory.

Are you sure the problem is your current working directory? I have this directories/files structure:
- memoi
-- / library files
- foo.red

Where foo.red is:
Red []
do %memoi/main.red
print 'hello
; rest is copied from tests/main.red from a line f42: func [a b /foo c d /baz g h][

I have run it by double clicking and pasting path to the foo.red and it does not tell me about wrong directory (Access Error: cannot open: %mmemoi/main.red - I misspelled memoi).
Are you using 0.6.4 version? If yes then one function was moved so the code was not working. I fixed it. Please update your files.
21:46@metaperl without memoization you should be able to call Fibonacci with number ~20 with no big problems. After 25 it gets slow - at least on my pc.
I tried to make memoized fibonacci but it does not seems to work.
Re-git
21:55 I would like to show png image with transparency on the screen but without the window (titlebar, buttons, and backdrop) Is it possible to make a transparent window backdrop with View?
9214
22:01@vejitatoja no, as far as I know. Window is a mandatory top-level widget. You can use popup flag or combination of no-min no-max though, to remove titlebar and buttons.

nedzadarek
00:08@Oldes about images (i: make image! ...):
> I suppose lexer should recognize i/1x1 like it recognize i/(1x1), right?

I do not mind pair index (not only for images!) but I would like to think () as some special "function" that you can "index" using different methods.
toomasv
04:08@vejitatoja view/flags [...] 'no-title removes title-bar, but background cannot made transparent currently AFAIK.
hiiamboris
05:53@vejitatoja I was curious how hard it can be ☻ https://gitlab.com/hiiamboris/red-alpha/tree/master
05:55According to MS docs it cannot work on W7, but it does.
dockimbel
06:07@hiiamboris Yes, it's pretty straightforward, though, I remember that it may not be that easy to support on all our target platforms, is it?
hiiamboris
06:08That's what I'm also wondering about...
toomasv
07:18@hiiamboris :+1: But on my W10, when run, it shows for a moment, but can't be brought to the foreground after that.
hiiamboris
09:15Makes sense. That's because how differently layering is done in Red on W7 and W8+...
09:19@toomasv try now, but I have no idea how to make it receive mouse events.
toomasv
09:23@hiiamboris Thanks! Now it stays on foreground until mouse-down on it - then disappears to background.
hiiamboris
09:34Yeah for some reason it's click-through... You can Alt-Tab back to it though ☺
10:24@toomasv clickable now, but still it's not alpha transparency, just single-color transparency (black in this case)
toomasv
10:27@hiiamboris Thanks, but alas, still escapes from click.
hiiamboris
10:33really? it does not on W8.1, and the code is the same I believe
10:33well, can't help you with W10 as VM is useless
toomasv
11:20Thanks anyway! :smile:
lepinekong_twitter
12:10@nedzadarek oh thanks :) by the way since you seem interested, I've started to write documentation for my functions that I try to refine into small tutorials in the future. Examples: https://redlang.red/source and https://redlang.red/override
12:11@toomasv huh :D thanks
nedzadarek
14:20@lepinekong_twitter nice. You could add "list of chapters" as well.
btw. write-clipboard mold : I wonder if :<...> is good syntax for it.
metaperl
14:50@nedzadarek fib 3 leads to stack overflow with [this implementation of fib](https://github.com/metaperl/sicp-red/blob/master/ch1.red#L31)
14:51screenshot - https://monosnap.com/file/OETWtwis340MDoACYQFhMEeV6AMdLj
9214
15:02@metaperl it happens because your implementation is wrong. Think about + precedence in second case branch.
15:03Sorry, third branch.
metaperl
15:07@9214 true [(fib (n - 1)) + (fib (n - 2))] fixed it... how was + binding before?
9214
15:13Operators take precedence over functions and have short left scope (take one value to the left) with width right scope (take result of expression on the right).
15:14So it was fib ((n - 1) + ...) in your case.
lepinekong_twitter
16:20@nedzadarek list of chapters will come when I'll have finished automating core stuff before : at the moment I'm focused on one page http://readable.red/doc/
16:21@nedzadarek do you have a better suggestion for :<...> ?
nedzadarek
16:42@lepinekong_twitter I mean something like this:
1) Usage
2) Source

and every element is a link that points to some part of the document:
1) Usage:
...
2) Source:
...

Like in [this example](https://www.w3schools.com/html/tryit.asp?filename=tryhtml_links_bookmark) when you click Jump to Chapter 4 it will move page a little to the Chapter 4 (h2 of id = "C4").

> do you have a better suggestion for :<...> ?

Why not just :function-name (or native-name, ... if you support other "function types").
Keep in mind you can pass a function (and other types) in a few different ways:
- f: func [f] [f 10] f :random ;== 3
- f: func ['f] [do reduce [f 10]] f random ;== 8
- f: func [f] [do append f 10] f [random] ;== 4
- ...

So you may consider writing types and lit-param/get-param.
lepinekong_twitter
16:47@nedzadarek yes later, in fact I intend to create a module to cross-hyperlink everything automatically.
9214
16:50> Keep in mind you can pass a function (and other types) in a few different ways

In 2nd and 3rd case you are passing word! and block!, not function!.
lepinekong_twitter
18:33Isn't func different from function ? why is b also private in afunc ?

afunction: func [a][
    a: 1
    b: 2
]
afunction

afunc: func [a][

    a: 1
    b: 2
]
afunc
b ; b has no value why since it's afunc not in a function ?


metaperl
18:39You used func in both cases.
18:41
>> ? function
USAGE:
     FUNCTION spec body

DESCRIPTION: 
     Defines a function, making all set-words found in body, local. 
     FUNCTION is a native! value.

ARGUMENTS:
     spec         [block!] 
     body         [block!] 

REFINEMENTS:
     /extern      => Exclude words that follow this refinement.

>> ? func
USAGE:
     FUNC spec body

DESCRIPTION: 
     Defines a function with a given spec and body. 
     FUNC is a native! value.

ARGUMENTS:
     spec         [block!] 
     body         [block!] 

>>


toomasv
18:53@lepinekong_twitter :eyeglasses: If you define a function with an argument, then remember to call it with defined argument:
afunction: function [a][
    a: 1
    b: 2
]
afunction 1
b
;*** Script Error: b has no value
afunc: func [a][
    a: 1
    b: 2
]
afunc 1
b 
;== 2
lepinekong_twitter
20:22@metaperl @toomasv Oops thanks I must be tired :)
20:45What's the equivalent of rebol make function! http://rebol.com/docs/core23/rebolcore-9.html#section-3 in red ? I tried this:

f: make function! [][print "hello"]
*** Script Error: invalid function definition: []
*** Where: make
*** Stack: run f

20:46I checked in rebol:

>> f: make function! [][print "hello"]
>> f
hello
>>


toomasv
21:12@lepinekong_twitter
>> f: make function! [[][print "hello"]]
== func [][print "hello"]
>> f
hello
lepinekong_twitter
21:29@toomasv thanks it works. Am I obliged to give a name ? do make function! doesn't work:

arg: []
block: [print "hello"]
f: make function! reduce [(arg) (block)]
f

do make function! reduce [(arg) (block)]

nedzadarek
22:01@lepinekong_twitter
>> do reduce [make function! [ [a] [print a * 2] ] 21 ]
42
22:06It seems that you cannot do 0-argument functions like in your example.
greggirwin
22:59@nedzadarek it's not the arity, but how do evaluates functions in Red. That is, it doesn't.
; define arg and block as above.
>> do make function! reduce [(arg) (block)]
== func [][print "hello"]
>> do :append
== make action! [[{Inserts value(s) at series tail; returns series head} 
    series [series! bitset!] 
    value [any-typ...
>> do reduce [make function! reduce [(arg) (block)]]
hello
nedzadarek
23:26@greggirwin it doesn't evaluate functions passed as as arguments (f: does [print 'f] do :f) but it knows how to evaluate it when they are in a block (as in your last example).
So, what I mean there is no special case in do that evaluates functions. It could be something like this:
do: [value ...] [
 ; ...
 if all [any-function? value no-arguments? value] [do reduce [value] ]
]

ps. no, I don't suggest such addition.
23:29ps2.no-arguments? just checks if a function need an argument - if no then it returns true; otherwise it returns false.
greggirwin
23:56This is an intentional design choice. [block! path! string! url! file!] are "actively" evaluated. All other types are passively evaluated.

nedzadarek
00:07Interesting.
lepinekong_twitter
00:36@nedzadarek thanks :)
toomasv
04:16@lepinekong_twitter Or
>> do reduce compose/deep/only [make function! [(arg) (block)]]
hello
>> do reduce repend/only [make function!] [arg block]
hello
giesse
05:35@nedzadarek in R2, do and make are the only functions that take a variable number of arguments. In Red, they take a fixed number of arguments like any other function. Therefore, it's impossible for do to evaluate function! arguments, unless you make an exception for functions with zero arguments, which has hardly any use in practice. It also makes writing a compiler *a lot* more complicated.
dockimbel
05:37@giesse What do you think about R3 making make fixed-arity while leaving do variable-arity?
giesse
07:15@dockimbel I'm undecided on the matter. On the interpreter side, it costs nothing to let do evaluate functions and, by side effect, take any number of arguments. But it is a bit ugly that do becomes special. As long as you have something like apply, there's not much in practice that do on functions is needed for, though, so both choices have their merit.
dockimbel
07:32We can see how apply usage will spread in Red once it is available.
nedzadarek
16:08@giesse
> Therefore, it's impossible for do to evaluate function! arguments, unless you make an exception for functions with zero arguments, which has hardly any use in practice. It also makes writing a compiler a lot more complicated.

I agree with you in 100%.

> in R2, do and make are the only functions that take a variable number of arguments.

I haven't knew this. Thank you for this information.
9214
16:53It's worth to keep in mind that R3's banishing of variable-arity functions was dictated by desire to make it more amenable to static analysis. Red pushed it further and forbade do too.
giesse
19:10@9214 I don't believe that was Carl's intent. I think it's just a general dislike of "special" items within the language (ie. in Red do and make can be mezz functions, in R2 that's not possible).
9214
19:19https://github.com/red/red/issues/3553

dockimbel
05:23@9214 My last comment there is a bit confusing, let me add some context to it. Hope it's clearer now.
9214
11:51@dockimbel yes, and clarifies the [similar thought](https://github.com/red/red/issues/3553#issuecomment-427601176) I've raised in this ticket (which I'm closing now).
Re-git
18:48I was playing today with making simple animations using draw dialect. Just some ball objects moving on the screen with velocity and position.
I love that Red is so simple but is there a way to make drawing a little more performant?

Here is the code:
Red[]
window-size: 900x900
ball-spacing-x: 36
ball-spacing-y: 1
ball-size: 10
ball-speed-x: 1.0
ball-speed-y: 1.0
balls-number: 1000
balls: []
balls2: []

ball: object [
    init: does [
        self/velocity/1: ball-speed-x
        self/velocity/2: ball-speed-y
        self/color: as-color random 255 210 222
        position-if-outside]

    outside-x?: does [return self/position/1 > window-size/x]
    outside-y?: does [return self/position/2 > window-size/2]
    
    position-if-outside: does [
        case [
            outside-x? [
                self/position/1: -1 * (window-size/1 - self/position/1)
                position-if-outside
            ]
            outside-y? [
                self/position/2: -1 * (window-size/2 - self/position/2)
                position-if-outside
            ]
            true [
                return false
            ]
        ]
    ]
    
    update: does [
        move-ball
        check-bounds
        ]
    
    move-ball: does [
        self/position/1: self/position/1 + self/velocity/1
        self/position/2: self/position/2 + self/velocity/2
        ]
    
    check-bounds: does [
        if self/position/1 > window-size/1 [
            self/position/1: 1
        ]
        if self/position/1 < 0 [
            self/position/1: window-size/x
        ]
        if self/position/2 > window-size/2 [
            self/position/2: 1
        ]
        if self/position/2 < 0 [
            self/position/2: window-size/y
        ]
    ]
    
    size: ball-size
    color: black
    velocity: [1.0 1.0]
    position: [1.0 1.0]
    position-pixel: does [return as-pair to-integer self/position/1 to-integer self/position/2
    ]
]


repeat i balls-number [
            append balls make ball [
                self/position/1: ball-spacing-x * i
                self/position/2: ball-spacing-y * i
                self/init
                ]
            ]
repeat i balls-number [
            append balls2 make ball [
                self/position/1: ball-spacing-x * i 
                self/position/2: ball-spacing-y * i
                self/init
                self/velocity/1: -1 * ball-speed-x
                ]
            ]

animate: function [face] [
    face/draw: copy []
    foreach ball balls [
        ball/update
        append face/draw compose [
            pen off fill-pen (ball/color) circle (ball/position-pixel) (ball/size)
        ]
    ]
    foreach ball balls2 [
        ball/update
        append face/draw compose [
            pen off fill-pen (ball/color) circle (ball/position-pixel) (ball/size)
        ]
    ]
]
view window: layout/tight compose [
    canvas: base 110.50.70 (window-size) draw [] rate 60 on-time [animate face]    
]
18:53I have tried to compile this script on OSX to see if there is any speed increase but when compiled there is no animation at all. I think it might be some bug. I don't have my Windows machine at the moment so I can't check if compilation works there.
9214
19:06@vejitatoja have you tried to specify -r -e flags?
19:21> is there a way to make drawing a little more performant?

Try to optimize your code first, as it spends most of the time in what looks like an inefficient loop with huge memory overhead. If that doesn't help, seek for bottlenecks and rewrite them in Red/System (take a look at [this](https://github.com/red/code/blob/master/Scripts/mandelbrot-fast.red) as an example).
lepinekong_twitter
19:55@toomasv thanks
19:56/args missing for do-thru
giesse
20:01@9214 -e can hardly solve a performance problem, can it? :)
9214
20:02@giesse yes, but it may bring back the animation (maybe a limitation of current AOT compiler is the culprit), theoretically.
Re-git
20:20Animation works again with -r -e flags when compiled!
Compiling does not have effect on performance.

What is interesting is that when i click inside the window performance drops to twice as slow. And when i make the window loose focus it becomes twice as fast again. I have used code below by Brian Casiello to time the animate function.
time-block: func [block /reps times] [
    if not reps [times: 1]
    start: now/time/precise
    loop times [do :block]
    print now/time/precise - start
]
9214
20:29> Compiling does not have effect on performance

Right, but that's expected.

> to time the animate function

I'd recommend to use @greggirwin's profile from [here](https://gist.github.com/greggirwin/908d44dc069ed84cf69f053e1308390d). As for 2x slow down, my guess is that this has something to do with event handling. Remember that Red uses native OS-specific backends, which have their upper caps.
giesse
22:28@9214 right, it would bring back the animation, but we already know it works in the interpreter, so what's the point?
22:28@vejitatoja -e does not do any compilation, you just got an exe with the interpreter and your script bundled into it. So, performance will be the same.
gltewalt
22:29The point is there was no animation for him when he compiled and he didn’t know why.
giesse
22:30@vejitatoja you are building a new draw block with each iteration, a simple optimization would be to build the block once and then just update the coordinates inside it.
9214
22:41@giesse the point is to have a single binary, and also eliminate compiler's quirks. If that's not the goal, then of course using interpreter is enough.
nedzadarek
23:31@giesse when using repl, it it was only very tall window - no animation (I changed the size to 0x450 later). ps. using stable 0.6.4
23:32Do I have to do something to start the animation?
greggirwin
23:34@vejitatoja, I thought this was in red/code, but it seems not. It's a port of an old R2 demo Nenad did.

https://gist.github.com/greggirwin/c03daa544de2092284a618a899266a23
23:35Just for tinkering and ideas. You can also see the Bubbles and other demos in red/code/scripts/.

dockimbel
02:58@vejitatoja Your code can be greatly simplified and run way faster if you turn it from an object-oriented approach to a data-oriented approach, by reusing the draw block as suggested by @giesse. That way, all the balls are stored in a single reusable block, and you don't need then to create 2000 objects to handle them. If you can't figure it out, someone here can surely provide you with a refactored version of your code.
04:16@vejitatoja I had to remove all the self/ prefixes to make it run (they are superfluous anyway). Cool visual demo! Frame rate could indeed be largely improved by avoiding the creation of 2000 balls on every frame.
04:19One quick example of possible code reduction:
does [return as-pair to-integer position/1 to-integer position/2]

can be replaced by just:
does [to-pair position]

You can even replace to-pair with to pair! which is equivalent, but faster alternative (as to-pair is just a convenient wrapper).
giesse
04:24@9214 but @vejitatoja only mentioned performance. "I have tried to compile this script on OSX to see if there is any speed increase but when compiled there is no animation at all." Therefore I don't see the point of suggesting -e.
9214
08:34@giesse so you would rather ignore the fact that compiled script doesn't work as expected? If it wouldn't work even after -e flag, then we would have a problem worth reporting - that's what I was checking, not suggesting using these flags to boost up performance (which doesn't make any sense).
hiiamboris
14:01Is there a way to make event! [] in Red?
rebolek
14:01not yet
dsunanda
15:56How do I update the attributes of the text in a VID box? In the code below, only the text associated with 't (a text field) changes, while 'b (a box) is unaffected:
view/no-wait [b: box "BOX" font-color blue font-size 10
              t: text "TEXT" font-color blue font-size 10
              ]
 b/font/size:  t/font/size: 20
b/font/color: t/font/color: green
hiiamboris
15:59it's a bug obviously
15:59@dsunanda you on Windows 7?
dsunanda
16:01Win10 in this case - It's never obvious if anything in Red is a bug.....It could be an unimplemented feature, or a principled decision :_)
nedzadarek
16:01@dsunanda @hiiamboris on win 8.1 x64 it doesn't work too. I'm going to download the newest version.
dsunanda
16:02I tried on 0.6.4 stable, and today's daily. Same result in both
nedzadarek
16:03I have tried it on the stable and 01.01.2019
hiiamboris
16:03@dsunanda please raise an issue about it. It works for base but doesn't work for box or any base with non zero alpha. Mention that it's the same for W7, W8 and W10.
dsunanda
16:04Thanks -- will do.
nedzadarek
16:09^^ Yes, same on the latest non-stable.
dsunanda
16:10Thanks guys - reported #3730
hiiamboris
16:17:+1:
lepinekong_twitter
17:32I want to create a module keyword: will this be a red native word in the future ? if yes I'll change.
rebolek
17:33@lepinekong_twitter modules are planned for 0.8.0, so I believe it's going to be used.
dander
17:49@rebolek it would be safe if used from a context though, wouldn't it?
17:50could still potentially cause some confusion though...
giesse
18:04@9214 I don't understand at what point -e helps establish that there is a problem with the compiler. It was already clear that the compiled version didn't work while the interpreted version did. I don't see how -e helps you see why the compiled version doesn't work. But, this already feels like a pointless argument...
rebolek
18:10@dander it would, but I guess that if you want to name something module, you want to use it at global level, unlike something like index for example.
Re-git
19:08@dockimbel @giesse thank you for the suggestion. I
removed object code and instead tried to just manipulate the draw block directly but I could not figure out how to implement same logic. How will I keep track of each ball direction and speed in data oriented approach?
giesse
20:52@vejitatoja check out the bubbles demo, it's doing something similar. I wrote the original REBOL version. http://www.rebol.com/view/demos/bubbles.r
The bubbles are moving randomly upwards, but if you notice I'm keeping track the position of each bubble in the draw block and making a list of that. You can keep using objects, to keep track of direction/speed etc. (objects are just rather memory intensive, but it wouldn't slow down the main loop here), then have each object point to the bubble draw code and update it directly.
Re-git
20:55can you help me understand this behavior?
a: [circle 20x30 10]
position: a/2
probe position/1 ;prints 20
position/1: 99
probe position/1 ;prints 99
probe a ; prints [circle 20x30 10]

I expected [circle 99x30 10]
nedzadarek
21:02@vejitatoja pair! (e.g. 20x30) does not share the same behaviour as block! (or other types that I had to check, probably any-series! or something). So, position and a/2 is **not the same**. By editing one value you will not see a change in the other value.
Re-git
21:13If i would not use pair and a could be a: [circle [20 30] 10]instead, everything would work as expected.
Is there some workaround to make it work so i can name my pairs inside the draw block?
21:24When I say position: a/2 it creates a copy of the original pair instead?
nedzadarek
21:28@vejitatoja
> When I say position: a/2 it creates a copy of the original pair instead?

I guess yes, but I am have not read the source so I cannot be sure
21:29
Is there some workaround to make it work so i can name my pairs inside the draw block?

draw-block: [sun: circle 20x30 10]
sun: find draw-block 'sun ; == [sun: circle 20x30 10]
sun: find/tail draw-block 'sun ; == [circle 20x30 10]
sun/2: 90x90 ; == 90x90
sun ; == [circle 90x90 10]
draw-block ; == [sun: circle 90x90 10]
>
dsunanda
21:30It creates a new word 'position that is initialized to the value of a/2 - and now they are separate values. You might want to play with this:
a: [circle 20x30 10]
position: next a
position/1/1: 99
print a
[circle 99x30 10]

'position here is the same as a/2, rather than an equal value.
lepinekong_twitter
21:45@rebolek ok thanks, in fact not sure yet I really need to create one.
21:48@dander for me context does't work currently to isolate, better use an anonymous function like in javascript that's why I asked how to autoexec a function so I used @nedzadarek answer do reduce I tested it it seems to work https://redlang.red/module-pattern
22:12@rebolek I'm going to use the term capsule :)
greggirwin
22:49@vejitatoja if your block is being used for draw commands, you can include set-words as markers. https://doc.red-lang.org/en/draw.html#_source_position mentions it, but doesn't have examples.

@giesse's Bubbles script, ported to Red: https://github.com/red/code/blob/master/Scripts/bubbles.red

https://github.com/red/code/blob/master/Scripts/resize-image.red#L50 shows basic usage of set-words in draw blocks.

giesse
01:01@vejitatoja pair! is a scalar type, like tuple!, or integer!. You can refer to them by putting them in a block (for example). In your case, you already have the pair in a block, so it's easy.
01:02@dsunanda already showed you, but I'd use x and y rather than 1 and 2 for pairs.

>> a: [circle 20x30 10]
== [circle 20x30 10]
>> position: at a 2
== [20x30 10]
>> position/1
== 20x30
>> position/1/x
== 20
>> position/1/y
== 30
>> position/1/x: 99
== 99
>> a
== [circle 99x30 10]
dockimbel
05:27@vejitatoja The key point above is the difference between at a 2 and a/2, the former is returning a reference to the same block but with a head position moved to index 2, while the latter is returning you the second element of the block (putting it on the internal stack, so it's a copy).

at a 2 has the following equivalents:
* skip a 1 (skip gives you basically 0-based indexing navigation)
* next a

a/2 has the following equivalents:
* second a
* pick a 2
* select a 'circle
Re-git
12:23@giesse @dockimbel Thank you! I think I understand it now.
toomasv
12:56But notice also difference between access methods in case you acces function values:
>> blk: reduce ['a func [a b][a + b]]
== [a func [a b][a + b]]
>> pick blk 2
== func [a b][a + b]
>> second blk
== func [a b][a + b]
>> select blk 'a
== func [a b][a + b]
>> blk/2
*** Script Error: blk/2 is missing its a argument
>> blk/2 1 2
== 3
Re-git
23:05I have rewritten the demo with balls animation using the data oriented style. [https://github.com/vejitatoja/Red-demos/tree/master/Balls](https://github.com/vejitatoja/Red-demos/tree/master/Balls)
Good news is that it works much faster especially if we start drawing thousands of circles. If i increase ball-number to 5000 (that will draw 10 000 circles every frame) the data oriented demo works twice as fast.
greggirwin
23:12Nice work @vejitatoja !
Re-git
23:15Bad news is that when I run the code on Windows 10 the animation is very slow. It looks like 10x slower comparing to running it on my much slower/older laptop with OSX.
Looking at the output of profiling the update function (15 miliseconds per frame) it looks like it should easily run with 60 frames per second but visually it looks like 10 fps.
On OSX the same function is taking more time per frame but the animation is super fluid and much faster.
greggirwin
23:20You could try the approach used in https://github.com/red/code/blob/master/Scripts/tiger.red, rather than using a rate timer. I have a bubbles version that does something similar. e.g.
until [
	foreach bubble bubbles [move-bubble bubble]
	show canvas
	do-events/no-wait
	quit?
]
23:21If you go to https://gist.github.com/greggirwin and search for bubbles, you should see a few versions.
23:23Note that with those, moving the mouse pumps the event loop (at least for me on Win10).
Re-git
23:37@greggirwin this does not help the performance and as you mentioned it freezes the program for a moment when moving the mouse.
23:42It would be good if someone with access to Mac and Windows could check the demo and see if he can also notice the huge slowdown.

nedzadarek
00:17@vejitatoja you can save few MS by storing draw-block into image:
https://gist.github.com/nedzadarek/53ed0cdb89e28c99175fb8ff692da7f3 lines: 20, 24 and 60.
00:18For my laptop 100 balls looks "smooth".
00:18ps. at least it works
greggirwin
00:25@vejitatoja, indeed, in a quick hack here, I needed at least 2 do-events calls to make it smooth.

loop 2 [do-events/no-wait]

But I don't think it's any faster than the original.
00:31You can turn the pen off just once, rather than for every ball. Again, a tiny gain perhaps.
lepinekong_twitter
00:34I created a function placeholder to export private function for public access through context: is there another way :)
unless value? '.section [do https://redlang.red/section]
.system: context [

	c: "c value from .system context"
	g: function[a b][print [a b "by context g function"]]
	f: 'export-placeholder
	
	do reduce [ 
		function [][
			f: function[a b][
				d: "d value from private function"
				.section "private a b" [
					print [a b c d]
				]
			]
			.section "exporting private f to context" [
				set in self 'f :f
			]			
			f 1 2   
			.section "totally private function not exported" [
				h: function[][print "I'm h incognito"]
				h
			]
			.section "other function body words should not leak either" [
				e: 4
			]             
		]
	]

]

.system/f 3 4

;1 2 c value from .system context d value from private function
;I'm h incognito
;3 4 c value from .system context d value from private function

greggirwin
00:42Not sure if this will work in your case:
export: func [
    "Export a value to the global context"
    'word [set-word!]
    value
    /to "Export to an alternate context"
    	ctx [any-word! any-object! function!]
] [
    set word :value
    unless :ctx [ctx: system/words]
    set bind word ctx :value
]

But the main point is that, currently, in Red, you can't extend a context/object, so the words need to exist at creation time, or you need to make a new object that contains them.
00:43I have a different one, but didn't note who wrote the above code that I kept for reference. I know it's not mine, because it uses unless. :^)
nedzadarek
00:45@lepinekong_twitter
Why not just set it directly in the context? For example:
.system: context [
  local-a: ...
  local-b: ...
  local-f: function [...] [... local-a ...]
]

Unless I am missing something...
dockimbel
04:30@toomasv Yes, paths are "active" accessors, so a function will get evaluated. Same as in Rebol.
toomasv
04:43@dockimbel So the only way to put functions accessed by "passive" accessors into use is to assign these to words first? As e.g.
>> f: pick blk 2
== func [a b][a + b]
>> f 1 2
== 3

Or, more convoluted:
>> do head insert [1 2] pick blk 2
== 3
>> reduce head insert [1 2] pick blk 2
== [3]
dockimbel
04:55@toomasv Correct. There will also be apply available at some point.
giesse
05:16
>> o: make object! [f: func [a b] [a + b]]
== make object! [
    f: func [a b][a + b]
]
>> o/f 1 2
== 3
>> :o/f
== func [a b][a + b]
hiiamboris
05:35what is the difference between object [..] and context [..]?
05:44I can't compile this script: Red [] c: [a: 1] c: context c
But can compile this one: Red [] c: [a: 1] c: object c
dockimbel
06:00@hiiamboris For the interpreter, it's the same (though in R3, object appends a convenient none at the tail of the argument block; we might want to do the same). For the compiler, context is recognized statically, so that c is treated in a special way (its type is fixed), while object is considered a "dynamic" construct at run-time, as any other function call, so will behave identically to the interpreter.
hiiamboris
06:09Understood. Thank you.
nedzadarek
11:27@toomasv you can use get syntax (I do not think it is official term): f: :blk/2
you can simplify your 2nd code:
do compose [(:blk/2) 2 3] ; == 5
do reduce [blk/2 2 3] ; == 5
lepinekong_twitter
14:22@nedzadarek because that's not the purpose of a module pattern: you have implementation private and exposition public :)
14:23Is it normal that return doesn't return in truth but continues til the end of a function ? This creates vicious bug flow to fix.
rebolek
14:24Do you have any example?
nedzadarek
14:24@lepinekong_twitter unless you redefine return it shouldn't continue.
14:31ps. as fair I know
rebolek
14:36Of course it doesn't. Unless I see some code that supports the claim that's a vicious bug, I'm skeptical over it.
lepinekong_twitter
16:32@rebolek it's the example on CD I debugged here https://redlang.red/section
16:36The parse example of https://www.red-lang.org/2013/11/041-introducing-parse.html I don't even understand how it works :) why load, opt, tags are needed, I removed them it still output the same.

html: {
        <html>
            <head><title>Test</title></head>
            <body><div><u>Hello</u> <b>World</b></div></body>
        </html>
    }

    ws: charset reduce [space tab cr lf]

    parse html tags: [
        collect [any [
            ws
            | "</" thru ">" break
            | "<" copy name to ">" skip keep (load name) opt tags
            | keep to "<"
        ]]
    ]

16:40@nedzadarek It's true I like overriding but not return (yet) :)
nedzadarek
16:41@lepinekong_twitter I had to ask because I have been doing it (overriding return).
lepinekong_twitter
16:41@nedzadarek oh I wanna see it then ;)
nedzadarek
16:43@lepinekong_twitter https://github.com/nedzadarek/Red-Memoi/blob/master/main.red#L77
lepinekong_twitter
18:12@nedzadarek ok thanks, if one day I need to do the same :)
greggirwin
20:54> Is it normal that return doesn't return in truth but continues til the end of a function ? This creates vicious bug flow to fix.

No, that's not normal, and I doubt it's a Red bug in this case. If you pass code around in blocks, and then do them, you need to understand how binding and evaluation work in depth.
20:58@lepinekong_twitter on your parse example, if you remove load you don't get the same output.
lepinekong_twitter
22:27@greggirwin where is this documented ? has anybody has an understanding of how return is affected ?
greggirwin
23:57As you know, we recommend Rebol docs for non-reference lang behavior and "User Guide" info, until we write our own for Red. And yes, there are people who understand this. You can too.
lepinekong_twitter
23:59is Red 6.0.4 Console now able to show a list like in this example ? https://publish.twitter.com/?query=https%3A%2F%2Ftwitter.com%2FDanEnglishby%2Fstatus%2F1084089006806233091&widget=Tweet

greggirwin
00:00Not yet.
nedzadarek
00:02But can you create a menu like when you click right mouse button?
toomasv
05:37@nedzadarek Contextual menu? Yes, you can.
lepinekong_twitter
10:55@toomasv @nedzadarek if one can click contextual menu, what would prevent to capture keypress and show that contextual menu on the fly so you get the same effect as the example ?
Re-git
11:04@nedzadarek Thank you for the idea! Indeed converting draw commands to an image instead of adding the regular draw block to face brings amazing improvement to speed of rendering of the graphics in the window. Even though it makes the update function that is being run every frame take much longer (which doesn't really make sens to me - why making the program slower would make rendering faster?).
It's a workaround and it works but shouldn't the conversion of draw-block to the image already happen in the background when Red sends some commands to operating system (windows 10)?

There is also another big problem with this approach - huge memory overhead and memory leak that crashes program after around 30 seconds on my system when it reaches 1.8 gigabytes in ram while the data-oriented version stays at 5.5 megabytes. [https://github.com/vejitatoja/Red-demos/tree/master/Balls](https://github.com/vejitatoja/Red-demos/tree/master/Balls)
nedzadarek
11:32@vejitatoja
> huge memory overhead and memory leak

Right, I have forgotten about that bug. At the moment images are not garbage collected (not sure about the newest versions). It seems that you can use one image with draw - [edit](https://gist.github.com/nedzadarek/53ed0cdb89e28c99175fb8ff692da7f3) ([change](https://gist.github.com/nedzadarek/53ed0cdb89e28c99175fb8ff692da7f3)).

> It's a workaround and it works but shouldn't the conversion of draw-block to the image already happen in the background when Red sends some commands to operating system (windows 10)?

As fair I remember it does something like this but it is not the best at it. It is more flexible than efficient... something like this. Talk to Red/draw gurus to know more.

> Even though it makes the update function that is being run every frame take much longer (which doesn't really make sens to me - why making the program slower would make rendering faster?).

My guess is that it updates the outside world (a screen) more than once. Any such edit of the outside world (a screen, a speaker etc) might be slower than "inside computation". draw - function version updates it only **once**. So you might lose some Ms for constant get draw data => update face/thing transition.
11:37@lepinekong_twitter Well, you mayb be able to show "rmb menu"... but it has to have right options.
lepinekong_twitter
21:31what is rmb ?
21:32Will VSCode red extension be able to also run in the browser ? https://publish.twitter.com/?query=https%3A%2F%2Ftwitter.com%2FCompuIves%2Fstatus%2F1062750492407803904&widget=Tweet
nedzadarek
21:54@lepinekong_twitter Right Mouse Button
lepinekong_twitter
22:17@nedzadarek ha yes :)
22:18I don't understand help source, where on earth is defined the _print function ? I type source _print and it's nowhere ? Is there hidden functions ?

help: func [
    {Displays information about functions, values, objects, and datatypes.} 
    'word [any-type!]
][
    print help-string :word
]

help-string: func [
    {Returns information about functions, values, objects, and datatypes.} 
    'word [any-type!] 
    /local value
][
    clear output-buffer 
    case [
        unset? :word [_print HELP-USAGE] 
        string? :word [what/with/spec/buffer word] 
        all [word? :word unset? get/any :word] [what/with/buffer word] 
        'else [
            value: either any [word? :word path? :word] [get/any :word] [:word] 
            case [
                all [any [word? :word path? :word] any-function? :value] [show-function-help :word] 
                any-function? :value [_print mold :value] 
                datatype? :value [show-datatype-help :value] 
                object? :value [show-object-help word] 
                map? :value [show-map-help word] 
                block? :value [_print [word-is-value-str/only :word DEF_SEP form-value :value]] 
                image? :value [
                    either in system 'view [view [image value]] [
                        _print form-value value
                    ]
                ] 
                all [path? :word object? :value] [show-object-help word] 
                any [word? :word path? :word] [_print word-is-value-str word] 
                'else [_print value-is-type-str :word]
            ]
        ]
    ] 
    output-buffer
]

dander
22:26@lepinekong_twitter you can find it along with a bunch of other parameters/helper functions in help-ctx
22:30by this point of digging into sources, the actual source code starts to become pretty useful: https://github.com/red/red/blob/master/environment/console/help.red
nedzadarek
23:39@lepinekong_twitter That's contexts for you.
If you don't want to look for it in the files then you can look for it in the body-of function (b: body-of :help-string). As you can see, you can get _print by this path: b/case/word/1. You can probe context? b/case/word/1 to see that function (it might be big so you may save it into file).
Instead of probe'ing, you can get it: _print: :b/case/word/1 get _print.. and continue using above knowledge.
ps. that's trial and errors - it may not work for everything.
23:41btw. There are 3 "global" contexts:
? "-ctx"
     gui-console-ctx object!       [...]
     help-ctx        object!       [...]
     red-complete-ctx object!       [...]
23:41So you may look for other functions there.

lepinekong_twitter
00:36@dander @nedzadarek ah I see better thanks.
00:52wrote a memo there https://redlang.red/help for I intend to extend help to support https://readable.red format for my own function documentation :)
greggirwin
01:21@lepinekong_twitter print source help-ctx on your page won't do what you think, I think.
PaulBanks
01:52Hi, just found this site - http://www.mycode4fun.co.uk/About-Red-Programming -
there's loads of good stuff on there, also all the other pages are real cool. bit slow to return messages
but good help and advice - a top rate site. ---- Ok on another note, I have a big problem, sorry, but when I create an exe with Red, my AntiVirus is complaining that it's a trojan and keeps wanting to remove it, makes it pretty useless if i want to share it ?.
greggirwin
02:02@PaulBanks, yes @virtualAlan shows up here as well, and keeps us all updated via the mailling list too.

The AV issues are a known problem for us. We have notes and hints on how to help with it (e.g. UPXing), but I can't find them at the moment. One of our other regulars can probably turn it up in short order though.
lepinekong_twitter
08:55@greggirwin well I changed to print mold :help-ctx but it's still didn't get rid of "^/" in string properties, is there another way ?
08:57Is there a reddish special way to group in sub-blocks so that I can calculate frequencies of words like this:

block: ["a" "a" "a" "b" "b"] ; suppose a sorted block
frequencies: ["a" 3 "b" 2] ; how to get the frequencies of each word ?


rebolek
09:01@lepinekong_twitter I use this:
>> block: ["a" "a" "a" "b" "b"]
== ["a" "a" "a" "b" "b"]
>> frequency: func [data /loca result][result: copy #() foreach value data [result/:value: either result/:value [result/:value + 1][1]] result]
== func [data /loca result][result: copy #() foreach value data [result/:value: either result/:value [result/:value + 1] [1]] result]
>> frequency block
== #(
    "a" 3
    "b" 2
)
lepinekong_twitter
13:40@rebolek thanks that's what I feared one cannot use collect here ;)
13:42@rebolek I think I did the same way but using block. Is using #() has any special advantage ?

page: read https://medium.com/@preethikasireddy/how-does-ethereum-work-anyway-22d1df506369
parse page [to {<div class="section-content">} copy html to end]
parse html [
    (collector: copy "")
    any [
        thru "<" to ">" skip copy text [to "<" | to "</" | to end] (append collector text)
        |
        thru "</" to ">" skip copy text [to "<" | to "</" | to end] (append collector text)
    ]
]

words: sort split collector make bitset! [#" " #"." #"?" #"," #";" #":" #""" #""" #"(" #")"]
words: collect [forall words [if words/1 <> "" [keep words/1]]]

bags: copy []
bag: copy []

forall words [
    word: words/1
    if value? 'previous-word [
        if previous-word <> word [
            append bags reduce [length? bag bag/1 ]  
            bag: copy []
        ]
    ]
    append bag word
    previous-word: word
]
sort/skip bags 2
reverse bags

rebolek
13:44@lepinekong_twitter I think block! should work just fine here.
lepinekong_twitter
13:45@rebolek ok thanks. I'm now trying to use collect with parse, we'll come if can't get it :)
rebolek
13:46ok :)
nedzadarek
14:03@lepinekong_twitter
> I feared one cannot use collect here ;)

For your frequency counting, you may use collect but it might not be that easy (or elegant). You have an access to collected collection and keep function. You can do this:
block: ["a" "a" "a" "b" "b"]
 
 collect [
    foreach el block [
        either val: collected/:el [
            f: find collected el
            last-value: f/2
            remove/part f 2
            keep reduce [el last-value + 1]
            
            ; or just:
            ; collected/:el: collected/:el + 1
        ][
            keep reduce [el 1]
        ]
    ]
 ]

but I think collect/keep is not made for this.
I have made [cold](https://github.com/nedzadarek/cold.red) and [one of the examples](https://github.com/nedzadarek/cold.red/blob/master/examples/map-to-append.red) seems close to what you need. It might be **a little* better than basic collect code.
14:11> Is using #() has any special advantage ?

For example you cannot use set-path syntax with blocks: arr: [] arr/void: 'ether but you can use it with maps: m: #() m/void: 'ether. It might be small difference but
> Rebol against complexity
14:12ps. There are few differences between map!, block! and object!.
lepinekong_twitter
14:17@nedzadarek thanks for the collect version will look at it further. Have never used maps yet, since I'm always syntax scared I try to keep my neurons activity low but will see if there are use cases where I really have to :)
14:19I don't understand why my break rules doesn't work. This work (using | to end)

page: read https://medium.com/@preethikasireddy/how-does-ethereum-work-anyway-22d1df506369
parse page [to {<div class="section-content">} copy html to end]
 Collector: parse html [
    Collect
    any [
        thru "<" to ">" skip  keep copy text [to "<" | to "</" | to end]
        |
        thru "</" to ">" skip keep copy text [to "<" | to "</" | to end]
    ]
]
write-clipboard ""
write-clipboard mold :Collector

whereas this doesn't:
14:19
page: read https://medium.com/@preethikasireddy/how-does-ethereum-work-anyway-22d1df506369
parse page [to {<div class="section-content">} copy html to end]
 Collector: parse html [
    Collect
    any [
        thru "<" to ">" skip keep copy text [to "<" | to "</"] break
        |
        thru "</" to ">" skip keep copy text [to "<" | to "</"] break
    ]
]
write-clipboard ""
write-clipboard mold :Collector

hiiamboris
14:24@lepinekong_twitter break returns success from any but then the position after that is somewhere in the middle of the text, and parse returns false because there's no rule to handle the remaining part.
lepinekong_twitter
14:30@hiiamboris yeah but I can't see clear, I just discovered this guy parse-trace but I don't understand what's he's saying to me either can you pinpoint further more :)

-->
   match: [Collect any [thru "<" to ">" skip keep copy text
   input: {<div class="section-content"><div class="section-
   -->
     -->
       -->
         match: [thru "<" to ">" skip keep copy text [to "<" | to
         input: {<div class="section-content"><div class="section-
         -->
           ==> matched
         <--
         match: ["<" to ">" skip keep copy text [to "<" | to "</"]
         input: {div class="section-content"><div class="section-i
         -->
           ==> matched
         <--
         match: [to ">" skip keep copy text [to "<" | to "</"] bre
         input: {><div class="section-inner sectionLayout--insetCo
         ==> matched
         match: [">" skip keep copy text [to "<" | to "</"] break
         input: {<div class="section-inner sectionLayout--insetCol
         -->
           -->
             -->
               match: [to "<" | to "</"]
               input: {<div class="section-inner sectionLayout--insetCol
               -->
                 ==> matched
               <--
               match: ["<" | to "</"]
               input: {<div class="section-inner sectionLayout--insetCol
             <--
           <--
         <--
         match: [copy text [to "<" | to "</"] break | thru "</" to
         input: {<div class="section-inner sectionLayout--insetCol
         ==> matched
       <--
     <--
   <--
 <--
return: false

hiiamboris
14:38parse-trace is quite a beast. Personally I'm avoiding it ☺
lepinekong_twitter
14:58@hiiamboris ah ok I feel less stupid thanks :)
15:39I tried to adapt the example from https://www.red-lang.org/2013/11/041-introducing-parse.html

page: read https://medium.com/@preethikasireddy/how-does-ethereum-work-anyway-22d1df506369
parse page [to {<div class="section-content">} copy html to end]
 Collector: parse html [
    Collect
    [any [
        thru "<" to ">" skip keep (load text) [to "<" | to "</" | to end]
        |
        thru "</" to ">" skip keep (load text) [to "<" | to "</" | to end]
    ]
    ]
]

write-clipboard ""
write-clipboard mold/only collector

it doesn't work:

*** Script Error: text has no value

I don't understand why. I get something that works by mere coïncide as I did a bad copy and paste forgetting to remove copy and that makes this work :

page: read https://medium.com/@preethikasireddy/how-does-ethereum-work-anyway-22d1df506369
parse page [to {<div class="section-content">} copy html to end]
 Collector: parse html [
    Collect
    any [
        thru "<" to ">" skip  keep copy text [to "<" | to "</" | to end]
        |
        thru "</" to ">" skip keep copy text [to "<" | to "</" | to end]
    ]
]

write-clipboard ""
write-clipboard mold/only collector




metaperl
16:35Why do you suppose until has its condition at the end of the block whereas while has it's condition in a block before the looping block?

c: 5
until [
   prin "o"
   c: c - 1
   c = 0    ; the condition to end the until loop
]


c: 5
while [c > 0][
   prin "o"
   c: c - 1
]
hiiamboris
16:43@metaperl how would you rather like it to be?
metaperl
17:09@hiiamboris shouldnt until be setup similar to while:
c: 5
until [c = 0][ blah blah blah]
nedzadarek
17:12@lepinekong_twitter well... what's the definition of text?
@metaperl to be precise, until's blocks are evaluated and the result is checked for "false'y" value.
Rebol has until too. I the guess Red's until was "copied" from the Rebol. I'm not sure why...
hiiamboris
17:13@metaperl I see two reasons why it's not:
1) Simplicity. Instead of discarding the last value of the block you put it to use. And you have only 1 block instead of two. With while you simply cannot do that, that's why while is more complex.
2) Since until checks it's condition *after* the code execution (and always executes it at least once), it's only natural to put it there. Easier to read and analyze.
lepinekong_twitter
17:15@nedzadarek ok thanks I thought I did like in the example but not exactly, will try again.
17:18In rebol 3 it is said http://www.rebol.com/r3/docs/usage/usage-console.html "A script can be interrupted by pressing the ESCAPE key, which returns immediately to the command prompt.", I tried in Red with:

repeat i 1000 [print i]

It doesn't interrupt it. What should I do in the script to detect escape ?
hiiamboris
17:20@lepinekong_twitter It's a known not yet implemented wish. Not much you can do I think.
dander
17:20@lepinekong_twitter @hiiamboris probably related to #3544
hiiamboris
17:21Yep.
17:22I suppose it'll require console to have it's special code for do or something.
rebolek
17:23it will require console port, so I guess it will come with 0.7.0
hiiamboris
17:24How will port help to stop arbitrary Red code? Or it will kill the whole thread executing it?
rebolek
17:25no, it will just break execution, but because it will be running asynchronously, it would be able to catch ESC key event
nedzadarek
17:26@hiiamboris
1) having 2 blocks does not mean that something is more complex. For me, whileis less complex because you can clearly see a condition.
2) then why until cannot just take 2 blocks (until CODE CONDITION)?
rebolek
17:27@nedzadarek you need to look at until more like repeated do than while
hiiamboris
17:27> will just break execution

By killing the thread, correct?
nedzadarek
17:27@rebolek what do you mean?
rebolek
17:28you have do, that will do the block once, until that will do the block repeatedly, until it returns true and forever that will do the block repeatedly
17:28@hiiamboris why should it kill the thread? That would kill the interpreter, I guess.
hiiamboris
17:30@rebolek Yes it will. No big problem to restart it. But how else you can stop arbitrary code in a waiting/deadlocked state? Maybe it executed sleep(99999999) something ;)
nedzadarek
17:31@hiiamboris continuations (I am far from expert on this topic)?
rebolek
17:31@hiiamboris I'm not sure how Rebol is doing it, but I guess it just check for ESC key and then stops evaluation. Maybe you're right, I don't want to mislead you.
nedzadarek
17:35@rebolek So the block returns true... but it can be as well checked in a separate block.
rebolek
17:35@nedzadarek Of course it can and nothing's stopping you from writing my-until that would take two args.
metaperl
17:36I think ask is a better answer [here](https://stackoverflow.com/a/51584459/149741).
nedzadarek
17:36@rebolek Yes, but I wonder if there have been some "bigger" reason to do until 1-argument version.
17:38@metaperl well, then put an answer on the SO.com
rebolek
17:39@nedzadarek As I wort, you need to think of until like an evaluator, similar to do, forever, reduce and others. Then the question doesn't make sense, because all evaluators take just one arg.
nedzadarek
17:40@rebolek ah... I see. Good point.
dander
17:46@rebolek nice explanation. I hadn't thought of it that way :)
rebolek
17:50@dander thanks :)
lepinekong_twitter
19:17what's quote used for ?
help quote
Return but don't evaluate the next value.

Any example ?
19:18@hiiamboris @dander ah ok thanks, meanwhile is there a way to detect escape key in the program so as to order exit ?
dander
19:23@lepinekong_twitter it can be handy for things like this:
>> (1 + 2)
== 3
>> quote (1 + 2)
== (1 + 2)
nedzadarek
20:52@lepinekong_twitter insert-event-func but it's more than what you want.
garthgoldwater
21:52idk if anyone's seen this, but there's an excellent explanation of binding and scoping and contexts on stack overflow that should probably be linked from the red website: https://stackoverflow.com/questions/21964110/is-there-a-overall-explanation-about-definitional-scoping-in-rebol-and-red/21964858#21964858
metaperl
21:52Kindly answer [this](https://stackoverflow.com/questions/54261909/how-to-create-a-series-from-1000-to-9999)
21:52@garthgoldwater - what a name! gold water... I love it.
22:00I need help with a function to form a simple html - tag
22:00simple-tag: func [tag contents][rejoin "<" tag ">" contents ""]
22:01When I try simple-tag "td" "hi there" I get Script Error: rejoin does not allow string! for its block argument
endo64
22:47rejoin "<" is incorrect, rejoin expects a block!
22:48simple-tag: func [tag contents][rejoin ["<" tag ">" contents ""]] works.
AlexanderBaggett
23:06@rebolek , Hey man you helped me with something about a year ago, unfortunately I lost the code for it. Can you show me how to get a list of action! in a way that I could write it to a file.
dsunanda
23:12 Rebolek may have something clever, but this should work:
write %file-name help-string action!
endo64
23:13@dsunanda Your's is much better than mine :)
remove-each word actions: words-of system/words [not action! = attempt [type? get word]]
save %actions.txt new-line/all actions yes
dsunanda
23:23@endo64 Mine would be much worse that yours if it tried to do what yours does....Just writing the actions words....
foreach line split help-string action! newline [append actions: [] first split trim/lines line " "]
save %file-name new-line/all actions yes
AlexanderBaggett
23:30@dsunanda @endo64 , thank you both!
greggirwin
23:34@metaperl if while and until worked the same, as you describe, why have both?

Sometimes it seems like more regularity would be good, but Red is also about expressing intent, and different words and structures let us convey that. Language design is still hard though.

nedzadarek
00:15@greggirwin
> if while and until worked the same, as you describe, why have both?

Well, then, why we need unless?
giesse
01:36@nedzadarek because if not is very common and unless reads better. (At least that was the rationale when it was added to REBOL.) I suppose it does save a tiny bit of time in the interpreter as well.
lepinekong_twitter
02:52@dander thanks.
@nedzadarek is there an example somewhere ? thanks
02:52Very very weird why test2 below is true ?!!!

f: function [][

    test: value? 'any-var ; false as expected
    ?? test
]

f

g: function [][

    test2: value? 'any-var ; Why is it true ?!!!
    ?? test2
    
    any-var: false
    test3: value? 'any-var 
    ?? test3
]

g

metaperl
06:16How do you load code from a file so that it overwrites the code that you previously loaded?
hiiamboris
06:23@metaperl If you mean do/#include then the loaded code is not "written" somewhere, it's evaluated (executed), replacing previously defined word values. Every time.
metaperl
06:26@hiiamboris if I have this file https://github.com/metaperl/red-rosetta/blob/master/html-table.r and I want to invoke red and then load the code into memory, how do I do that?
06:29In a Red program, right after Red there is a block, what is legal to put in that block?
06:30@hiiamboris - I see.. you use do to load code not load
hiiamboris
06:40@metaperl On headers see http://www.rebol.com/docs/core23/rebolcore-5.html#section-2 but Red's own header spec isn't defined yet. Only a few parts like needs: view or config: [..] are used right now.
ne1uno
06:54on windows a few things get added to the executable properties when compiled rights: version: productname: title:
metaperl
06:59How do I get actual newlines in the string I am producing here:
07:00
simple-tag: func [tag contents][rejoin
    ["<" tag ">" newline contents newline "</" tag ">"]]


07:05I want to revise simple-tag so that it takes a single refinement named attr . This refinement takes a block of two strings and creates an html attribute:
simple-tag/attr "td" "td-contents" ["style" "font-weight: bold"]
07:08oh here is the code for simple-tag - https://github.com/metaperl/red-rosetta/blob/master/html-table.r#L35
toomasv
08:45@metaperl Here is one possibility:
simple-tag: function [tag contents /attr spec][
    start-tag: rejoin either attr [
        ["<" tag " " spec/1 {="} spec/2 {"} ">"]
    ][["<" tag ">"]] 
    rejoin [start-tag newline contents newline "</" tag ">"]
]
simple-tag/attr "td" "td-contents" ["style" "font-weight: bold"]
;== {<td style="font-weight: bold">^/td-contents^/</td>}

And here is version with several attributes:
simple-tag: function [tag contents /attr spec][
    start-tag: rejoin either attr [
        collect [
            keep rejoin ["<" tag " "] 
            foreach [atr spc] spec [
                keep rejoin [atr {="} spc {" }]
            ] 
            keep ">"
        ]
    ][["<" tag ">"]] 
    rejoin [start-tag newline contents newline "</" tag ">"]
]
simple-tag/attr "td" "td-contents" ["style" "font-weight: bold" "class" "experiment"]
;== {<td style="font-weight: bold" class="experiment" >^/td-contents^/</td>}

metaperl
14:03Please help with [this](https://stackoverflow.com/questions/54267883/how-did-find-actually-locate-a-character-in-a-string-when-it-was-passed-a-str)
koba-yu
14:26Hi, I have 4 view codes and on the last one, I can not get text drawn.
My code has any wrong points...?

; this draws black text
view/no-wait compose/deep [rich-text draw [
		text 10x10 (rtd-layout [black "test"])
	]
]

; this draws white text
view/no-wait compose/deep [rich-text draw [
		fill-pen 0.0.0
		box 10x10 100x100
		text 10x10 (rtd-layout [white "test"])
	]
]

; this draws red text
view/no-wait compose/deep [rich-text draw [
		fill-pen 246.248.250
		box 10x10 100x100
		text 10x10 (rtd-layout [red "test"])
	]
]

; this does not draw text
view/no-wait compose/deep [rich-text draw [
		fill-pen 246.248.250
		box 10x10 100x100
		text 10x10 (rtd-layout [black "test"])
	]
]


I use latest build on Windows.
toomasv
15:27@koba-yu Seems to be a bug. Please report an issue. This works however:
view/no-wait compose/deep [rich-text draw [
        fill-pen 246.248.250
        box 10x10 100x100
        text 10x10 (rtd-layout [0.0.1 "test"])
    ]
]
koba-yu
15:31@toomasv Thank you for your check and workaround! I'll make an issue.
toomasv
15:38@koba-yu This does also work:
view/no-wait compose/deep [rich-text draw [
        fill-pen 246.248.250
        box 10x10 100x100
        fill-pen black
        text 10x10 (rtd-layout ["test"])
    ]
]
koba-yu
15:44@toomasv Ah, fill-pen affects rich-text...?
toomasv
15:45Yes, but only for black. I guess it is somehow connected to @qtxie's magic of layers.
koba-yu
16:57@toomasv I registered the issue [#3751](https://github.com/red/red/issues/3751). Thank you for your help.
toomasv
16:59@koba-yu :+1: You're welcome!
nedzadarek
21:13@giesse

> because if not is very common and unless reads better. (At least that was the rationale when it was added to REBOL.) I suppose it does save a tiny bit of time in the interpreter as well.

I know rationale of unless constructs. I mean it as an answer to Greg's post.
Why he thinks that having until takes 2 arguments is redundant? We can rationalize it the same as unless.

@lepinekong_twitter I don't know. Let me check my notes.
21:17
view [
    b: base pink "foo"
    do [
      f: insert-event-func [
        if (face == b) [print event/type]
        if not (face == b) [print "not base: " print event/type]
        none
      ]
    ]
]
; remove-event-func :f
lepinekong_twitter
21:21
f: function [][test][

    test: value? 'any-var ; false as expected
    ?? test
]

f

g: function [][test][

    test2: value? 'any-var ; In rebol test2 is false: CORRECT ; in Red it's true: INCORRECT
    ?? test2

    any-var: false
    test3: value? 'any-var 
    ?? test3
]

g

>
21:26This is really annoying as it creates a catch-22 situation.
giesse
22:20@nedzadarek then can you explain why having two arguments for until would read any better or be any faster to interpret?
nedzadarek
22:35@giesse not sure about speed but in my opinion in some cases (I have not explored everything) you can go straight to a condition to see when a loop will run and when it will not.
22:35You get a gist of a loop.
greggirwin
22:39@lepinekong_twitter are you aware that your example above is not valid, because Red's function spec is different than Rebol?
22:42@nedzadarek I've yet to become a fan of unless, though I keep trying.

For me, until *makes you* read the body, which subtly hints that the body will always be executed at least once, which differs from while, where you read the test first, implying that the body may never execute.
nedzadarek
23:31> I've yet to become a fan of unless, though I keep trying.

I guess it's personal preference.

> For me, until makes you read the body, which subtly hints that the body will always be executed at least once, which differs from while, where you read the test first, implying that the body may never execute.

I got that reasoning about "until takes 1 block" but I still don't know why until2 (until that takes 2 blocks) would be redundant.

metaperl
01:57Someone please answer [this](https://stackoverflow.com/questions/54272942/how-to-find-the-first-element-of-a-block-of-strings-whose-first-character-matche).
02:00I would also appreciate an answer to [this question](https://stackoverflow.com/questions/54272956/how-to-increment-element-of-block-after-found-element) as well.
giesse
02:22@nedzadarek let me ask a different way then, can you show me an example of until2 being easier to read than until?
metaperl
02:22I want an answer to [this question](https://stackoverflow.com/questions/54273057/two-dimensional-dispatch-table-with-templated-response) as well as a pony ;)
02:23I should not have started the discussion of until and while here - it belongs in red/red not red/help
giesse
02:23until2: func [code condition] [until [do code do condition]]
02:24@metaperl well, this is how people learn :)
02:26@metaperl on the question, I would use map!, however, someone may argue that nested case 's would be more readable (like the nested if/then's in the given example)
metaperl
02:27@giesse - i have unanswered questions.... let me refresh the Stack Overflow threads.
02:28I dont know what question you are referring to
giesse
02:29@metaperl the one you just posted right above
02:29
>> choices: #("rock" #("rock" "Rock and rock" "paper" "Rock and Paper" "scissors" "Rock and scissors") "paper" #() "scissors" #())
== #(
    "rock" #(
        "rock" "Rock and rock"
        "paper" "Rock and Paper"
        "scissors" "Rock and scissors"
    )
    "paper" ...
>> choices/("rock")/("scissors")
== "Rock and scissors"
>> select select choices "rock" "scissors"
== "Rock and scissors"
metaperl
02:32I wanted the verb between the two weapons....
02:32we already know the two weapons because we indexed into the data structure with them.
02:33actually i'm not thinking about this in the right way
02:34a better strategy would be to write out the answers
02:34
results: [ ["rock breaks scissors" "player"] .... ]


02:35and then do a search ignoring the verb
02:37This is actually even simpler than that... either the game is a draw or the player wins. If neither of those is matched, then the computer wins.
02:45New Red question, hot off the presses! Please help with [this](https://stackoverflow.com/questions/54273161/in-red-how-do-i-search-through-a-block-for-a-string-matching-a-pattern)
gltewalt
02:49Use a case
http://www.rebol.com/r3/docs/functions/case.html
metaperl
03:09I think I can use parse on this somewhat - https://stackoverflow.com/questions/54273161/in-red-how-do-i-search-through-a-block-for-a-string-matching-a-pattern
03:12actually it's even easier than that...
03:27this block is illegal.. man:
player-wins: [
    ["rock" "scissors"] "breaks"
    ["paper" "rock"] "covers"
    ["scissors" "paper"] "cut"
]
gltewalt
04:33Something basic. Could be more DRY.
items: ["scissors" "paper" "rock" "scissors"]

does-player-win?: func [player [string!] computer [string!]][
    if equal? computer player [print ["You tie." tab player computer] exit]
    either equal? computer (select items player) [print ["You win!" tab player computer]][print ["You lose..." tab player computer]]
]

loop 21 [
    does-player-win? random/only items random/only items
]
04:49"scissors cut paper", "paper covers rock", "rock breaks scissors"
04:57Since items is in order of what beats what (scissors cut paper, paper covers rock, rock smashes scissors), and since select returns the
next value after what it finds - if the computer value is equal to the result of using select with the player value, the player value beats the computer value.
06:24Inconsistent formatting with red --cli if I do this:
items: ["scissors" "paper" "rock" "scissors"]

does-player-win?: func [player computer][
    results: [tab "player:" player tab "computer:" computer newline]
    if equal? player computer [print ["You tie." reduce results] exit]
    either equal? computer (select items player) [print ["You win!" reduce results]][print ["You lose..." reduce results]]
]   

loop 10 [
    does-player-win? random/only items random/only items
]
06:25Fine in GUI
GalenIvanov
08:15Hi reducers! I just made my first GitHub commit. The repository is titled "Combinatorics-Red", bit it only covers permutions for now. Please take a look at it and share your comments/recommendations with me.
08:15https://github.com/GalenIvanov/Combinatorics-Red
ne1uno
08:59@GalenIvanov looks good! you could just have a block of precalculated factorials. float! will go a few higher than integer!
GalenIvanov
09:02@ne1uno Thanks! Yes, I need to take care of the factorials.
nedzadarek
11:08@giesse until2 some-code condition => do some-code until condition. Though I would do ... func [condition code] .... Here we assume familiarity with while.
We can even make an operator: until3: make op! func [code condition] [until append code condition]. Which one is more readable:
- i: 0 until [probe i: i + 1 i < 10] or
- i: 0 [ probe i: i + 1] until3 [i > 10]?
hiiamboris
11:45@nedzadarek and what if your code block spans 20 LOCs or more?
nedzadarek
14:17@hiiamboris
First, you have code folding. Secondly, if you do not have that feature, then sure, you have a problem. It is a "what this blocks does" problem. Yes, it is bad thing.
With built-in untilhowever, it would be "I have to understand 20+ lines of code to find out when a loop will stop".
14:38*"what this block does"
hiiamboris
14:58Never used code folding. Can't see any purpose in it.
nedzadarek
15:07@hiiamboris so you either
- keep everything in functions or
- keep everything relatively small?
hiiamboris
15:32@nedzadarek I try to, but even when I can't, or it's someone else's code, the mind always has a map.
nedzadarek
15:56@hiiamboris Then you can create huge maps in your brain - good for you.
AiguyGary_twitter
16:18What is the proper syntax for joining together multiple conditions in an "or" relationship in an "if" statement without brackets I get a syntax error but with brackets it does not evaluate properly for example
if AI/A = "Test5" or AI/A = "Test6" [print "Worked"] generates a syntax error but
if [AI/A = "Test5" or AI/A = "Test6"] [print "Worked"] parses ok but incorrectly acts as if it is true.
16:19I can see the "or" keyword listed in the documentation but there are no examples.
16:30Ok I got it requires the parenthesis not the brackets if (AI/A = "Test5") or (AI/A = "Test6") [print "Worked"]
nedzadarek
16:31@AiguyGary_twitter you can use any:
if any [
    2 = 3
    3 = 4
    42 = 42 
] [
   print 'or
]
or
16:33ps. for "and" you can use all function instead of any.
16:40btw. or and andare not special structures (keywords) but just ordinary functions... op! (infix) to be precise. In most cases they follow normal order:
- function1 val1 operator1 val2
is the same as:
- function1 (val1 operator1 val2)
16:41
add 2 3 * 5
; == 17
(add 2 3) * 5
; == 25
16:42ps. you can group expressions (change the order)by putting them into parenthesis: () like you have done and like in add example above.
giesse
18:59@nedzadarek "I have to understand 20+ lines of code to find out when a loop will stop" - I don't understand this statement. The condition is always at the end.
19:02but maybe your real problem is that until doesn't work that well with code folding?
gltewalt
19:08Any quick ideas on how to wrap the any-function! words in a href using replace?

write %all-functions.html replace/all what/buffer "^/" "

"

toomasv
20:57@gltewalt Hope I understood your wish correctly -- just list of words. (<-s and >-s need to be manually corrected, I don' have time now to play with these):
ws: charset " ^-" 
lg: charset "<>" 
write %all-functions.html rejoin parse what/buffer [
    collect some [
        some ws s: (
            if p: find/part s lg find s ws [
                change p switch p/1 [#"<" ["<"] #">" [">"]]
            ]
        ) :s 
        keep to ws thru lf keep ("<p>^/")
]]
nedzadarek
21:38@giesse
> "I have to understand 20+ lines of code to find out when a loop will stop" - I don't understand this statement. The condition is always at the end.

But a condition might not be in one line. It can span whole until's block. Unless I'm missing something.

> but maybe your real problem is that until doesn't work that well with code folding?

No. Code folding might help but you still have to understand, more or less, whole until's block to understand what until is doing. while on other hand you get gist of it, e.g. while [sum < 10] [complex-code] you get that word sum have to be smaller than 10.
gltewalt
22:10It can’t span the whole block, but I guess a condition could turn true before the end of the block - but that’s on the programmer.
22:11http://www.rebol.com/docs/words/wuntil.html
giesse
22:39@nedzadarek

> But a condition might not be in one line. It can span whole until's block. Unless I'm missing something.

If you write really bad code, sure. Same for while though, while [a] [...] tells you absolutely nothing about the meaning of a unless you read the whole program.
nedzadarek
23:28@giesse bunch of ifs would be such "really bad code"?

while [a] [...] - isn't such code uncommon?
gltewalt
23:40I wouldn’t mind until [condition][code]

PaulBanks
00:21thanks @greggirwin but as great as it is, It's not much use if every compiled Red program keeps being seen as a trojan. #
lepinekong_twitter
10:18@greggirwin that's my point why the function spec has changed ? Because of this change, I have to do ugly syntax:
instead of

unless value? '__DEBUG_MODE__ [__DEBUG_MODE__: false]

I have to do:

__DEBUG_MODE__: false
    if value? in system/words '__DEBUG_MODE__ [
        __DEBUG_MODE__: get in system/words '__DEBUG_MODE__
    ]

when used in a function otherwise I cannot detect that a global __DEBUG_MODE__ has been set: this returns none instead of false:
10:18
f: function[][
	unless value? '__DEBUG_MODE__ [__DEBUG_MODE__: false]
    ?? __DEBUG_MODE__
]
f
__DEBUG_MODE__: true
f

>> f
__DEBUG_MODE__: none
>> __DEBUG_MODE__: true
== true
>> f
__DEBUG_MODE__: none

10:20whereas this will output correct __DEBUG_MODE__:

f: function[][
    __DEBUG_MODE__: false
    if value? in system/words '__DEBUG_MODE__ [
        __DEBUG_MODE__: get in system/words '__DEBUG_MODE__
    ]
    ?? __DEBUG_MODE__
]
f
__DEBUG_MODE__: true
f

>> f
__DEBUG_MODE__: true
>> __DEBUG_MODE__: true
== true
>> f
__DEBUG_MODE__: true

10:25@greggirwin you changed the internal spec aka the implementation but the user spec shouldn't haven't changed because of side effects like above this really doesn't simplify readable code. separating the what from the how is crucial.
Oldes
10:34@lepinekong_twitter function collects set-words... try this instead:
>> f: function[/extern __DEBUG_MODE__][
[        unless value? '__DEBUG_MODE__ [__DEBUG_MODE__: false]
[        ?? __DEBUG_MODE__
[    ]
== func [][unless value? '__DEBUG_MODE__ [__DEBUG_MODE__: false] ?? __DEBUG_MODE__]
>> f
__DEBUG_MODE__: false
>> __DEBUG_MODE__: true
== true
>> f
__DEBUG_MODE__: true
10:34Or just:
f: func[][
    unless value? '__DEBUG_MODE__ [__DEBUG_MODE__: false]
    ?? __DEBUG_MODE__
]
10:37
>> f
__DEBUG_MODE__: true
>> unset '__DEBUG_MODE__
>> value? '__DEBUG_MODE__
== false
>> f
__DEBUG_MODE__: false
>> value? '__DEBUG_MODE__
== true
10:39In this case, you may also use just:
f: does [
    unless value? '__DEBUG_MODE__ [__DEBUG_MODE__: false]
    ?? __DEBUG_MODE__
]
lepinekong_twitter
13:52@Oldes if you use /extern you are setting __DEBUG_MODE__ in the global context that I don't want to. I want to READ from global context not SET global context in f :)
And you cannot just do unless value? '__DEBUG_MODE__ [__DEBUG_MODE__: false] as I said, if __DEBUG_MODE__ has no value in global context it returns none not false.
14:01@rebolek ok I'm not awaken deleted :)
rebolek
14:02Try green tea, it's good at awaking ;)
lepinekong_twitter
14:17@rebolek I don't like coffee nor tea, but you're right I didn't have coke in my fridge any more: I tried to lower my diabete, I'm stuck :)
rebred
15:04
keyp: ""
view [
	size 640x480
	on-key-up [ keyp: ""]
	on-key-down [
	if event/key = 'right [keyp: "right"]
	if event/key = 'down [keyp: "down"]
	]
	img0: image 

    base 0x0 rate 30 on-time [
	if keyp = "right" [img0/offset/x: img0/offset/x + 1]
	if keyp = "down" [img0/offset/y: img0/offset/y + 1]
	]
]
15:04if I press the keys RIGHT and DOWN at the same time it only execute one key
nedzadarek
15:06@rebred
view [
    size 640x480
    on-key-up [ right: false down: false]
    on-key-down [
    if event/key = 'right [right: true]
    if event/key = 'down [down: true]
    ]
    img0: image 

    base 0x0 rate 30 on-time [
    if right and down [print 'both img0/offset/x: img0/offset/x + 1 img0/offset/y: img0/offset/y + 1]
    if right [img0/offset/x: img0/offset/x + 1]
    if down [img0/offset/y: img0/offset/y + 1]
  ]
]
rebred
15:11thank you!
nedzadarek
15:12:+1:
15:18
view [base focus on-key-down [print event/key]]

try to hold one key, e.g. down then while holding that key (down) hold another (e.g. right). The keys are repeated but only the last key is detected:
down
...
down
right
...
right

Is this a limitation of my keyboard (wireless, not something very good, but "ok") , OS (win 8.1 x64) or the Red?
rebred
15:19when I hold any key down after a second I hear "ta ta ta ta ta....." like if there is a buffer that is being filled. I am on OS X
nedzadarek
15:24@rebred I am not sure about device but it might be OS' thing. I remember similar behaviour on my old Windows. If you press a key it will wait a little and pretend as you start repeatedly pressing that one button. I could set some options about this feature.
15:28@rebred https://www.idownloadblog.com/2015/01/14/how-to-enable-key-repeats-on-your-mac/
rebred
15:40it is a RED issue since it happens only when pressing any key in the view window
15:41if I hold down any key in another app, it will not give me the "ta ta ta ta ta..."
15:55
view [
    size 640x480
    on-key-up [ right: false down: false]
    on-key-down [
    if event/key = 'right [right: true]
    if event/key = 'down [down: true]
    ]
    img0: image 

    base 0x0 rate 30 on-time [
    if right and down [print 'both img0/offset/x: img0/offset/x + 1 img0/offset/y: img0/offset/y + 1]
    if right [img0/offset/x: img0/offset/x + 1]
    if down [img0/offset/y: img0/offset/y + 1]
  ]
]
15:56when I hold down either the right or down key I get a "tu tu tu tu tu......" sound
15:56like a keyboard buffer overflow
15:57it doesn't happen when I hold down keys in other apps
nedzadarek
16:08@rebred hmm... I don't have this bug on windows. Maybe it's OSx - specific.
metaperl
16:47Hello, I would appreciate a [code review](https://codereview.stackexchange.com/questions/211884/red-implementation-of-rock-scissors-paper) of this Rosetta Stone problem.
AlexanderBaggett
16:55@rebred , @nedzadarek your icon's are 1 pixel different. That threw me off lol.
nedzadarek
16:56@AlexanderBaggett weird, it's build-in github/gitter icon. They should be the same.
AlexanderBaggett
16:57They aren't you have 1 more central pixel.
nedzadarek
17:01Interesting.
burque505
17:05I'm very new to Red (only a few days), using latest versions from various sources on Windows 7, 64-bit. I have seen reference to loading DLLs for use, but very little (actually, zero) on creating COM objects from Red to interact with Windows programs such as Word, Excel, IE, Acrobat, and so forth. I would also be very interested to know if there is any possibility of using DotNet DLLs, many of which are built non-COM-accessible, from Red. Thanks!
AlexanderBaggett
17:08@burque505 , I do recall a .Net Bridge, albeit one-way letting you open and call .Net stuff from Red. I will look around and see if I can dig it up.
burque505
17:09@AlexanderBaggett, thank you!
AlexanderBaggett
17:09Ah, here we go. I found it.
17:09https://github.com/red/red/tree/master/bridges/dotnet
burque505
17:10Greatly appreciated, I'll have a look right now. Very kind of you.
lepinekong_twitter
17:19No refinement for load to only load body (without header) or how to do it ?

REFINEMENTS:
     /header      => TBD.
     /all         => Load all values, returns a block. TBD: Don't evaluate Red header.
     /trap        => Load all values, returns [[values] position error].
     /next        => Load the next value only, updates source series word.
        position     [word!] "Word updated with new series position."
     /part        => 
        length       [integer! string!] 
     /into        => Put results in out block, instead of creating a new block.
        out          [block!] "Target block for results."
     /as          => Specify the type of data; use NONE to load as code.
        type         [word! none!] "E.g. bmp, gif, jpeg, png."

nedzadarek
17:26@lepinekong_twitter if you mean "I don't want a Red header (Red [...])" then docs says: " /all => Load all values, returns a block. TBD: Don't evaluate Red header.".
burque505
17:39[![bridge-test.GIF](https://files.gitter.im/red/help/uXme/thumb/bridge-test.gif)](https://files.gitter.im/red/help/uXme/bridge-test.GIF)
17:40@AlexanderBaggett , I have tried compiling the examples from the github page, and get the errors in the GIF. Any ideas greatly appreciated!
Phryxe
17:53Maybe try to compile with -r instead of -c ...
lepinekong_twitter
18:19@nedzadarek I mean not at all evaluating it or not, so I don't want this as I can see red[]:

block: {red[] print "hello"}
test: load/all block
?? test
== [red [] print "hello"]

I would like this

[print "hello"]


18:21Theorically there is no keyword, everything can be overrided, it this really true : can I override a directive like #include ;)
burque505
18:22@Phryxe , thanks, I tried that. It compiles, but I get an access violation error. There are other problems I'm dealing with regarding that particular code, though - some paths are hard coded that I needed to change , i.e.
18:23
#system [
	#if dev-mode? = yes [
		#include %../../runtime/platform/COM.reds
	]

which brings me to the next stumbling block, which is that I don't know how to make "dev-mode" true for this code. Also there is a requirement for SharpVector dlls, which seem to have changed since this code was written (different names for sure, don't know about the content).
lepinekong_twitter
18:25@nedzadarek by the way I can't see any difference between load and load/all ?

block: {red[] print "hello"}
test: load block
?? test
== [red [] print "hello"]

burque505
18:28@Phryxe, @AlexanderBaggett, I am encouraged regardless by the fact that COM.reds exists in runtime/platform, and was included as part of red-master. This leads me to believe that somebody, sometime, has created or will at some point create a COM object in Red :)
Phryxe
18:39-c is development mode
burque505
18:45[![clr-search.GIF](https://files.gitter.im/red/help/QEEG/thumb/clr-search.gif)](https://files.gitter.im/red/help/QEEG/clr-search.GIF)
18:45@Phryxe, thanks. Getting a little closer, perhaps - perhaps not.
9214
19:16@burque505 welcome.

.NET bridge is an experimental prototype, and hasn't been touched in a long while. So, problems you deal with are expected, and unlikely to be resolved in a near future, since integration with CLR/JVM is not a priority on project's roadmap.

You can create dynamic libraries with Red/System though, but I don't think that COM ABI is supported, only stdcall and cdecl calling conventions.

Interaction with COM DLLs should be doable, in theory, since Windows backend contains the necessary imports. If you want to contribute and feel confident enough, I'd suggest to wait for a go-ahead from core developers and then experiment with this. But first you should learn a bit of Red :wink:

> I don't know how to make "dev-mode" true for this code

... or you can just use #include unconditionally.
rebred
20:08
view [
	size 700x200 
	img0: image 20x20
	img1: image 20x20
	img2: image 20x20
	img3: image 20x20
	img4: image 20x20
	img5: image 20x20
	img6: image 20x20
	img7: image 20x20
	img8: image 20x20
	img9: image 20x20
	img10: image 20x20
	img11: image 20x20	
	img12: image 20x20
	img13: image 20x20	
	img14: image 20x20
	img15: image 20x20	
	img16: image 20x20
	img17: image 20x20	
	img18: image 20x20
	img19: image 20x20	
]
20:09is there any way to run a loop in the view so I can avoid creating these images manually
burque505
20:27@9214 : thanks.
toomasv
20:34@rebred
append/only [view] append [size 700x200] new-line/skip collect [
    repeat i 20 [keep reduce [to-set-word rejoin ["img" i - 1] 'image 20x20]]
] true 3
rebred
20:46that's great! what does true 3 do
nedzadarek
20:49@lepinekong_twitter
Here is from load's help:
/header => **TBD**.
/all => Load all values, returns a block. **TBD: Don't evaluate Red header.**

So, it's TBD(To Be Done - this feature will be in the newer versions... at least it should).
20:57@rebred that's why proper indentation, parenthesis or putting into many readable variables/words in the "how to" code is important.
Especially for new people. Let me rephrase it:
block-with-images: collect [
    repeat i 20 [keep reduce [to-set-word rejoin ["img" i - 1] 'image 20x20]]
]
append/only [view] (
   append [size 700x200] (new-line/skip block-with-images true 3)
)

ps. Naming is one of the hardest thing in the programming... sorry for bad names.
rebred
21:08great thank you!
lepinekong_twitter
21:58@nedzadarek for me /header it will load header only ? it's the contrary I want: /body ;)
22:01compose/deep "spoils" mold: mold allows to keep block format nice, but if you just want to use variable with compose/deep everything spoilt, how to save the situation :)

~header: mold/only [Red [
    File: %snippet.8.red
    Title: "testing macro include"
]    
]
>>print ~header
Red [
    File: %snippet.8.red 
    Title: "testing macro include"
]

~output-file: %snippet.8.red
~header: mold/only compose/deep [Red [
    File: (~output-file)
    Title: "testing macro include"
]    
]
>>print ~header
Red [
    File: %snippet.8.red Title: "testing macro include"
]

22:17finally found it:

~header: mold/only compose/deep [Red [
    File: (~output-file)
    new-line
    Title: "testing macro include"
]

nedzadarek
22:18@lepinekong_twitter what I got from this doc is that in the future load will not load header & load/all will load header.
22:19Or something like this. One thing is certain - you will have an option to turn on/off loading of header.
rebolek
22:26@lepinekong_twitter this has nothing to do with neither mold nor compose.
lepinekong_twitter
22:29@nedzadarek ah ok that's more logical thanks.
22:32@rebolek whatever I just want get the things done, it is a pity that change is not incremental just because you want to use a variable, compose/deep should have a mold refinement or something. By adding new-line I get something like this (the args are obscure in help so I'm pretty sure the values I passed are not right but I get something :)

Red [
    File: %snippet.9.red new-line 
    Title: "testing macro include" 
    new-line 
    Test: "3rd line"
]

rebolek
22:33> whatever I just want get the things done

That's where we differ. When I want to get things done, I want to understand how they work and why they work the way they work.
lepinekong_twitter
22:34@rebolek one can understand when there is correct help. There's nothing on new-line.
rebolek
22:35@lepinekong_twitter I wouldn't call this nothing:
>> ? new-line
USAGE:
     NEW-LINE position value

DESCRIPTION: 
     Sets or clears the new-line marker within a list series. 
     NEW-LINE is a native! value.

ARGUMENTS:
     position     [any-list!] "Position to change marker (modified)."
     value        [logic!] "Set TRUE for newline."

REFINEMENTS:
     /all         => Set/clear marker to end of series.
     /skip        => Set/clear marker periodically to the end of the series.
        size         [integer!] 

RETURNS:
     [any-list!]
22:35Reading help and experimenting helps, trust me.
22:36
>> block: [a b c]
== [a b c]
>> head new-line next block true
== [a 
    b c
]
lepinekong_twitter
22:39@rebolek something as obscure as "le marc de café" (dark as coffee grounds) as we say in french and I'm not alone to tell this ;) :
"The language is brilliant, elegant and powerful, but it has its share of gotchas and OBSCURE OR POOR DOCUMENTED FEATURES..." http://www.pat665.free.fr/doc/bind.html
22:42@rebolek your example is a bit clearer thanks
rebolek
22:44You may not be alone, but that doesn't make you right. Actually, the problem you've described above is something that I think should be reported, but only when properly isolated. It's not a problem with compose or mold, but it's something else, see this code:
Red[] 
 
header1: [Red [ 
    File: output-file 
    Title: "testing macro include" 
]     
] 
header2: [Red [ 
    File: (output-file) 
    Title: "testing macro include" 
]     
] 
 
probe header1 
probe header2 
print ""

22:44It returns:
22:46
>> do %test.red
[Red [
    File: output-file 
    Title: "testing macro include"
]]
[Red [
    File: (output-file) Title: "testing macro include"
]]
22:46So the new-line marker is lost after paren!.
lepinekong_twitter
23:08@rebolek I'm not saying there is a problem, I'm saying there are some use cases like this that should have a more incremental way of doing when you iterate through a solution, you like to be able to build it by natural step and not suddenly has to rewamp the whole architecture of your code. So the most incremental way I found is for example to use build-markup in this case:

~output-file: "%snippet.13.red"
~header: [Red [
    File: <%~output-file%>
    Title: "testing macro include"
    Test: "3rd line"
]    
]

~header: build-markup mold/only ~header

though with current build-markup implementation I cannot use expression so I have to use "%snippet.13.red" and not %snippet.13.red it's still a small inconvenience compared to change everything and make the code less readable (which is my number 1 criteria between several solutions).
23:12@rebolek now I have other cases where I will use new-line because it will be natural to use it ;)
rebred
23:27why print to-integer 1.9 gives 1 and not 2 ?
dsunanda
23:50Red follows the same conventions as Rebol with to-integer - ie [Conversion from decimal! will be truncated towards zero](http://www.rebol.com/r3/docs/datatypes/integer.html)
(With a change in terminology between the two languages .... Red uses float! where Rebol uses decimal!)
nedzadarek
23:54@rebolek @lepinekong_twitter It seems that some (all?) changes removes new-line markers:
>> arr: [
[    a]
== [
    a
]
>> arr
== [
    a
]
>> change arr 'b
== []
>> arr
== [b]

metaperl
00:26No one seems to be in a hurry to provide a code review [for me](https://codereview.stackexchange.com/questions/211884/red-implementation-of-rock-scissors-paper) :)
PaulBanks
01:05So, no answer ? - what's the plan to deal with the AV problem - all you guys are very clever, but what's the use of it, what's the point if compiled programs are seen as trojans ? - it ends up being a hobbyist language. just good for amateur projects. I get this head in the sand feeling ?
ne1uno
01:09@PaulBanks try suggested upx? not all anti virus have the problem. check virus total
estoniah
01:16If a value has a component(indirect type) with a loop pointer, what happen at copy/deep?
PaulBanks
01:18@ne1uno thanks, yes have used upx and of course virus total - although upx does help a little, there's still AV's flagging us as bad. not good
9214
03:23@metaperl people here help others on volunteering basis, so show some respect and bide your time. After all, you (and your code) aren't more special than any other newbie in this room.
03:33@PaulBanks the plan is to deal with this issue. The best you can do is:

* keep reporting false positives to vendors;
* refrain from accusations and escalation of drama - I get that this situation is annoying, but you are not alone in it; framing Red as a "hobbyist language" utterly dismisses all the hard work been put into it.

More importantly, and this concerns everyone who has problems with AVs - if you want to help, contanct @greggirwin and ask what can be done. There's no clear technical solution to this problem, and resolving it fully will likely involve a lot of politics and mass-movement from community side. Core team can't afford time and resources to this right now. If you plan to stay vocal with regard to this issue, at least do so in a proactive manner.
03:38@estoniah I don't understand what you mean by "loop pointer", but indirect values get their buffers copied with copy, from index offset up to tail. copy/deep does that for all nested indirect values that support copying, again from index to tail.
endo64
07:33When I compile below script as red -t MSDOS -c test.red and then execute on CMD, there is no output.
If I compile it with -r then it works. Is it a regression (I'm on Win10 x64)
Red [] print "ok"

hiiamboris
08:26@endo64 can you try red -u -t MSDOS -c test.red ?
9214
09:37@endo64 https://github.com/red/red/issues/3221
hiiamboris
10:24@9214 I think his issue is different. Likely using the older .dll. As to #3221 IIRC in Windows there are 2 hardcoded types of executables (CLI and GUI) which are even started in a different manner and have these types embedded into the binary header. To do what you wish you can however make a GUI executable that will conditionally attach to it's parent process' console with [AttachConsole](https://docs.microsoft.com/en-us/windows/console/attachconsole) call and print the output there.
9214
10:42Yeah, I already know that.
nedzadarek
11:13Everyone talks about anti-viruses but I haven't seen anyone talks about Windows' (8.1 in my case) SmartScreen. Every time I download & run new red.exe SmartScreen tells me it "blocked an application". I can click "more information" and run it. It my put some people off. Will this be fixed in the 1.0 version?
11:14ps. I don't have English version so translation my be "little wrong".
hiiamboris
11:15My W8.1 asks me that every time I recompile some script and run it :) Gotta turn this crap off, you've just reminded me...
nedzadarek
11:19@hiiamboris I don't usually compile stuffs but I don't remember SmartScreen appearing.
hiiamboris
11:34Idk about SmartScreen. To be precise, I have had an annoying dialog every time I start smth from a network drive (internet policy) + Windows Defender aggro on Red binary, so now they both go where they belong...
lepinekong_twitter
11:55@nedzadarek yes thanks.
11:59@nedzadarek I think I can compensate easily for lack of load/header with:

header: reduce ['Red select source 'Red]
    body: remove remove (copy source)

nedzadarek
12:39@lepinekong_twitter
>> bl: [a b c red 42]
== [a b c red 42]
>> select bl 'red
== 42

Isn't Red [..] the first thing in a script? If yes can't you just (in order to load a body):
1) load script
2) if first element is Red then skip 2 elements (Red and a block)
3) else do nothing
12:41btw. remove/part "abcd" 2 ; == "cd"
Or just skip [1 2 3 4] 2 ; == [3 4] - but it's the same block with just different position.
lepinekong_twitter
12:50@nedzadarek yeah ok that's simpler you know I'm not good at syntax I just know what I want to do :)
12:53@rebolek so below I use new-line in a function that tries to do true include when script is not compiled (with expand-directives), it helps including a newline before inclusion. But then load removed all other newlines, I doubt there is a solution for that latter ?
https://i.imgur.com/hbwGsNY.png
rebolek
12:55@lepinekong_twitter Unfortunately I'm not sure what I'm looking at.
lepinekong_twitter
12:55 @rebolek I updated
rebolek
12:56I see one difference in compare-checksum functions that is easy to fix. Is there anything else?
lepinekong_twitter
12:58@rebolek on the left side I have a build script that expand-directives in copy-files.1.red on the bottom-right which macro includes the file compare-checksum, in final I get final copy-files.1.red on left-bottom with the file included.
12:59Why does it introduce tabs also by the way: formatting code is weird.
13:00@rebolek I have created this §include macro since red #include for interpreted script doesn't only translate to do command.
rebolek
13:00I see.
13:01But where's a problem?
13:06The included code looks basically the same.
13:06And the formatting is just something for user, if everything was on one line, it would work the same.
lepinekong_twitter
13:08@rebolek the problem is I want keep nice code formatting when I open it in vscode :)
rebolek
13:09@lepinekong_twitter I understand that, but there's just one easily fixable difference, AFAICT.
lepinekong_twitter
13:10The tab can be easily removed, but reinserting the original new lines are not.
13:11@rebolek but that's still ok, I just wanted to know if that would be possible ;)
rebolek
13:12detabbing is easy, but what you mean by reinsterting original new lines? They are same (with one exception).
13:13Anyway, you probably shouldn't do this on data level, because that's very complex problem. Why don't you just take the snippet as text and insert it into another text?
lepinekong_twitter
13:13@rebolek if you look the bottom files in https://i.imgur.com/hbwGsNY.png, the one on the left has been compacted with no "breath": all blank lines have been gone.
rebolek
13:14Ah, I understand now, thanks!
13:14I was looking just at the compare-checksum code.
13:14OK, so that's definitely not something you can do at data level.
lepinekong_twitter
13:15@rebolek ok thanks for confirmation I won't lose time trying to do it :)
rebolek
13:15If you load text as data, you also lose comments for example.
nedzadarek
13:27Can parse easily get whole expression? I am not sure how it is called. For example:
f: func [a] [a * 10]

parse [ 'foo 'baz 'bar my-keyword probe f 2 + 3  42 print "something" 'blah ] [copy a ['my-keyword SOME-RULE] ]

and I want a to be [my-keyword probe f 2 + 3].
I am considering restricting to restricting syntax to my-keyword SINGLE-VALUE if the above task would be "not so easy". SINGLE-VALUE is something like series (e.g. paren, block), get/set/lit-words, integers/floats ... something like any-type! as fair I can see.
rebolek
13:40Are you trying to reimplement Red in parse? :smile:
13:41> Can parse easily get whole expression?

That depends on what *expression* means in your dialect.
nedzadarek
13:48@rebolek
> That depends on what expression means in your dialect.

Like in the Red, if you can set it to a word, then it is an expression. One exception, as fair I remember, are unset! values (e.g. print 42).

13:49> Are you trying to reimplement Red in parse?

I am just changing one word and an expression... and that might be "reimplementation of the Red".
rebolek
14:14f 2 + 3 can be f f 2 + 3, f f f 2 + f 3 \...
nedzadarek
14:48@rebolek yes
lepinekong_twitter
17:56@rebolek I'm roughly pleased of the result even with these unwanted tabs it's acceptable :)
https://redlang.red/img/include-macro-example.png
https://redlang.red/include
rebolek
18:19@lepinekong_twitter :+1:

c61292558
03:07how can I read and open CAD(.DWG,DXF etc.) file with it?
on linux
i have no idea,
thanks
greggirwin
03:28@c61292558, @Oldes answered you [here](https://gitter.im/red/red?at=5c456628c45b986d11945ad7). Red doesn't (and has no plans to) natively support those formats.
03:29If someone (like you) needs to work with those formats, they'll need to write the code themselves, which is a big task, but should be doable.
c61292558
09:53Oh.....,I know,thanks.
09:53but ...can u give some guides to write the code ?
09:54@greggirwin
rebolek
09:55Well you would need to write parser for such file (and as Oldes wrote, it's proprietary format, so it won't be easy) and then convert the data to Draw dialect. It's going to take months to years, I guess.
c61292558
09:59wow~..so it is
09:59thanks @rebolek
rebolek
10:00@c61292558 I don't want to discourage you, but it's very complex task.
10:01> From 1982 to 2009, Autodesk created versions of AutoCAD which wrote no fewer than 18 major variants of the DWG file format,[7] none of which is publicly documented.
c61292558
10:03but why there are many cad file viewer softwares on the internet?
dsunanda
10:03@c61292558 Thereare existing tools and services to convert .dwg to other formats - eg .svg - depending on what you are trying to do, that may be enough. Or at least a better starting point for what you want to do in Red.
c61292558
10:05tools on linux platform??
10:06not yet seen @dsunanda
10:14by the way,have anybody developed some 2d games with RED?
rebolek
10:40I've seen few simple ones, but I don't have any links here unfortunately.
snotbubble
10:40@c61292558 have a look at Houdini's iconvert for converting geometry
10:43@c61292558 crap sorry that's gconvert… iconvert is for images. [link](www.sidefx.com/docs/houdini/ref/utils/gconvert.html)
hiiamboris
11:16@c61292558 you can find some games in [this list](https://github.com/red/red/wiki/[LINKS]-Scripts-collection)
endo64
11:18Here a few simple games you can find: https://github.com/red/community/tree/master/games
rebolek
11:18 @endo64 @hiiamboris thanks for links
hiiamboris
11:21There's also a cool match3 game buried somewhere in the logs of [red/gui-branch](https://gitter.im/red/red/gui-branch)
endo64
12:46This one? https://github.com/cryptowyrm/red-scripts/blob/b73df82d654ad65ced5f4f6e370e2bad905023f1/match3.red
hiiamboris
12:55yep!
qtxie
13:12@c61292558 Here are two games.
https://github.com/hyzwhu/red-2048
https://github.com/hyzwhu/redbox
13:14[![g4.gif](https://files.gitter.im/red/help/lC9w/thumb/g4.gif)](https://files.gitter.im/red/help/lC9w/g4.gif)
13:16[![1.gif](https://files.gitter.im/red/help/8S4U/thumb/1.gif)](https://files.gitter.im/red/help/8S4U/1.gif)
endo64
14:33@qtxie Redbox! Great game! Thanks
9214
14:56IIRC it's a direct port of [ReBOX!](https://www.softinnov.org/rebol/rebox.shtml) from Nenad :wink:
endo64
15:12Yes, there are issues like walking in the walls etc. but shouldn't be hard to fix.
15:12Oh and 2048 works great :)
15:13[![image.png](https://files.gitter.im/red/help/wJ5y/thumb/image.png)](https://files.gitter.im/red/help/wJ5y/image.png)
nedzadarek
15:30Can excessive printing to the gui-console cause gui crash?
15:31cli-console seems fine.
c61292558
16:57thanks a lot!I research it immediately
rgchris
17:37How does Red define font size? Cursory tests give me slightly different results from e.g. browser sizing.
>> layout [some-text: text "Some Text" font-size 25]
== make object! [
  ...
>> size-text some-text
== 149x39

What is the relationship between the 25 and 39 here? (am using [this](https://iamvdo.me/en/blog/css-font-metrics-line-height-and-vertical-align) as a primer in font metrics and terms)
17:41*(can move to GUI branch as needed)*
hiiamboris
17:44@rgchris google for "em height" - that will be the 25 value, or 25pt
39 is Red's logical pixels which are normal pixels multiplied by the system/view/metrics/dpi / 96
rgchris
17:48So Red's font size is not in Red's logical pixels?
hiiamboris
rgchris
17:49Is there a reference for that?
hiiamboris
17:49Also be aware that there are at least 3 font metrics used by size-text on Windows, and all of them give different results: :point_up: [January 13, 2019 1:22 PM](https://gitter.im/red/red/system?at=5c3b116ac45b986d1152c05d)
I suspect on other platforms the results will also be different
17:50> Is there a reference for that?

reference for what?
rgchris
17:51Documentation.
hiiamboris
17:52Only the code: https://github.com/red/red/blob/master/modules/view/backends/windows/font.reds#L102
https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/nf-wingdi-createfonta
rebolek
17:53It’s like in the OS, where font size 12 doesn’t mean 12 pixels too.
rgchris
17:58@rebolek Understood. I'd make a case for sticking with Red's coordinate system for such sizes, but that'd be for another day. Just trying to get some calculations right for now.
18:01@hiiamboris Which of the metrics are used on other platforms? I'm primarily concerned with correlating Red's font-size 25 with SVG's font-size="25" (which is based on it's internal coordinate system, not points).
mpchean
18:03Hi: I want to give my boss an executive overview of Red. Does anyone know of something like this?
dander
18:15Someone made a nice tetris clone too, but I can't seem to find it. Maybe someone else remembers where it is?
hiiamboris
18:27> @hiiamboris Which of the metrics are used on other platforms? I'm primarily concerned with correlating Red's font-size 25 with SVG's font-size="25" (which is based on it's internal coordinate system, not points).

@rgchris It will be 25pt on every OS, just different rendered sizes in pixels.
rgchris
18:27@hiiamboris My local DPI shouldn't matter as Red's pixels should always account for that, thus a point should always be 1.5px (according to Red's—presumably by your 96 multiplier above—96ppi coordinate system). Thus 25 * 1.5 => 37.5—even rounded up is less than 39.
hiiamboris
18:28But 96 / 72 is not 1.5, it's 1.333, you can't compare 39 and 25, because as the MS docs say:
> The character height value (also known as the em height) is the character cell height value minus the internal-leading value.

I've no idea what internal leading value is, but I bet it's out of your control
rgchris
18:30Ah, right—this is messing with my brain. Ok, so checks...
18:31@hiiamboris Should be dependent on the font descender/ascender, no?
18:32Which does sort-of correlate to my results. Yes!
hiiamboris
18:36Your guess is as good as mine ;)
rgchris
18:36(I have a font with em-size: 2048, ascender+descender: 2441 => 2441.0 / 2048 * 25 * 4.0 / 3 => 39.72981770833334 => rounded down to 39)
9214
18:43@mpchean well, you can start by reading info on the official website.
18:48@dander that was @hiiamboris' [Retris](https://gitlab.com/hiiamboris/retris).
hiiamboris
18:51Yeah, and it's on the list. Not a total newbie's stuff though.
endo64
19:05@mpchean About page is a good place for that: https://www.red-lang.org/p/about.html
rgchris
19:20Here's the context of the text I'm trying to measure:
19:20https://gist.github.com/rgchris/5212462e9d996a3fa3dbfcc2be196205
19:20(cc. @hiiamboris)
19:21As you may be able to tell, it doesn't quite line up.
19:22(may need to change font-family based on available fonts)
19:24Scratch that—does appear to work : )
hiiamboris
19:33Cool. Tried other font families?
rgchris
19:39@hiiamboris Yup!
19:45Even works with [different families on different lines](https://gist.github.com/rgchris/5212462e9d996a3fa3dbfcc2be196205) : )
hiiamboris
20:00:+1:
gltewalt
20:51Not sure how to handle this problem.

Say that there is a hash [a 0 b 2 c 5] and I pick hsh random 6
If pick returns one of the words, all good.
If pick returns one of the integers, get the previous element.
9214
20:59@gltewalt in other words, you want to pick only elements at odd indices?
pick [a 0 b 2 c 3] mod 1 or random 6 6
gltewalt
21:00I was doing mod 1 random 6
9214
21:02oring with 1 will always give an odd number. Taking modulo will ensure that this random odd number doesn't overflow the length of series (max value here is 7).
21:03You could subtract 1 instead, but that may give you 0.
gltewalt
21:05Yeah, need to avoid 0
9214
21:07
text
>> odd: function [x][pick x mod 1 or random length: length? x length]
== func [x /local length][pick x mod 1 or random length: length? x length]
>> loop 50 [append [] odd [a 0 b 2 c 3]]
== [b c b c c a c c a b c b b b b c a c b b a c a c a b b b c c a a b b c b c a a c a c b b b c c a a a]
gltewalt
21:09The new fastest 🐁 in all mexico
nedzadarek
21:21@9214 about your [memoize.red](https://github.com/9214/whatnot/blob/master/red/memoize.red):
You run it like this:
fib: func [n] [
     either  n < 2 [
        return n
    ] [
        return ( (fib (n - 2) ) + (fib (n - 1) ) )
    ]  
]
fib-memo: memoize :fib
fib-memo 10

Am I right?
9214
21:35It takes a function and returns its memoized version.
>> fib: memoize func [n][either n < 2 [n][add fib n - 2 fib n - 1]] :...
>> fib 42
== 267914296
nedzadarek
21:42@9214 thank you

lepinekong_twitter
00:09I can override any native word except do: is there a trick to mitigate the stackoverflow I get with:

unless value? 'sysdo [
    sysdo: :do
    do: function [
        {Evaluates a value, returning the last evaluation result} 
        value [any-type!] 
        /expand "Expand directives before evaluation" 
        /args {If value is a script, this will set its system/script/args} 
        arg "Args passed to a script (normally a string)" 
        /next {Do next expression only, return it, update block word} 
        position [word!] "Word updated with new block position"
    ][

        ~const>refinements: [
            expand args next
        ]

        ~command: copy []        
        ~refinements: copy ""          
        foreach ~word>refinement ~const>refinements [
            ~refinement: (get ~word>refinement)
            if ~refinement [
                ~~refinements: rejoin [~~refinements form ~word>refinement]
            ]
        ] 

        ~main-command: copy "sysdo"

        unless ("" = ~refinements) [
            append ~main-command "/" 
        ]
        ~main-command: rejoin [~main-command " " ~refinements]     

        ~command: to block! ~main-command
        
        append ~command compose [(value)]

        if args [
            append ~command to-word 'arg
        ]
        if next [
            append ~command to-word 'position
        ]   

        sysdo ~command               
    ]  
]      

do [print "hello"]


*** Internal Error: stack overflow
*** Where: unless
*** Stack: do do do do do do do do do do do do
do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do do


nedzadarek
01:22@lepinekong_twitter I am curious - why do you want to override one of the most important build-in word?
gltewalt
01:44Suggestions?

https://gist.github.com/gltewalt/c74c416662aba72991d90599d5299c17
01:48About games... make this game:
“Percy the Parse 🐭 Finding his way to end of mazes to collect RedCoins.”
BeardPower
10:45@gltewalt Post the game design :-)
10:49Why are you complicating the weight-based random selection so much? Just use percentage weights [10 40 50] and compare the output from random 100% to the weights.
rebolek
11:05I'm using (random 1.0) ** n, but that's not for discreet values.
nedzadarek
11:46@gltewalt
> Say that there is a hash [a 0 b 2 c 5] and I pick hsh random 6
If pick returns one of the words, all good.
If pick returns one of the integers, get the previous element.

You are picking only half of a series (/ 2) and you are picking every 2nd element (2 *; 2nd, 4th, 6th...). In first case you have to shift number (-1):
hsh: [a 0 b 2 c 5]
hsh/((2 * random ((length? hsh) / 2)) - 1)
 
hsh: [0 a 2 b 5 c]
hsh/(2 * random ((length? hsh ) / 2) )
11:54ps.
sum-history: does [history/scissors + history/paper + history/rock]
; ...
get-weighted-value: func [hsh [hash!] /local rnd][ 
    rnd: random sum-history  
   ; ...
]

So you are storing history of your previous events. That is not random (I am not talking about machines not being able to make random number also known as "pseudo-randomness") but it makes games better if done right. I have to analyze it. Interesting!
BeardPower
12:45@rebolek Which still can be represented as a percentage.
NjinN
13:04Two games
https://github.com/NjinN/Recode/tree/master/Red/gobang
https://github.com/NjinN/Recode/tree/master/Red/flappyBird
13:05[![gobang.gif](https://files.gitter.im/red/help/pHXw/thumb/gobang.gif)](https://files.gitter.im/red/help/pHXw/gobang.gif)
13:06[![flappybird.gif](https://files.gitter.im/red/help/9IfN/thumb/flappybird.gif)](https://files.gitter.im/red/help/9IfN/flappybird.gif)
lepinekong_twitter
13:33@nedzadarek I just want to set system/options/script to the script it will do because location, location, location is of utmost importance also in programming ;) in other languages like powershell or nodejs you can know the current executing script, you can't in red.
13:36@nedzadarek for example, this would avoid to have to look inside script production.red to realize you have to do system/options/script: clean-path %production.red before calling it
do https://redlang.red/cd.red

cd ../build
do %gen-html-content.red
cd ../ci
do %copy-html-to-design.red
cd ../../design
cd build
do %gen-html-page.red
cd ../ci
system/options/script: clean-path %production.red
do %production.red

rebolek
13:40> you can't in red.

Right. But unlike Powershell or node.js, Red is still in alpha, so some features are not implemented yet.
BeardPower
13:41@NjinN Nice!
hiiamboris
13:44@NjinN Great indeed! :+1:
BeardPower
13:44Red has flappy bird. What else could go wrong now? ;-)
hiiamboris
13:44Btw you can procedurally generate the biggest part of https://github.com/NjinN/Recode/blob/master/Red/gobang/Gobang.red
planetsizecpu
13:47@NjinN 👍
hiiamboris
13:51In https://github.com/NjinN/Recode/blob/master/Red/flappyBird/mci-cmd.red you don't have to import malloc and free, just use make-c-string instead of malloc and free as byte-ptr! ... in place of your free.
13:54Or use https://static.red-lang.org/red-system-specs.html#section-13.7 and be free of dynamic allocations ;)
lepinekong_twitter
14:03@NjinN great :) can't flappy bird run in non-compiled version ?
endo64
14:04@lepinekong_twitter As it uses some R/S, it cannot.
14:05But I think is uses R/S only for sound, so can be disabled to make it work in REPL.
lepinekong_twitter
14:06@endo64 ah ok thanks, would be really really really great if R/S could work IN THE FUTURE without compilation ;)
nedzadarek
14:42@lepinekong_twitter
Why it has to be do. Why not my-do( insert-your-name-here) or your-package/do? I would understand if it was some binding (e.g. arr: bind [do [2 + 3] ] context [do: func [a] [prin mold a print ":" print mold system/words/do a]]). You can use your own function, e.g.:
my-do: function [a] [
  do-value: do a
  system/options/script: clean-path %production.red
 return do-value
]
my-do %path/to/file

In my opinion it makes code more readable because it will tell an user that my-do will do something that might or might not be like build-in do. Imagine few people were able to redefine do. Every person redefined in his do max stack size (let's pretend it's possible - I haven't checked it). By changing an order of loading file you would make some programs working or not working.
ps. of course it depends on your purpose.
14:45@hiiamboris do you mean [this panel](https://github.com/NjinN/Recode/blob/master/Red/gobang/Gobang.red#L73) (about procedurally generation of the biggest part)?
lepinekong_twitter
14:45@nedzadarek I have already done .do so my question is about fundamental: why can't I override do since in official doc it is said I can override any word ;)
nedzadarek
14:51@lepinekong_twitter I think you can but you have to be careful because some core part of the Red depends on do. Here is my try:
old-do: :do
a: 0
do: function [value /expand /args arg /next position /extern a][
       a: a + 1
       old-do value
    ]
 
3 ; == 3
a ; == 28
a ; == 39
do [2 + 3] ; == 5
print a do [2 + 3] print a
; 699
; 700
14:52ps. of course **be careful** with this
NjinN
15:04@hiiamboris Thanks, still need to learn more about R/S.
hiiamboris
15:59@nedzadarek that's right
16:00these games are so great, I'm going to add them to the showcase..
lepinekong_twitter
16:35@nedzadarek huh yours works why mine doesn't I'm jealous ok thanks I'll retry :)
nedzadarek
17:04I have updated [memoization code](https://github.com/nedzadarek/Red-Memoi/tree/recursion) to support recursive functions. See [test](https://github.com/nedzadarek/Red-Memoi/blob/recursion/tests/recursive_fibonacci.red) for more info (I have put edited main into separate file - it will be merged in the future - I need to check things (the Red and Github related) first).
17:05ps. I haven't updated old test but it seems fine - I will do it in this week.
lepinekong_twitter
17:07I don't understand the basics of do/next, why do I get 1 instead of 3:

>> do/next [1 (1 + 2)] 'test
== 1
>> test
== [(1 + 2)]

nedzadarek
17:10@lepinekong_twitter
> Do next expression only, return it update block word.

It will evaluate next expression. A next expression is the first "expression" in a series. In your case it's 1.
lepinekong_twitter
17:14@nedzadarek but in help it says: Do next expression only, return it, update block word: why does it update test with 1 + 2, why says next since it's the default ? What's the use case of having next :)
17:16@rebolek Red is not so young if you add Rebol age ;)
rebolek
17:20@lepinekong_twitter right, Red can build on years of Rebol's design. However everything is reimplemented from scratch, so Rebol's maturity doesn't help a bit there. Especially because Rebol is written in C and Red in Red/System.
lepinekong_twitter
17:22@rebolek self script path is very fundamental core feature if it has never been implemented in the first place I doubt it'll ever be seeing the pile of other stuffs you have :)
nedzadarek
17:25> huh yours works why mine doesn't I'm jealous ok thanks I'll retry :)

My code is very simple. In your case I would make mistakes too.

> why does it update test with 1 + 2

It doesn't update it with (1 + 2). It set position to the position after evaluation [(1 + 2)] (head would be [1 (1 + 2)]).

> why says next since it's the default ? What's the use case of having next :)

You can iterate over expression, add some data, print something etc. For example:
line: 0
src: [ 1 + 2 3 + 4] 
while [not tail? src] [ 
        line: line + 1
        prin ["Expression" line ": "]
        probe do/next src 'src
]
; Expression 1 : 3
; Expression 2 : 7
17:26I think someone used it for error/debugging (just a prototype).
mpchean
19:11@9214 @endo64 thank you.
rebolek
19:41@lepinekong_twitter
> self script path is very fundamental core feature...

I don't doubt it, you're right. However, there's a ton of fundamental core features unfortunately.
lepinekong_twitter
19:48@rebolek this one (self script path) is fundamental of fundamentals ;)
19:48When chaining functions, how do I explain that I need to use (...) in this case:
do https://redlang.red/popup ; load popup library
popup (ask "message: ")


but not in this case:
f: function[x][x + 1]
g: function[x][x * 2]
g°f: function[x][g f x]
r: g°f 2
?? r

rebolek
19:53@lepinekong_twitter I don't doubt that it's fundametal of fundadentals, but remember that few month ago Red hasn't got GC, still hasn't module system and I/O is a thing that is currently being in the work. And system/options/scriptis something that anyone can contribute.
lepinekong_twitter
20:00@rebolek I can't see how since you need access to modify Red core that's why I try to modify do.
20:02@rebolek it's a question of prioritization, for me it should go on the super top of the pile, because ;)
“If you do not know where you come from, then you don't know where you are, and if you don't know where you are, then you don't know where you're going. And if you don't know where you're going, you're probably going wrong.”
https://www.goodreads.com/quotes/412254-if-you-do-not-know-where-you-come-from-then
20:06even the dos dinausore has it so https://ss64.com/nt/syntax-args.html should modern red shouldn't she ;)

You can get the pathname of the batch script itself with %0, parameter extensions can be applied to this so %~dp0 will return the Drive and Path to the batch script e.g. W:\scripts\ and %~f0 will return the full pathname W:\scripts\mybatch.cmd

You can refer to other files in the same folder as the batch script by using this syntax:

  CALL %0\..\SecondBatch.cmd
This can even be used in a subroutine, Echo %0 will give the call label but, echo "%~nx0" will give you the filename of the batch script.

When the %0 variable is expanded, the result is enclosed in quotation marks.

hiiamboris
20:26@lepinekong_twitter I think it's best if you raise an issue on the tracker about it
20:30For now, why is system/options/path and system/options/script not enough for you?
lepinekong_twitter
20:41@hiiamboris as I said it doesn't give the current script, it gives only the FIRST script that was the argument of red, but if this script calls another script you're stucked.
hiiamboris
20:42I see. Does REBOL give you that another script?
rebolek
20:52@lepinekong_twitter You can modify Red sources and submit a pull request.
20:54> If you do not know where you come from, then you don't know where you are, and if you don't know where you are, then you don't know where you're going.

Nice. However, Red has its roots and its roadmap. So those questions were solved already.
hiiamboris
20:55@lepinekong_twitter Or at least just write down the design how it should work in all circumstances. Someone will implement it if your design is sound.
lepinekong_twitter
21:00What design ? I just know the what: get the current executing script :)
21:00Weird collect/keep: why do I get doubles [name: "Jack" age: 18] :

users: [
	[name: "Jeff" age: 14]
	[name: "Jack" age: 18]
	[name: "Milady" age: 22]
]

adults: collect [foreach user users [
		if user/age >= 18 [
			?? user
			keep (append/only [] user)
		]
	]
]

user: [name: "Jack" age: 18]
user: [name: "Milady" age: 22]
== [
    [name: "Jack" age: 18] 
    [name: "Jack" age: 18] 
    [name: "Milady" age: 22]
]

hiiamboris
21:01> What design ? I just know the what: get the current executing script :)

Well, that illustrates how much you need it ;)
lepinekong_twitter
21:01@hiiamboris the problem with you all geekies is you have problem to understand human ;)
hiiamboris
21:03True, since humans don't really understand themselves... ¯\\\_(ツ)\_/¯
dander
21:05@lepinekong_twitter I'm curious about what you need the current dir for. I guess you are doing more than just #include %relativepath/file.red? I mean, that's probably the most common use case for relative paths, right? I figure if there is another super common use case for it, more people would be asking the question. But maybe there is another way of doing what you want.
21:08@lepinekong_twitter I think it's because you are keeping that block, and adding to it for each user you match on. So the first time it matches, the block just has Jack, but the second time it has both Jack and Milady. Maybe just keep user instead of keep (append/only [] user)
lepinekong_twitter
21:08@danderwell the use case is very common in every language, as explained here for example https://www.autoitconsulting.com/site/scripting/get-current-script-directory-powershell-vbscript-batch: "The scripts I write usually read in other files or call OTHER scripts. In order for these scripts to run from any location – such as a UNC path – WITHOUT HARD CODING paths they need to use relative paths. "
21:09@dander haha yeah treacherous block I always forget :) https://redlang.red/static
rebolek
21:10@lepinekong_twitter nobody doubts such a feature is important. However there are still more important features for the core team that this, especially when it's trivial, it can be contributed by interested user.
lepinekong_twitter
21:10@dander thanks I have fixed:

users: [
	[name: "Jeff" age: 14]
	[name: "Jack" age: 18]
	[name: "Milady" age: 22]
]

adults: collect [foreach user users [
		if user/age >= 18 [
			keep (append/only copy [] user)
		]
	]
]

nedzadarek
21:11@lepinekong_twitter ok... you defeat the purpose of collect (unless it's just smaller example):
adults: collect [foreach user users [
            if user/age >= 18 [
                ?? user
                keep/only user
            ]
    ]
    ]
lepinekong_twitter
21:12@rebolek I hear "you'll probably wait forever" so I'll change do rather ;)
rebolek
21:13@lepinekong_twitter I'm afraid there must be some language barrier, because that's certainly not what I said.
lepinekong_twitter
21:13@nedzadarek ah ok I didn't think keep/only exists so that's better thanks
gltewalt
21:13@BeardPower because I was going off the algo on stack overflow. (Complicating the weighted random)
lepinekong_twitter
21:14@rebolek no you didn't say but that's how I interpret knowing the context ;)
gltewalt
21:17https://stackoverflow.com/a/1761646
dander
21:24@lepinekong_twitter I think there are some other things missing for red to be full featured as a scripting language. Are you able to launch these scripts with red.exe somehow? I thought the only entry points were the repl or compiling, and I think system/options/args is not yet implemented either
21:24or other arg passing between scripts
nedzadarek
21:26@lepinekong_twitter Yes, ? collect doesn't show it. Other functions has /only refinement though.
> The scripts I write usually read in other files or call OTHER scripts. In order for these scripts to run from any location – such as a UNC path – WITHOUT HARD CODING paths they need to use relative paths. "

Are you keeping your scripts in a one directory, e.g.:
C:/
- libraries/
-- aaa/
== something.red
-- bbb/

and you call them from an arbitrary directories? If yes, then how about setting system path to your directory and read it in the read. Something like this (I don't know how to read system variables in the different OS'):
my-load: func [path] [
  main-dir: LOAD-PATH-FUNCTION
  do probe main-dir/:path
]
my-load %aaa/something.red
dander
21:30@nedzadarek get-env and set-env are native!s
gltewalt
22:24@toomasv Thanks.
I wanted the any-function! words wrapped in <a href="url">word</a>. The "url" could be literal for now.
I have a few ideas.
nedzadarek
22:25@dander nice, thank you.
lepinekong_twitter
22:31@nedzadarek the scripts are totally independant, in real world like big corps they could have been written by different persons so organization of scripts should not depend on paths, that's only possible when you have such reflective properties for files even functions and not only objects.
22:32@nedzadarek even for my own little person case, I have dozens of scripts that have been written, I don't want to look inside each one.
22:35@nedzadarek there's a fashionable term today which is called "agile architecture" I don't like fashion but it may convey beter what I mean : you want to be able to shuffle things around ;)
BeardPower
22:37@gltewalt Alright :-)
lepinekong_twitter
22:41@nedzadarek this is kind of biological homeostasis applied to software: be independant of variable environment as much as possible, I always do things based on universal principles: that's the only things I can remember with my low number of neurons :)
nedzadarek
23:44@lepinekong_twitter then why don't you go "node way": every program has its own sub-directory with libraries (e.g %my-program/ - main directory, %my-program/main.red - your program, %my-program/libraries - your "scripts writen by different people/organizations", %my-program/libraries/popup & %my-program/libraries/popup/main.red - library named popup with its file main.red)?

c61292558
02:22how can I make my software"Icon of software at the bottom right corner"?
hiiamboris
07:23@c61292558 https://docs.microsoft.com/en-us/windows/desktop/api/Shellapi/nf-shellapi-shell_notifyicona
07:23I don't think Red natively supports that just yet.
endo64
07:30There are Rebol scripts for tray icons, first one uses Win32 API so can be implemented in Red / R/S, second one uses ports, we should wait for 0.7.0 for that.
http://www.rebol.org/view-script.r?script=tray.r
http://www.rebol.org/view-script.r?script=simple-system-tray.r
07:31"Icon of software at the bottom right corner" generally named "system tray" or "tray icon".
lepinekong_twitter
10:06@nedzadarek I'm not doing a monolith giant program like a server I'm doing small autonomous modules a bit like microservices and even when languages would allow agents.
10:16@nedzadarek the lack of that kind of core features or worst the change in user spec that impacts word behavior like value? https://redlang.red/value really spoilt the original elegance of the language. To make a module robust to any context usage as for encapsulation having to now write:

if error? try [__DEBUG_MODE__: get in system/words '__DEBUG_MODE__][
    __DEBUG_MODE__: false
]

instead of just:

unless value? '__DEBUG_MODE__ [__DEBUG_MODE__: false]

like you could in Rebol, is well awkward to say the least.

c61292558
11:20but ....i want it on Linux(deepin os)..... @endo64 @hiiamboris
hiiamboris
11:25is there even a system tray on linux?
c61292558
rebolek
11:25depends on WM
amreus
11:26 Yeah more like a dozen versions of a "tray" depending on window manager.
nedzadarek
11:28@lepinekong_twitter node is not only about servers. You could do small **independent** libraries.
ps. that's why we can (and should) make some mezzanines: https://gist.github.com/nedzadarek/91014c8d2514bf77940d0ff2db82713a
c61292558
11:29@hiiamboris many linux distributions have their graphical interface,like deepin and so on.
lepinekong_twitter
12:05@nedzadarek I know I use nodejs, python, powershell, c#, java, etc. as I said I don't intend to rely on red only: I only use red for meta-programming level as it still lacks core protocols and libraries for interfacing with webservices for example.
GiuseppeChillemi
17:01I have a function which calls another function. In the second one I set some new words. I wish to have them bound the the first function once the second one ends. How should I do ?
nedzadarek
17:22@GiuseppeChillemi how about returning block/map from second function and setting them in the first function, like this:
f1: function [] [
   a: b: none
   set [a b] f2
   print ['a a 'b b]
]

f2: func [] [
   [2 3]
]
f1
; a 2 b 3

This way you can have different second functions that are not tied to the first one.
GiuseppeChillemi
17:40@nedzadarek I do not understad how set [a b] f2 works in conjunction with f2: func [] [ [2 3]]
nedzadarek
17:43@GiuseppeChillemi set will just set words, either one: set 'a 42 print a ; 42 or more set [a b] [1 2] print [a b] ; 1 2; f2 just returns block of values ([2 3]). So you are doing somethign like this:
bl: f2 ; `bl` is a block [2 3]
set [a b] bl ; a is set to 2 &  b is set to 3
17:45ps. set is more powerful but I kept it simple.
hiiamboris
17:51@GiuseppeChillemi
>> f1: function [] [a: b: none f2 print [a b]]
>> f2: does bind [a: 2 b: 3] :f1
>> f1
2 3
nedzadarek
17:57@hiiamboris :+1:
GiuseppeChillemi
18:08@hiiamboris F2 does not know it is F1 the caller, so :F1 is not possible, it should be generic
18:09Also, 'a and 'b should be passed to F2 as arguments
18:09(a block is a good solution)
18:11@nedzadarek Understood, thanks. I will work on your proposal to get what I need.
nedzadarek
18:14@GiuseppeChillemi
f1: function [] [a: b: none f2 a b print ['a a 'b b]]
f2: func ['a 'b][set a 1 set b 2]
f1
; a 1 b 2
hiiamboris
18:18or if block is what you want:
>> f1: function [] [a: b: none f2 [a b] print [a b]]
>> f2: func [ws][set ws [1 2]]
>> f1
1 2
GiuseppeChillemi
18:28@hiiamboris I do not understand if F2 words are bound to the global context ot to F1 context
18:29also @nedzadarek
hiiamboris
18:33@GiuseppeChillemi literal blocks ([a b]) that appear inside a function are bound to that function, and when you pass them around they retain their bindings
18:40
>> a: 3 f: function [] [a: 4 f2 b: append [a] bind [a] system/words ? b print b] f
B is a block! value.  length: 2  [a a]
1 2
18:43@GiuseppeChillemi there's a great spoon bending exercise for you ☺ https://github.com/9214/whatnot/blob/master/red/spuny-mortals.red
OneArb
18:45Is it possible to ask a R2 question here?
hiiamboris
18:46it should be
OneArb
18:47I hope so :)
rebolek
19:00And the question is...? :smile:
endo64
19:01
>> o: object [a: 1]
>> f: function [] [a: 2]
>> x: bind [a] o
>> get first x
== 1
>> x: bind [a] :f
>> context? first x
== func [/local a][a: 2]
>> get first x
*** Script Error: context for a is not available

19:02Shouldn't context is available?
rebolek
19:03I think the error message should be different probably.
19:03The context is available, but a has no value.
endo64
19:04Correct, that was what I expect.
hiiamboris
19:09It's available only at the time of call. And on each recursive call the context will refer to the *new* top of the stack.
rebolek
19:12Yes, that's how I understand it. So the error message should be changed IMO.
hiiamboris
19:13Perhaps...
9214
19:18@rebolek and why should it be changed? Error message is up to the point (and already [was changed](https://github.com/red/red/wiki/[DOC]-Guru-Meditations#function-contexts) before). Context is not available because there's no frame on the call stack. You get one when function is called.
rebolek
19:21@9214 if you can get the context with context? and then get error that context is not available, there's some contradiction, don't you think?
9214
19:21Neither objects nor functions are contexts by themselves. Objects are thin wrappers over contexts which are allocated on the heap, and function's contexts are mapped on call stack during funciton call, and disappear once function is evaluated.
19:26@rebolek I don't see any contradiction, and already explained (twice) how it works. context? gives you a value (object! or a function!) that refers to internal context! value. object!'s context are allocated on the heap and are present during whole lifetime of a script (or until next GC sweep). function!'s contexts come and go to/from call stack together with function calls.
rebolek
19:27I understand how it works, however still see the contradiction.
19:28I think if the error message said something like *context is not **currently** available*, it would make more sense.
OneArb
19:34@rebolek reflecting how to best phrase a follow-up question to

https://rebolforum.com/index.cgi?f=printtopic&topicnumber=46&archiveflag=new

Is it possible to add a face to a view without unviewing it?
rebolek
19:35@OneArb yup, no problem. Just add a face to a parent-face's pane and then show parent-face.
9214
19:40@rebolek not really. To me this implies that it may become *eventually* available sometime in the future, but doesn't clarify when and how. So, if you want a less puzzling error, it should say something like "context for <foo> is available only during function call", but then it's up to a user to figure out which function is in question. Or error message can remain untouched (whatever you say it's fairly accurate), and contexts workings should be covered in documentation.
OneArb
19:48@rebolek I'll try that. The added twist is the face name will not be known until runtime. I use

make set-word! rejoin [get-face field-name b] 'text join "Test" b

,get stuck on how to reference that new face

show make set-word! rejoin [get-face field-name b]

How to access / modify a runtime defined face?

`
GiuseppeChillemi
19:54How would you visually rappresent a context and words ?
OneArb
19:54How can I paste code and keep it formated on Gitter?
9214
19:56@OneArb there's a Markdown cheatsheet (M⇩ button) in the bottom-right corner of message input field.
OneArb
19:59I got the ` thanks @9214

20:00@rebolek
This is the code I attempt to make work

browse-lines: 8

block-end: [
    label "field-name"
    across
    field-name: field "grid"
    below    
    button "Create fields" [ do create-fields-new ]  
    button "Refresh grid1/text" [
      grid1/text: "Text*"
      show grid1
    ]
    button "Refresh fieldname/text" [
      ; how to set the runtime created face?    
      b: 5
      set in make set-word! rejoin [get-face field-name b] 'text "Textx"
      show make set-word! rejoin [get-face field-name b]
    ]    
    below across
    button "Halt" [halt]
    button "Quit" [quit]
  ]
  
create-fields-new: [
        unview 
         view layout collect [
             repeat b browse-lines [
                 keep make set-word! rejoin [get-face field-name b]
                 keep 'text
                 keep join "Test" b
             ]
             keep block-end
         ]
     ] 
     
view  layout block-end

GiuseppeChillemi
20:54@hiiamboris
> @GiuseppeChillemi literal blocks ([a b]) that appear inside a function are bound to that function, and when you pass them around they retain their bindings

Yes but here we are taliking about the words contained in the block and not the block itself. So I think A and B are bound to the global context and not F1
moliad
20:54binding is not assigned to a block, it is assigned to each instance of a word datatype value
20:55so in the following: [ a a a ] ... a can be bound to 3 different values
GiuseppeChillemi
20:58@moliad This is why I think a visual rapresentation of context and its words and values could be useful... I am still stuck at this concept. I do not fully understand how they connects together, in other words, their relations and the connection structure.
moliad
20:59example:

c1: context [ a:  'really?] 
c2: context [ a: "yep" ]
c3: context [ a: "OMG!" ]
b: reduce [ in c1 'a    in c2 'a     in c3 'a]
probe b
probe reduce b
== [a a a]
== [really? "yep" "OMG!"]
GiuseppeChillemi
21:01@moliad I have always tought that words inside blocks are just "neutral" symbols.... now it seems thay have a connection to something else.
21:02To me: [a a a] is a group of the same word/symbol and then REDUCE [a a a] would give the same result
moliad
21:03there is no connection structure... a word! value is a structure with two attributes. A reference to a context (object!) and the index of the value to lookup into that context. The lexical nature of a word (it has a litteral string representation) is just an artifact for human interpretation where object! values store a lookup table to map the textual representation of words. Binding does the lookup and pairing between two contexts to re-assign the lookup + context pair from one context to another.
GiuseppeChillemi
21:08So we have its "visual rapresentation" a a reference to a context and the value for that context.
moliad
21:08the actual implementation in memory may be a bit more complex, but this is the basic logical mechanism of one of the most powerful aspects of the Rebol symbolic token concept.
9214
21:08> with two attributes

Three. Context reference, index in this context and symbol ID. Reference + index form a "binding". Index in symbol table forms a "spelling". word! is just an instance of internal symbol! value coupled with value in some context.
21:09Context is just a two-column table, one for symbol IDs (symbol!), the other for values (any-value!).
moliad
21:09yes, but I'm trying to keep it simple for understanding ... once loaded, the spelling is not actually required... its just for human interfacing.

21:10(and re-binding)
9214
21:10@moliad I thought Rebol allowed change of spelling with alias?
GiuseppeChillemi
21:11@moliad No Max, please, do not keep it simple. Now its time to fully rapresent it in my mind. I could come back later when I do not understand something but I have to start from the full scheme with connections.
moliad
21:13so @GiuseppeChillemi what you call a visual representation, is just the label this word uses, like @9214 says, its not stored as a string within the context, but as a reference in a (currently global?) symbol table. these ID are then used when re-binding to compare if two words use equivalent symbols.
21:15@9214 yep, I assume it simply adds a new entry in the symbol table and sets its source id to the same as the other... the problem with this is that is it also equivalent in all token use, including when used as refinements... it creates strange bugs... to it was deprecated.
9214
21:15> (currently global?) symbol table

Yep, currently there's one table per Red session. Eventually it will be one per module.
moliad
21:16One wet dream I have with Red is to support general continuation. I think the interpretor would allow it pretty easily, but I wonder if it would be possible on compiled sections of the code.
9214
21:17@moliad oh boy, yes. That's my wet dream since a while too.
moliad
21:19just being able to do :
halt
>> print some-value
== "some result"
>> continue

and it takes up where it left off ... with multi threading, it would allow one continuation per thread :-)
9214
21:20@moliad there was some chat about continuations in [/lisp](https://gitter.im/red/red/lisp) room, if you're interested.
GiuseppeChillemi
21:21I'll read again what you have written (all but your "wet dreams" topic, am not adult enough) and come back with questions.
nedzadarek
21:22@GiuseppeChillemi

> I do not understand if F2 words are bound to the global context ot to F1 context

Let me clear the last code:
f1: function [] [a: b: none f2 a b print ['a a 'b b]]
f2: func ['v1 'v2][set v1 1 set v2 2]
f1
; a 1 b 2


In my case:
f1: a & b are bound to the f1's context because function makes all set words local; f2, print are in global context
f2: v1 & v2 are arguments to the function, hence they are in f2 context
9214
21:22@moliad having stack frames as first-class values (and direct access to call / evaluation stacks) would be the right step in this direction, I guess.
moliad
21:24it would already allow some time reversal, very useful in debugging.
21:25@GiuseppeChillemi seems all good
GiuseppeChillemi
21:26So...
in b: [a a a], then A are not the same because blocks items are just links to some words and and their context whose visual rappresentation is the same but the value is different ?
nedzadarek
21:26btw. I keep referring to the context of print, do etc as "global context". Is this good name or does the Red use another name?
9214
21:27@moliad regarding aliases - symbol table is a block of symbol! values. Symbol ID is just an index in this block. Each symbol! value has a dedicated field where index of aliased symbol is contained. Say, A is an alias for a (this is how case-insensitivity is handled) and will contain an index of a. That way you can have many instances of the same symbol with different casings, and two symbols can be compared for equality simply by checking their alias values.
moliad
21:28blocks are even simpler than you think. they are arrays. so each a within is just a value, which happen to be word! types, stored directly within the block's memory.
9214
21:30> they are arrays

Array + extra "table" which tracks head / tail and total size of allocated buffer, various flags and back-pointer to referring node.
moliad
21:32@9214 yep... but the R2 alias has a weird side-effect which is not very nice...
>> alias 'only  "foo"
== foo
>> append/foo [] [1 2 3]
== [[1 2 3]]
21:33sorry... two discussions... interleaved
GiuseppeChillemi
21:36> blocks are even simpler than you think. they are arrays. so each a within is just a value, which happen to be word! types, stored directly within the block's memory.
>

c1: context [ a:  'really?] 
c2: context [ a: "yep" ]
c3: context [ a: "OMG!" ]
b: reduce [ in c1 'a    in c2 'a     in c3 'a]
probe b
probe reduce b
== [a a a]
== [really? "yep" "OMG!"]


So which is the value they store here:

b: reduce [ in c1 'a    in c2 'a     in c3 'a]


Do they store the word A and the binding to the context and value ?

21:39So:

b: [a a a]
probe b
[a a a]


Is different than

b: reduce [ in c1 'a    in c2 'a     in c3 'a]
probe b
[a a a]


While they are visually identical ?
moliad
21:40b will now store 3 brand new word ***values***, which store references to 3 different contexts, and references to symbols, and idex within the contexts.
21:41exactly. they *look* the same, but they are in different memory, and they only reason they probe the same is that they all contain references to the same symbol, but within different objects.
GiuseppeChillemi
21:42Yes, but until now I have never realized that blocks content is not its visual rappresentation but they are different. I thought this "priviledge" of having a value was only for words defined outside blocks.
moliad
21:43to be extra precise, c1 c2 c3 may have different index for the same symbols. if c1 had two attributes and a was the second one, its index for a is probably 2
GiuseppeChillemi
21:43This because no REBOL books ever made a visual rappresentation of what's behind.
moliad
21:44there is an attempt in the bindology document by Ladislav Mecir, but its a rather dry read. ;-)
GiuseppeChillemi
21:45Mathematicians have their wet dreams where others have dry ones.
moliad
21:45The Red source code is a nice way to discover all of this.
21:45hehe
21:46I've got to go... see y'a!
21:47hope its all clear now... it changes perspective on the language.
21:47(it did for me)
GiuseppeChillemi
21:48@nedzadarek

> @GiuseppeChillemi
>
> > I do not understand if F2 words are bound to the global context ot to F1 context
>
> Let me clear the last code:
> `
> f1: function [] [a: b: none f2 a b print ['a a 'b b]]
> f2: func ['v1 'v2][set v1 1 set v2 2]
> f1
> ; a 1 b 2

I need to pass a block of symbols and a block of values to F2. Then they should be bound 1 to 1 to F1 context
21:49@moliad I am just learning
21:49Thanks
endo64
21:52@GiuseppeChillemi It is the red pill of Redbol languages. Remember words carry their context (Gregg or Ladislav)
Very good stuff about binding, thank you all!
GiuseppeChillemi
21:55> @GiuseppeChillemi It is the red pill of Redbol languages. Remember words carry their context (Gregg or Ladislav)

It appears they carry it too inside BLOCKS
21:57@nedzadarek So, if I pass a block with words inside, I will pass the block and the binding of each word inside it.
22:03But if I get and item in a block and put it into another one, will I loose the binding ?

Something like

c1: context [ a:  'really?] 
c2: context [ a: "yep" ]
c3: context [ a: "OMG!" ]
b: reduce [ in c1 'a    in c2 'a     in c3 'a]
probe reduce b
new-block: copy []
append new-block first b


Oh oh...

>> probe reduce new-block
[really?]


That's really mind bending !
22:04Nooooo I have made a mistake, give me the blue pill !!!
22:04The world will never be the same again for me !
22:05Please: let probe reduce new block return [a] again !
endo64
22:06No way back anymore :)
GiuseppeChillemi
22:07:((( :)))))))
nedzadarek
23:27@GiuseppeChillemi
> I need to pass a block of symbols and a block of values to F2. Then they should be bound 1 to 1 to F1 context

f1: function [] [a: b: none f2 [a b] ["a from f2" "b from f2"] print ['a a 'b b]]
f2: func [keys values][set keys values]
f1
; a a from f2 b b from f2

?

moliad
03:58You need to unlearn about blocks having any concept of binding. blocks only store values. these can be of any type. some types have a pointer to extra data, many contain all the data within this generic value slot.
04:02words are such an example. they store all they need to refer to a value within a context as well as the symbol it was given when created or loaded, so it can refer to it later (to be molded or to compare symbols from another context so it can be rebound or looked up when using something like get or set.
04:06if you copy a word from one block to another it can do a direct mem copy of all the content inside the value slot (plus any GC magic). So the new value in the new block is independent, but it contains all the same context ref, symbol ref and context value index data fromthe word it was copied from.
04:16binding will change this data "in-place" and that is the magic of rebol.. its probably the most significant design detail of the whole language. its so well implemented that you can use rebol for a decade and never need to know or understand it. you can simulate almost all other traditional token and symbolic scoping tricks of other languages, even functional ones. but its much harder to imitate rebol's token mechanisms in other languages, because we carry the meaning of the tokens with the data. the tokens themselves have no global value, which is how most if not all other languages do it. it may be looked up dynamically, but its still always based off of a single global Symbol table which has inner scopes etc.
(please don't give examples of different languages, I'm comparing to mainstream computer science)
04:20virtual methods within OOP languages are probably the closest implementation to our binding engine, but they are rarely dynamic... usually they are still statically defined in a class, unless you use prototypes like Javascript and C# which has capabilities to do dynamic object and class inspection (like when we use words-of
04:23back to our binding examples, when you use VIEW, your layout spec may include set words, right? well these are used as-is and since they retain their binding, if we use set on the word, then it will actually set the word as supplied from your context. even if its being used deep within 10 layers of code and context. this is an example of why binding is so powerful, the static nature of the binding makes it very flexible and reusable.
nedzadarek
20:51@moliad
> virtual methods within OOP languages are probably the closest implementation to our binding engine

I wonder how would you compare Smalltalk & Ruby to the Red's binding engine. I would say something about Ruby but I haven't been using it for a long time so I don't want to talk about not basic features. I just remember that classes & objects are editable and you have binding class (you can bind & unbind methods).

> the static nature of the binding makes it very flexible and reusable.

Sometimes you want something less powerful/flexible but more reliable (or I would say something that you cannot easily shoot yourself in the foot).
9214
21:20Late binding / dynamic dispatch in OOP languages have little to do with bind and any-word!s.
lepinekong_twitter
22:21Collect/keep in parse with multiple keep, this works:

link-rule: [
    thru {<h3} thru {<a} thru {href=} [thru {"} | thru {'}] keep copy ~link to {?} 
    thru {>} keep copy ~title to {<}
    thru {<p} thru {<a} thru {>} keep copy ~description to {</} 
]

~links: parse html [
    collect [
        any [
            link-rule
        ]
    ]
]

but is there a possible syntax to group into a block :
keep reduce [~title ~description to-url ~link]

or is it only possible with append/only:
link-rule: [
    thru {<h3} thru {<a} thru {href=} [thru {"} | thru {'}] copy ~link to {?} 
    thru {>} copy ~title to {<}
    thru {<p} thru {<a} thru {>} copy ~description to {</} 
    (
        append/only ~links reduce [~title ~description to-url ~link]
    )
]

~links: copy []
parse html [
    any [
        link-rule
    ]
]




nedzadarek
22:26@lepinekong_twitter
>> collect [keep (reduce [2 + 3 4 + 6])]
== [5 10]

?
endo64
22:36@lepinekong_twitter Or is this what you want?
~links: parse html
    collect [
        any [
			collect [link-rule]
        ]
    ]
]
22:37This will produce:
[[
    "http://example1.com/" 
    "title1" 
    "description1"
] [
    "http://example2.com/" 
    "title2" 
    "description2"
] [
    "http://example3.com/" 
    "title3" 
    "description3"
] []]
22:47@moliad @9214 I have another question about binding,

o: context [a: "object"]
p: context [a: "another object"]
b: reduce [in o 'a] ;== [a] and a is bound to o

print get bind first b p  ;bind the word a to p, and print, hence "another object"
print b ; == "object" (a is still bound to o, so it didn't keep the binding)

bind b p ;bind the words inside a block
print b
; == another object (now a is bound to p and binding is kept)
22:48When a word is inside a block then it keeps the binding, otherwise binding is not kept.
9214
22:59@endo64 block keep their values on the heap, and "preserve" all changes that you do to them. It that way binding is "static" and can be kept indefinitely. But with bind first b p a *copy* of a word! value slot is taken out of block, pushed on evaluation stack and gets its binding modified. You can "preserve" this word! value yourself by putting it somewhere.

Moreso, b in this line:
print get bind first b p

And in this line:
print b

And even in this one:
bind b p

Are all *different* values. They are 3 completely independed words that share the same spelling. Modifing one won't affect the other. Same applies to any other word. In [a a a] all as may have completely different bindings. Modifing copy of a pulled out of a block won't modify its "twin brother" which remained in that block. Modifying the first a won't affect the second.
23:03BTW, in is a bit slower than bind, because it makes an extra copy of the second argument.
23:13To put it simply, bind [foo] bar affects foo, and foo just sits in a block where it belongs, with its binding altered. bind 'foo bar similarly affects foo, but foo itself lives only on evaluation stack, as a passed / returned argument to / from bind function. If you don't put it in some aggregate structure - it's gone forever. And, again, binding one particular word won't affect any other word with the same spelling.
endo64
23:14> block keep their values on the heap, and "preserve" all changes

@9214 Thanks a lot for the explanation!
9214
23:17You can draw a parallel with [homonyms](https://en.wikipedia.org/wiki/Homonym#Further_examples) in natural language. They are words that sound alike or are spelled alike, but have different meanings.
23:18@endo64 you're welcome.
endo64
23:25I know that words with same spelling can have different meaning in different contexts, and the [a a a ] example, but still thought that words will keep their binding even if they live out of a block (well, they actually keep just during the evaluation)

>> print get bind in o: object [a: 1] 'a p: object [a: 2]
2
>> o/a
== 1

My incorrect expectation was o/a would be 2.
I understand your explanation and it makes a lot sense now, thanks again!
9214
23:32
text
in o: object [a: 1] 'a

in returns a *copy* of a value slot.
bind in o: object [a: 1] 'a p: object [a: 2]

bind takes this copy and binds it to p object.
print get bind in o: object [a: 1] 'a p: object [a: 2]

print get ... outputs 2 and confirms that binding indeed was changed. But the word a that you've modified has gone. Its sole purpose in this expression was to yield 2 and disappear in a puff of smoke. Moreso, trying to modify words in object's body won't work, as you always work with copies. even words-of returns a copied block, with all words in it being bound to an object.
endo64
23:41> But the word a that you've modified has gone. ...even words-of...

Yep, understood very well! Thanks. I'll collect all conversation about binding here started with @GiuseppeChillemi 's question and put it to a wiki page, so you won't keep telling this long anymore and simply point to there ;)
9214
23:47@endo64 thanks. I plan to document this (and much more) myself since a while, but can't figure out where to start. It's all interconnected, and one-sided approach won't cut it.
gltewalt
23:56What’s all interconnected?

gltewalt
00:05You can do better than bindology
00:20Something on bind or parse is needed. From a good writer.
lepinekong_twitter
00:31@nedzadarek @endo64 thanks will look at your solutions.
GiuseppeChillemi
09:20@gltewalt Vladimir @9214 is either a good writer and his knowledge is very deep. Hi is the best candidate for these topics.
09:26@endo64

> Yep, understood very well! Thanks. I'll collect all conversation about binding here started with @GiuseppeChillemi 's question and put it to a wiki page, so you won't keep telling this long anymore and simply point to there ;)

I am already keeping links to many conversation in my bookmarks and start collectiong them here: [Programming.red wiki page, forum/chats section](https://programming.red/wiki/Main_Page/RED_By_Topics#Forums.2FChats_Q.2FA)
Note, page are actually in READ ONLY mode because I am giving them a structure and they are in draft stage.
10:11@endo64 , I have taken some time to insert some links to threads I have collected. I have found a graph from Vladimir too. He already made something but I totally forgot about it: [Graph on Words/Contexts/Bindings](https://gitter.im/red/help?at=5accc5a91130fe3d36c0b7e9)
viayuve
10:38how to minimize app/page like taskbar in panel without closing it.
nedzadarek
10:41@GiuseppeChillemi Great work! Keep it up! Someone from the future will thank you.
10:41@lepinekong_twitter You're welcome.
viayuve
10:46why this message suddenly "Windows Defender SmartScreen prevented an unrecognized app from starting. Running this app might put your PC at risk."
GiuseppeChillemi
11:18@nedzadarek Still a lot of links to threads to add.
JLCyclo
16:51a question: a sample or meaning for do/expand ?
nedzadarek
17:00@JLCyclo https://www.red-lang.org/2016/12/entering-world-of-macros.html
do/expand [
     #macro [number! 'KB] func [s e][to-integer s/1 * 1024]
        print 64 KB
]
; 65536
JLCyclo
20:50@nedzadarek thanks
nedzadarek
21:12@JLCyclo You're welcome
lepinekong_twitter
23:59Weird macro behavior: it only expands one file (%imports/file1.inc) not the second one (§include %imports/file2.inc) ?!

;src/test.red
Red [
    Title: ""
]

#macro §include: func[param>source][
    new-line load param>source true ; new-line block true will insert a new line in block (not in a string which uses newline)
]

f: function [][

§include %imports/file1.inc
§include %imports/file2.inc

]



;build.red
Red [
    Title: ""
]

~output-file: %test.red
src-expanded: expand-directives load %src/test.red
write (~output-file) mold/only src-expanded


output:

Red [
    Title: ""
] 
    .html-gen: function [] [
        test1: true 
        §include %imports/file2.inc
    ]


The 2 include files:

test1: true

and

test2: false








nedzadarek
13:32Is there a way to control stack limits (number, time limit etc) without recompiling the source?
lepinekong_twitter
14:31Have now a lengthy page on collect https://redlang.red/collect you're right @nedzadarek I'll now need to add some index :) will also add a contributors page for the help here ;)
rebolek
14:35collect return a block of collected values optionally from a matched rule. Often used with keep.

There's no matched rule. There's keep function (so it's not used *often*, but exclusively with keep, because keep is not defined outside collect) that collects values.
nedzadarek
15:10Yes, collect doesn't make sense without keep.
lepinekong_twitter
17:03So nobody knows about https://gitter.im/red/help?at=5c4e45d3ca428b06451199d7 ? Did I do any stupid syntax mistake as usual :)
17:04@rebolek I think I took this definition from red page but maybe I'm wrong I'll check ;)
hiiamboris
21:55@lepinekong_twitter strange indeed
endo64
21:57@lepinekong_twitter It looks like a bug to me:
>> expand-directives [#macro mymacro: func[a] [load a] mymacro %test.red mymacro %test.red]
== [
    a: 1
    a: 1
]


There is a problem when there is load inside a macro and there an outer block:

>> expand-directives [#macro mymacro: func[a] [load a] [mymacro %test.red mymacro %test.red]]
== [[
    a: 1 mymacro %test.red
]]


On the other hand if I change my %test.red file from a: 1 to "test" then it works again even there is outer block:

>> expand-directives [#macro mymacro: func[a] [load a] [mymacro %test.red mymacro %test.red]]
== [[
    "test"
    "test"
]]
hiiamboris
22:02
>> expand-directives [#macro m: func [x][x] [m [1 2] m [3 4]]]
== [[1 2 m [3 4]]]
>> expand-directives [#macro m: func [x][x] m [1 2] m [3 4]]
== [1 2 3 4]
endo64
22:16
>> expand-directives [#macro m: func [x][load x] m "1" [m "2" [m "3"]]]
== [1 [2 [3]]]
>> expand-directives [#macro m: func [x][load x] m "1" [m "2 3" [m "4"]]]
== [1 [2 3 [m "4"]]]

22:17I think we should move to /bug room and also raise a ticket.
lepinekong_twitter
23:16@endo64 @hiiamboris thanks, so it's not me for once :)
23:16Is there a reason why this syntax doesn't work in View layout:

cell (color-i) (rejoin [form color-i newline :color-i])


whereas this one works:

cell (color-i) rejoin [form color-i #"^/" get color-i]


in:


show-colors: function [
    /colors param>colors [block!] 
][

    refinement-colors: colors

    either refinement-colors [
        title: "Custom Palette"
        cell-size: 100x100
        colors: :param>colors
    ][
        title: "Red Palette"
        colors: sort extract load help-string tuple! 2   
        cell-size: 80x80
    ]


    backdrop-color: white
    win: copy compose [
        title (title)
        backdrop (backdrop-color)
        style cell: base (cell-size) font [size: 10] middle wrap
    ]     
    i: 1
    foreach color-i colors [
        append win compose [
            cell (color-i) (either refinement-colors [form color-i][
                rejoin [form color-i #"^/" get color-i]
            ])
        ]
        if (0 = (i % 5)) [
            append win 'return
        ]
        i: i + 1
    ]
    view win
    return colors
]

show-colors





endo64
23:33@lepinekong_twitter It works for me. As there is rejoin it should work.

toomasv
04:36@lepinekong_twitter Two suggestions:
1. You don't need to copy the compose block. compose already copies the block, so copy is redundant.
2. Instead of
append win compose [
            cell (color-i) (either refinement-colors [form color-i][
                rejoin [form color-i #"^/" get color-i]
            ])
        ]

you might want to use
repend win [
            'cell color-i either refinement-colors [form color-i][
                rejoin [form color-i #"^/" get color-i]
            ]
        ]

which is more effective, appending reduced values to win one-by-one, without intermediate block. (You can retain parens if you prefer for readability)
xqlab
09:26@lepinekong_twitter There are errors and unrebolish ways on your redlang/collect page
e.g not dir? folder should probably be not dir? folders/1 or unless (..) or (..) should be better unless any [.. ..]
lepinekong_twitter
09:35@xqlab yes you're right I am dyslexic ... in brain :)
09:36@toomasv oh thanks I didn't know compose copy block and I never remember repend, should create it in dictionary :)
09:37@endo64 the code I post works: you must change to cell (color-i) (rejoin [form color-i newline :color-i])
09:42@endo64 @hiiamboris any alternative possible to create static include for interpreted script ?
hiiamboris
09:51@lepinekong_twitter simplest fix would be to have one include per block ;)
lepinekong_twitter
09:51@xqlab will create a page style guide, always forget about any, repend etc.
hiiamboris
09:51I also suggest you raise an issue
lepinekong_twitter
09:51@hiiamboris I don't consider as a fix for me: I need multiple includes :)
hiiamboris
09:54why not put them each in a separate block?
09:54combine later if you will ;)
lepinekong_twitter
11:02@hiiamboris I don't understand what you mean ?
11:02Dynamic code:
~folder1: %../build/
~folder2: %../ci/
dynamic-code: compose/deep [
    ~files: collect [
        keep compose [
            (to-paren [collect [foreach ~file read (~folder1) [unless dir? ~file [keep head insert ~file clean-path (~folder1)] ]]]) 
            (to-paren [collect [foreach ~file read (~folder2) [unless dir? ~file [keep head insert ~file clean-path (~folder2)]]]]) 
        ]
    ]        
]
write-clipboard mold dynamic-code ; so that you can look at code generated in clipboard
do dynamic-code


How do you generalize to any number of ~folders ? for example if:
~folders: [%../build/ %../ci/ %../.src/]
11:05The most comprehensive way possible ;)
hiiamboris
11:13with foreach?
11:13also I don't see how this is related to your macros
11:17I'll give you a workaround for macros after you create an issue on the tracker ;)
lepinekong_twitter
11:37@hiiamboris what I want to do is this: I have a gigantic program that I want to split for dev, but assembled in one piece (packaging) when downloaded from internet. I have 2 systems (see https://i.imgur.com/Xu1lixa.png): a script that assembles a hierarchy of files in .assembling folder, and now the macro which can include files in .includes folder. I now need this macro and not just this assembling script because of common parts that can participate into several other giant assembling files. Without this macro, duplicating such parts is a nightmare for synchronizing evolution of these assemblings.
11:39@hiiamboris last but not least it helps flattening the view of components, hierarchy is great for composing not great at navigating.
hiiamboris
11:46makes sense
lepinekong_twitter
11:49@hiiamboris as I said I have only 2 neurons so I have to compensate with organisation so if I need to even cut the hairs further I have also section :) https://redlang.red/section
nedzadarek
11:57@lepinekong_twitter
> not great at navigating.

I disagree.
hiiamboris
12:24@lepinekong_twitter interesting ;) Is it sort of your way to find out which line causes an error in your code?
endo64
16:03> the code I post works: you must change to cell (color-i) (rejoin [form color-i newline :color-i])
16:03@lepinekong_twitter I did already, it worked that way too.
lepinekong_twitter
16:17@hiiamboris yes because I make a lot of bugs :)
16:18@nedzadarek I have both hierarchical and flat so no matter what ;)
16:18Weird or not ? In the code below dir? doesn't recognize file! type:

~files: collect [
    keep compose [
        (collect [foreach ~file  read %../.src/ [ type: type? ~file ?? type ?? ~file ask "pause" unless dir? ~file [keep head insert ~file clean-path %../.src/ ]]]) 
        (collect [foreach ~file read %../build/ [unless dir? ~file [keep head insert ~file clean-path %../build/] ]]) 
        (collect [foreach ~file read %../ci/ [unless dir? [keep head insert ~file clean-path %../ci/]]]) 
    ]
]


dir?: func [file [file! url!]][#"/" = last file]
pause
type: file!
~file: %content.read.red
pause
*** Script Error: dir? does not allow block! for its file argument
*** Where: dir?
*** Stack: collect collect dir?

nedzadarek
16:20@lepinekong_twitter are you saying that you are are using both, flat and hierarchical structure(s)?
16:21 @lepinekong_twitter
(collect [foreach ~file read %../ci/ [unless dir? [keep head insert ~file clean-path %../ci/]]])
are you transforming a block after %../ci/? If not I can see that you want to pass a block to the dir?
lepinekong_twitter
16:25@nedzadarek I'm using hierarchy to organize code, I'm using flat to search code: when you reach a huge amounts of information seaching a directory doesn't scale well - that's why google won the search war over yahoo directory ;) https://en.wikipedia.org/wiki/Yahoo!_Directory
16:27@nedzadarek why did you modify to "dir? [" whereas my code was "dir? ~file" ?
nedzadarek
16:28@lepinekong_twitter I wonder whenever or not google is so flat... but I get your idea. I guess you are using some meta-data to look for data more efficiently.
16:29@lepinekong_twitter I haven't modified anything. I have just copied 3rd inner collect. If something is wrong then the OS is the culprit.
16:30^^ I guess you have forgotten to add (pass) ~file to the dir? in your 3rd collect.
lepinekong_twitter
17:20@nedzadarek no at the moment I don't need, I just trivially use my eyes and an alphabetical list, next step maybe if my number of functions grow to thousands: It's just still quicker than type search files in VSCode that's what I want :) Same for the offline mode engine I'm building: I just want it practically fast enough (at the moment it's unfinish and it's so slow)
17:22@nedzadarek oh sorry 3rd is mystypo, it's the first one which make Red crash, but to be sure I'll retry by deleting 3rd one.
nedzadarek
17:25
s: "" repeat i 4 [append s "*" print length? s print s]

Output:
1
****
2
****
3
****
4
****

Am I doing something wrong? Each iterations print the correct string's length but it prints whole string (resulting string after last repetition of the repeat).
17:31 s: "" repeat i 4 [append s "*" print length? s print copy s] - copying seems to fix the issue but is this intended behaviour?
lepinekong_twitter
18:11@nedzadarek thanks it was this mischief dir? in 3rd line, I thought the interpret stopped at erroneous line but seems that it checks whole syntax first.
nedzadarek
20:32@lepinekong_twitter as for 0.6.4 version, error messages are cryptic sometimes. Within my code I have put bunch of print/probe to know where the error occurred. So, in my opinion, it's better to check more than one occurrence of "similar looking code" that an error message shows you.
Oldes
20:32@nedzadarek it must be some kind of delayed printing in the gui console. Works fine in CLI console. My guess is, that the gui console first builds draw block and as you don't copy the series, it is shared.
greggirwin
20:33@Oldes, beat me. :^)
nedzadarek
20:33@Oldes but why length? sworks?
Oldes
20:34because it is good in the time when it is being processed. And the integer value is not a series value.
nedzadarek
20:36@Oldes I see. So is this a bug? Shall I report it (I am going to check current issues first)?
Oldes
20:36@nedzadarek it is same like:
>> s: "" b: [] repeat i 4 [append s "*" repend b [length? s s]] b
== [1 "****" 2 "****" 3 "****" 4 "****"]
20:36It is your bug... you should use copy
greggirwin
20:37
>> s: ""
== ""
>> append s "*" print length? s print s
1
****
>> append s "*" print length? s print s
2
****
>> append s "*" print length? s print s
3
****
>> append s "*" print length? s print s
4
****
nedzadarek
20:37@Oldes but you said it works on the cli console.
Oldes
20:38@nedzadarek because the cli console does not build a block, but outputs data directly into output buffer
greggirwin
20:38Sorry, my example doesn't show the behavior statically. @nedzadarek, run those lines one by one, and watch the console output.
Oldes
20:38But maybe @qtxie could copy the series. I'm not familiar with the gui implementation.
greggirwin
20:39It does seem like the series should be copied in this case.
nedzadarek
20:39@Oldes yes, I know but I mean if it works on a cli console but it doesn't work on the gui console but both consoles should be very close to each other.
20:40@greggirwin It looks amazing... but I would say it is a bug. I would not expect something already printed to be changed.
greggirwin
20:40Agreed. Red changes history. :^)
20:41Please file a ticket.
lepinekong_twitter
20:48@nedzadarek thanks next time I'll try to check (though I'm often blind :))
20:49Just a little remark vscode plugin doesn't colorize to-float:
https://redlang.red/img/split-sql.png
nedzadarek
20:50@greggirwin https://github.com/red/red/issues/3761 done
20:51@lepinekong_twitter You're welcome.
21:00So, there is no way to set stack limits (number/time) without recompiling the source?
greggirwin
21:08Correct.
nedzadarek
21:37@greggirwin Thank you.
hiiamboris
21:39@nedzadarek lovely issue title :+1:
nedzadarek
21:50@hiiamboris all credits to Gregg: :point_up: [January 29, 2019 9:40 PM](https://gitter.im/red/help?at=5c50ba59c2dba5382eab2bab)
qtxie
22:46@nedzadarek Should be easy to fix it.
lepinekong_twitter
23:13With Red 0.6.4 would it be possible to insert interactive graphic like for Python in VSCode Terminal ? https://blogs.msdn.microsoft.com/pythonengineering/2019/01/29/python-in-visual-studio-code-january-2019-release/
nedzadarek
23:33@qtxie good to hear, thank you.
greggirwin
23:49@lepinekong_twitter, I believe that depends more on the VSCode plugin and LSP than Red itself. @bitbegin may provide more information, but he's very busy.

bitbegin
01:25i will check if the interactive mode can be implemented
qtxie
02:32@lepinekong_twitter It is embeded the IPython console. We don't have such powerful console yet.
02:34We can make a Red module for the IPython console.
AiguyGary_twitter
03:57Is there an easy way in Red to format large numbers for output with commas every three digits to the left of the decimal point? Something similar to sprintf in C perhaps.
greggirwin
04:01Not yet. The format dialect is waiting in the wings. You might be able to extract some bits from it: https://github.com/greggirwin/red-formatting
04:02See [the doc](https://github.com/greggirwin/red-formatting/blob/master/formatting-functions.adoc) for info.
04:04form-num-with-group-seps, in %format.red, might be all you need.
04:05Though, sorry, it does have some internal dependencies. You could probably hack those out without too much trouble.
Oldes
09:47What is the easiest way to remove unwanted object's fields? Let's say I have:
>> o: object [a: 1 b: none]
== make object! [
    a: 1
    b: none
]

and want to have object without the b.
rebolek
09:47You can't remove object keys.
Oldes
09:48I know... so I want to construct a new object with just some keys.
rebolek
09:48And what are your rules for determining what is unwanted?
09:51
>> object head remove/part find body-of o 'b 2
== make object! [
    a: 1
]
Oldes
09:52I was hoping, that if I have:
>> o1: object [a: 1] o2: object [a: 2 b: none]
== make object! [
    a: 2
    b: none
]

I could construct a new object using: make o1 o2 which now returns:
== make object! [
    a: 2
    b: none
]

but could return:
== make object! [
    a: 2
]
09:52Using body-of is a way to go... but quite cryptic.
rebolek
09:53How should make know what fields you don't want?
Oldes
09:54make could know which fields I want if both arguments would be of type object . It would set only keys of the first one.
rebolek
09:55It knows, it combines fields from both objects:
>> make object [a: 1] object [b: 2]
== make object! [
    a: 1
    b: 2
]
Oldes
09:56I know what it does now. But cannot it work differently?
rebolek
09:56I still don'ŧ undrestant what you want to change
Oldes
09:56Do you make objects from objects? Or do you use blocks as the second argument?
09:58In your example, it could return copy of the original object as there is now a in the second object.
>> make object [a: 1] object [b: 2]
== make object! [
    a: 1
]
10:04Imagine this:
>> def: object [a: b: c: none]
== make object! [
    a: none
    b: none
    c: none
]
>> make def object [c: 1 b: 2]
== make object! [
    a: none
    b: 2
    c: 1
]

so far it is good. But now imagine that I have object with many other keys:
>> data: object [x: 3 a: 1 y: none]
== make object! [
    x: 3
    a: 1
    y: none
]

and I want to normalize it to object with only the required keys... so I would like to have this:
>> make def data
== make object! [
    a: 1
    b: none
    c: none
]

instead of current:
>> make def data
== make object! [
    a: none
    b: none
    c: none
    x: 3
    y: none
]
hiiamboris
10:08@Oldes It's easy. Just set copy def data
Oldes
10:09@hiiamboris it does not give what I want:
>> set copy def data
== make object! [
    x: 3
    a: 1
    y: none
]
hiiamboris
10:11Ok correction: set new: copy def data
10:11
>> new
== make object! [
    a: 1
    b: none
    c: none
]
10:12set apparently returns it's 2nd argument
Oldes
10:12hm... much better:)
10:23Still wonder if make OBJECT OBJECT could not produce same results. How common this pattern is now?
10:25I think that the most common is make OBJECT BLOCK
hiiamboris
10:26In R2/R3 make object object combines both objects (and it's symmetrical). So, probably a compatibility matter.
10:29Well, not exactly symmetrical, as it prefers values of the 2nd object with words common to both...
10:29But you get the point
lepinekong_twitter
12:24@greggirwin I meant outside of vscode only. @qtxie ok thanks.
12:26I want to refine my timer https://redlang.red/timer with timer/start and timer/stop which should be async: in what object can I access the console window rate and on-time event to do so ?
dsunanda
12:43@Oldes R3 (not R2) can remove fields that have the value of NONE - it uses TRIM. Arguably, that is a compatibility wish that Red may one day consider:
obj: make object! [a: 1 b: none c: 0]
trim obj
== make object! [
    a: 1
    c: 0
]
nedzadarek
13:42@hiiamboris

> Well, not exactly symmetrical, as it prefers values of the 2nd object with words common to both...

In both cases a is none. In a first case a should be 1. If above sentence is true.

def: object [a: b: c: none]
data: object [x: 3 a: 1 y: none]
make def data
comment {
== make object! [
    a: none
    b: none
    c: none
    x: 3
    y: none
]
}

make data def
comment {
== make object! [
    x: 3
    a: none
    y: none
    b: none
    c: none
]
}
Oldes
13:54@dockimbel is it by design that the values are not being copied and rebind when user set obj1 obj2? Having:
def: object [int: ser: fce: none]
data: object [ser: "ah" int: 1 fce: does [int: int * 2] foo: 'nothing]
new: copy def
set new data
append new/ser "a"
new/fce

result:
>> new
== make object! [
    int: 1
    ser: "aha"
    fce: func [][int: int * 2]
]
>> data
== make object! [
    ser: "aha" ;<-- notice that the original data is also changed as the set does not copy, (probably OK)
    int: 2     ;<-- calling `new/fce` modified data in the original context and not the new one (BAD?) 
    fce: func [][int: int * 2]
    foo: 'nothing
]
13:57@dsunanda trim on object may be useful, but not in my case. I don't want to remove all none values.
hiiamboris
15:49@nedzadarek try R3
gltewalt
20:22https://www.red-lang.org/2014/12/050-objects-support.html
nedzadarek
20:29@hiiamboris ah, it was in R3.
rebred
21:54is there a command to flip an image horizontally ?
hiiamboris
22:04matrix [-1 0 0 1 image/size/x 0]
rebred
22:23
view [
	size 400x400
	img: image %/test.png
]

22:23where do I plug it ?
hiiamboris
22:26into draw dialect block
22:26https://doc.red-lang.org/en/draw.html
rebred
22:37@hiiamboris do I have to apply this command inside the view ?
hiiamboris
22:41image draw [matrix [...] image (load %/test.png)] smth like that
22:41maybe with compose
22:42:city_sunset: :zzz:
ComradeSparklePony
23:13Hello. I'm new to Red, and I'm working on a GUI project. Is there a way in Red to have scrollable GUIs? I've searched the documentation and helpin.red, but the only mention of "scroll" that I have found have to do with area, text-list, drop-list, and drop-down, as well as scroll being reserved for future use. Thank you.
greggirwin
23:15@Oldes, et al, I have old keep-words/remove-words funcs, from R2 days, which are clear names for those needs.

Interesting to note that in the article @gltewalt pointed to, it says get can work on objects, but that's not currently the case. I don't know if the type spec was added later, but the def for get in %environment/natives.red doesn't include it. get* in %runtime/natives.reds looks like it supports it though. Looks like an easy feature to fix/add.
23:22@ComradeSparklePony, if you mean like a browser page scrolls, no. I think someone has done an example for it, but can't recall who. Basically, something like this:
view [
	size 450x400
	across
	p: panel 380x800 [
		below
		area "A" 350x200
		area "B" 350x200
		area "C" 350x200
		area "D" 350x200
	]
	scroller 16x400 [
		p/offset/y: to integer! negate face/data * 800
	]
]
23:23Feel free to ask more questions, since you're new to Red. That example may not be clear.
ComradeSparklePony
23:23@greggirwin I think I understand. I'll give it a try. Thank you.
rebred
23:25
view [
	img: image 300x300 %/test.png
]

I have a PNG image 300x300 called img. I would like to copy the to left hand corner of it 0x0 100x100 into a new image
nedzadarek
23:26@hiiamboris @rebred you can use draw function that draw it into image:
i: draw 100x100 [text 0x0 "ABCDEF"]
i2: draw 100x100 compose/deep [image i matrix [-1 0 0 1 (i/size/x) 0] image i] ? i2
23:27^^ about flipping images
greggirwin
23:27
>> partial: copy/part fstk-logo 32x32
== make image! [32x32 #{
    393A3C34393B34393B34393B34393B34393B34393B34393B34393B34393B
    34393B34393B34393B34393B34393B...
>> view [image fstk-logo  image partial]
rebred
23:29@nedzadarek great thanks!
greggirwin
23:40Matrix may be preferred, but you can also easily just use corner coordinates to flip images. e.g. view [image fstk-logo base 64x64 draw [image fstk-logo 64x0 0x64]]
rebred
23:40@greggirwin what is fstk-logo
greggirwin
23:42The Fullstack logo, which is included in Red by default. Just an image that's handy.
23:43Try using help fstk-logo or help image!.
rebred
23:43when I type partial: copy/part fstk-logo 32x32
23:43I get:

>> partial: copy/part fstk-logo 32x32
*** Script Error: fstk-logo has no value
*** Where: copy
*** Stack:
greggirwin
23:44Try from the GUI console, not the CLI console.

rebred
00:01Gregg Irwin ./red --cli
00:01is this the CLI console ?
00:03I still get:

--== Red 0.6.4 ==-- 
Type HELP for starting information. 

>> partial: copy/part fstk-logo 32x32
*** Script Error: fstk-logo has no value
*** Where: copy
*** Stack:
greggirwin
00:12That's the CLI console. Run it without --cli.
rebred
00:14I did. I get the same problem
00:20
>> help fstk-logo
No matching values were found in the global context.

>> help image!.
No matching values were found in the global context.

>>
greggirwin
00:21help image! (no dot at the end).
00:23What does about say?
rebred
00:23Red 0.6.4 for macOS built 19-Jan-2019/13:54:56+01:00 commit #4880ddb
nedzadarek
00:25@rebred the same version works on the Windows (8.1)
greggirwin
00:25Hmmm. I wonder if it's not in the MacOS build. Can someone else confirm? Any image will do, I just use fstk-logo because (I thought) it woudl be more readily available.
rebred
00:30
>> empty-img: make image! 300x300 
== make image! [300x300 #{
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF...
>> partial: copy/part empty-img 32x32
*** Script Error: partial: needs a value
*** Where: partial
*** Stack:
greggirwin
00:34
>> empty-img: make image! 300x300 
== make image! [300x300 #{
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
    FFFFFFFFFFFFFFFFFFFFFFFFFFFF...
>> partial: copy/part empty-img 32x32
== make image! [32x32 #{
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF...

Can someone else confirm the issue on MacOS?
rebred
00:40
>> about
Red 0.6.4 for macOS built 30-Jan-2019/7:03:13+01:00 commit #25ef631

>> empty-img: make image! 300x300
== make image! [300x300 #{
    FFFFFFFFFFFFFFFFFFFF...
>> partial: copy/part empty-img 32x32
*** Script Error: partial: needs a value
*** Where: partial
*** Stack:
00:40also the latest build does this
00:53is there a way around to copy part of an image
rcqls
05:49@greggirwin confirmed with latest red:
>> empty-img: make image! 300x300
== make image! [300x300 #{
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF...
>> partial: copy/part empty-img 32x32
*** Script Error: partial: needs a value
*** Where: partial
*** Stack:

05:54And not yet implemented on linux (GTK):
>> empty-img: make image! 300x300
== make image! [300x300 #{
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF...
>> partial: copy/part empty-img 32x32
== make image! [0x0 #{}]
>>

To add to the todo list...
greggirwin
06:16Thanks @rcqls. @endo64, do you know if this is a known issue on MacOS, or should we ping @qtxie to check?
qtxie
07:06@greggirwin Looks like a bug. It should be supported on macOS.
toomasv
08:32@greggirwin @ComradeSparklePony A bit elaborated :point_up: [January 31, 2019 1:22 AM](https://gitter.im/red/help?at=5c5231a28aa5ca5abf5b1253):
view [
    size 390x220
    across space 0x0
    panel 350x200 [
        origin 0x0 space 0x0
        p: panel 350x800 [
            origin 0x0 space 0x0
            below
            area "A" 350x200
            area "B" 350x200
            area "C" 350x200
            area "D" 350x200
        ]
    ]
    scroller 16x200 [
        face/data: min .75 face/data
        p/offset/y: to integer! negate 800 * face/data
    ] 
    on-created [face/selected: 25%]
]
09:14Embedded scroller:
view [
    size 390x220
    across space 0x0
    base 367x200 with [
		flags: 'scrollable
		pane: layout/only [
			origin 0x0 space 0x0
			p: panel 350x800 [
				origin 0x0 space 0x0
				below
				area "A" 350x200
				area "B" 350x200
				area "C" 350x200
				area "D" 350x200
			]
		]
	]
	on-created [
		put get-scroller face 'horizontal 'visible? no
		sc: get-scroller face 'vertical
		sc/position: 0
		sc/page-size: 200
		sc/max-size: 800
	]
	on-scroll [
		sc/position: max 0 min 600 switch event/key [
			down [sc/position + 20]
			up [sc/position - 20]
			page-down [sc/position + sc/page-size]
			page-up [sc/position - sc/page-size]
			track [event/picked - 1]
			end [sc/position]
		]
		p/offset: as-pair 0 negate sc/position
	] 
]
lepinekong_twitter
13:56@toomasv Great I needed that also, thanks :)
toomasv
13:59@lepinekong_twitter :)
abdllhygt
16:08Hey, how can i see bank balance or transfers by Red?
rebolek
16:21That depends if your bank has some API support. All EU will be required to have API later this year and lot of banks will be using Open Banking API. So if your bank supports it, then you can implement trhis API in Red and use it.
greggirwin
20:30@toomasv nice!

Would someone please open a ticket for the bug @qtxie confirmed?
rebred
21:11
map: [
      1 2 3
      4 5 6
      7 8 9
]

I have this block called map. Is there a way to access column 1 and row 3 with something like map/(1x3) ?
hiiamboris
21:12@rebred you'll have to make a custom accessor func, based on the newline? hack
greggirwin
21:14Or do it like this:
map: [
      [1 2 3]
      [4 5 6]
      [7 8 9]
]
map/1/3
21:15But note that map may become a standard FP mapping func, name wise.
rebred
21:15thanks!
hiiamboris
21:23@rebred Github avatar base is 20 x 2^15 = 655360, yet you get one so similar to @nedzadarek. An *amazing* coincidence.
greggirwin
21:26Blockophones? (blockie-homophones)
hiiamboris
rebolek
21:28Why 20x? colors? Anyway, similarity is a concept that makes the odds very high, unlike statistics.
hiiamboris
21:28Yes, colors.
rebred
21:41
total: ""
repeat n 20 [
	str: rejoin ["img" n ": image 30x30 "]
	append total str
]


when I do this I get curly braces {} in front and back of the string total. is there a way to avoid having them after append>
greggirwin
21:56It's still a string, just that Red changes to the multi-line string chars when molding long strings (>= 50 chars). It's only the molded output you see that's different.
rebred
22:03
total: ""
repeat n 20 [
	str: rejoin [" img" n ": image 30x30 "]
	append total str
	probe total
	total2: load total
	probe total2
]

22:03load apparently removes the curly braces
greggirwin
22:06Because it turns it into a block, so it is no longer a string.
nedzadarek
22:08@hiiamboris
> An amazing coincidence.

Yes, like winning 1 million dollars in a lottery... but without money.
rebolek
22:08Deja vu

gltewalt
00:24Should take affect all fields?
00:24
>> o: object [a: b: c: d: none]
== make object! [
    a: none
    b: none
    c: none
    d: none
]
>> set o "heavy gold"
== "heavy gold"
>> o
== make object! [
    a: "heavy gold"
    b: "heavy gold"
    c: "heavy gold"
    d: "heavy gold"
]
>> loop 6 [take o/a]
== #" "
>> o
== make object! [
    a: "gold"
    b: "gold"
    c: "gold"
    d: "gold"
]
greggirwin
00:30In this case, yes, as you are setting all the words to the same series value.
>> set o reduce ["heavy gold" copy "heavy gold"]
== ["heavy gold" "heavy gold"]
>> o
== make object! [
    a: "heavy gold"
    b: "heavy gold"
    c: none
    d: none
]
>> loop 6 [take o/a]
== #" "
>> o
== make object! [
    a: "gold"
    b: "heavy gold"
    c: none
    d: none
]
gltewalt
00:32But setting to a different value doesn’t change all values. o/a: 42
00:34Maybe it does with series. Didn’t try that.
00:47
>> o
== make object! [
    a: "hi"
    b: "hi"
    c: "hi"
    d: "hi"
]

>> set 'o/a "x"
== "x"
>> o
== make object! [
    a: "x"
    b: "hi"
    c: "hi"
    d: "hi"
]
greggirwin
01:20In the last example, you're setting a single word to a new series value. When using set with an object, block and object values are treated specially (as multiple values).
01:21Good info for an article, or extended function help.
01:22Also, if you use set/only object and block values are treated like other values (singly).
01:25
>> o: object [a: 1 b: 2 c: 3]
== make object! [
    a: 1
    b: 2
    c: 3
]
>> set o object [a: 11 b: 12]
== make object! [
    a: 11
    b: 12
]
>> o
== make object! [
    a: 11
    b: 12
    c: 3
]
>> set/only o object [a: 11 b: 12]
== make object! [
    a: 11
    b: 12
]
>> o
== make object! [
    a: make object! [
        a: 11
        b: 12
    ]
    b: make object! [
        a: 11
        b: 1...
>> probe o
make object! [
    a: make object! [
        a: 11
        b: 12
    ]
    b: make object! [
        a: 11
        b: 12
    ]
    c: make object! [
        a: 11
        b: 12
    ]
]
...

AlexanderBaggett
19:53@greggirwin , it's not even my question, but that just blew my mind a bit. Cool stuff.
ComradeSparklePony
22:34@toomasv @greggirwin This is what I ended up with:
view [
    size 600x400
     p: panel [
        below
        text "A"
        text "B"
        text "C"
        text "D"
    ]
    scroll: base 16x200 loose react [
        face/offset/y: (max (min 195 face/offset/y) 5)
        face/offset/x: scrollx
        p/offset/y: to integer! negate face/offset/y
    ]
    do [scrollx: scroll/offset/x]
]

Does that look about right?
greggirwin
22:44@ComradeSparklePony it works here, if a bit roughly. I get a lot of flashing/artifacts if I move the mouse horizontally. If you can, see if @toomasv's examples can be adapted for your needs, as they're solid. That said, you are certainly getting the hang of things.
22:46For your max (min ... logic, I have a simple limit func, which I find useful to making my intent clear.
limit: function [
	"Returns a value constrained between two boundaries (inclusive)."
	value
	bound-1
	bound-2
][
	lower: min bound-1 bound-2
	upper: max bound-1 bound-2
	max lower min upper value
]
22:50@AlexanderBaggett Red makes you think differently. Where other langs might have third party or standard libs, all with very specific interfaces and behaviors, Red has deep behavior that isn't always obvious. This can be good and bad. For experts, it's generally very good, though can lead to gotchas at times. It's harder on new Reducers, but the rewards are worth it.
ComradeSparklePony
23:03I'm probably missing something, but neither of toomasv's examples worked for me. For the first example (and yours), I get an error saying that "scroller" is an invalid face type, and the second one crashes due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]' (might have something to do with the fact that I use a mac). I fiddled with things until I got something that worked, which is what I send above.
23:08A quick search for the 'uncaught exception' error shows that it does have something to do with Apple's ecosystem.
greggirwin
23:14Ah, you must be on MacOS. Scroller may not be supported there yet. Sorry about that.
23:16@qtxie, do we have an ETA/priority on MacOS scroller support?

ComradeSparklePony
01:07That makes sense. I'll just stick with what I have for now, but keep scroller in mind for the future. Thank you very much.
qtxie
02:07@greggirwin AFAIK, the design of the scroller has not been finished yet.
Rebol2Red
09:05Why is'nt there a function which fetches the filename without the extension?
Because i can't find one i am curious how you would program this.
filename: %/C/Users/Tijs/Desktop/ONE-TIME-PAD/IMG-20190126-WA0008.jpg

Getting:
The Folder
The filename without the extension
The extension
rebolek
09:09@Rebol2Red
>> path: copy/part filename next find/last filename #"/"
== %/C/Users/Tijs/Desktop/ONE-TIME-PAD/
>> file: skip filename length? path
== %IMG-20190126-WA0008.jpg
>> extension: find/last file dot
== %.jpg
hiiamboris
09:22Also mind:
>> ? split-path
USAGE:
     SPLIT-PATH target

DESCRIPTION: 
     Splits a file or URL path. Returns a block containing path and target. 
     SPLIT-PATH is a function! value.

ARGUMENTS:
     target       [file! url!]
09:23e.g. set [path file] split-path filename
Rebol2Red
09:23@hiiamboris @rebolek Thanks
I'm gonna use: split-path and a part of reboleks code: file: skip filename length? path
I like to see some different ways from other programmers to pick the one that suits me the most. More input please.
filename: %/C/Users/Tijs/Desktop/ONE-TIME-PAD/IMG-20190126-WA0008.jpg
folder-and-filename: 	split-path filename
folder: 				folder-and-filename/1
filename-no-extension: 	skip filename length? folder-and-filename/1
filename-extension: 	suffix? filename
probe folder
probe filename-no-extension
probe filename-extension
hiiamboris
09:34:+1:
Rebol2Red
09:42Maybe as a function for common use
splitting-filename: function ["Splits a complete filepath into folder, filename-no-extension and filename-extension"
	filename [file!]
][
	folder-and-filename: 	split-path filename
	folder: 				folder-and-filename/1
	filename-no-extension: 	skip filename length? folder-and-filename/1
	filename-extension: 	suffix? filename
	return reduce [folder filename-no-extension filename-extension]
]

filename: %/C/Users/Tijs/Desktop/ONE-TIME-PAD/IMG-20190126-WA0008.jpg

splitted: splitting-filename filename
probe splitted/1
probe splitted/2
probe splitted/3

This can be better though. Any idea how?
10:09Maybe this is better
split-filename: func ["Splits a complete filepath into folder, filename-no-extension and filename-extension"
	filename [file!]
][
	filename-complete: 		split-path filename
	filename-folder: 		filename-complete/1
	filename-no-extension: 	skip filename length? filename-complete/1
	filename-extension: 	suffix? filename
]

filename: %/C/Users/Tijs/Desktop/ONE-TIME-PAD/IMG-20190126-WA0008.jpg

split-filename filename
probe filename-folder
probe filename-no-extension
probe filename-extension

And ofcourse putting the function into a #include file
hiiamboris
10:11@Rebol2Red better to use function and reduce like you did before or it will pollute the system/words context
schwarzbox
10:16 I define function with zero or more arguments.

noarg: function [args [any-type!]] [
    unless attempt [print args][print ""]
]
noarg ['print [0 0 0] red none]
noarg 196
noarg

manyarg: function [args [block!]][
    print args
]
manyarg ['print [0 0 0] red none]
manyarg [196]
manyarg []

Any other ways? Or how works native "print" when take "any-type!" ?

Rebol2Red
10:17@hiiamboris I agree, but i like the idea of using split-filename filename as if it was a built-in function and the use of meaningfull words like filename-folder, filename-no-extension and filename-extension. I do not think anybody uses these words in other parts of their programs.
hiiamboris
10:23@Rebol2Red Consider this code:
f1: does [
   sp: split-filename fn
   if something = f2 fn [ ... ]
   if something-else = filename-folder [...]
]

What if it's not you who wrote f2 or you've forgotten it's source. If f2 uses split-filename too, it will replace all the used words and you'll have an extra bug hunting session
10:25@schwarzbox I believe there's a mistake in native print spec. It should take default! type not any-type!. Your own definition is a correct usage of variable arity, except you may not realize you're pushing manyarg as an argument to your 3rd noarg call ;)
10:27To call noarg with no arguments: (noarg) or do [noarg]
Rebol2Red
10:30@hiiamboris I see. Didn't think of that! I still find it confusing when and why to use func or function. Is there a rule for it? Maybe one should always use function to set words local?
hiiamboris
10:32@Rebol2Red sometimes you work in a context [..] and set a lot of words local to that context, in this case func is very handy (otherwise you'll be using set 'myword .. everytime instead of concise myword: ...
Rebol2Red
10:41@hiiamboris
Do you mean if i place split-filename in a context i can use func without polluting the system/words context?
Like this:
filehandling: context [
	split-filename: func ["Splits a complete filepath into folder, filename-no-extension and filename-extension"
		filename [file!]
	][
		filename-complete: 		split-path filename
		filename-folder: 		filename-complete/1
		filename-no-extension: 	skip filename length? filename-complete/1
		filename-extension: 	suffix? filename
	]
]

filename: %/C/Users/Tijs/Desktop/ONE-TIME-PAD/IMG-20190126-WA0008.jpg

filehandling/split-filename filename
probe filename-folder
probe filename-no-extension
probe filename-extension
10:51Another somehow (or somewhat?) related question:
If i place 2 functions into a seperate file, #include this file and use only one function of it does the other function gets into memory or only takes up some diskspace? I think it will only takes up some diskspace but i want to be sure.
endo64
11:00You can check with values? 'args inside the function.
schwarzbox
11:02@hiiamboris Thank you. You right. It hard to realize that "print" throw an error without arguments. If I call my function in console (noarg) or call in console (print) it show same error. I made it first time now :-)
Also it helps me understand what happen here.
With you help I find solution for my project and better understand how to work Red function.

print: func [argument [any-type!]][
append append console/text newline form reduce argument
return reduce argument
]
`

Now all output goes to Console in my application. It include output of debug "print" from source code. Maybe I find "unexpected behavior" But It destiny.
hiiamboris
12:24> Do you mean if i place split-filename in a context i can use func without polluting the system/words context?

@Rebol2Red yes, though the context is still shared.

> does the other function gets into memory or only takes up some diskspace?

Memory too. Shouldn't be your problem unless you *can* write a gigabyte of functions...
12:30@schwarzbox I have forgotten that variable-arity doesn't work with normal arguments.. You need to make the argument literal:
>> noarg: function ['args [any-type!]] [if value? 'args [print args]]
== func ['args [any-type!]][if value? 'args [print args]]
>> noarg 123
123
>> noarg ["hello" "world"]
hello world
>> (noarg)
== none
12:31print having any-type arg is ok then...
Rebol2Red
12:59Now my question is how to make a library of functions the right way?

Some questions which arised:
Every function in a seperate file?
One big file with all related functions ex. filehandling.red contains function split-filename etc?
One really big file with all the functions?
Use context and func or ... and function?
Use #include?

Maybe someone has a library somewhere to look at
hiiamboris
13:12Do you think there's a single universal answer for all the possible circumstances out there? ;)
Rebol2Red
13:19 No, but there must be some guidelines i can use.
How do you implement a library?
hiiamboris
13:22Just use your library how you like it. You'll know it when it becomes ugly. Red has no package system yet, so no guidelines either. @rebolek has a simplistic prototype, you can try to fit your code into his model.
13:23https://gitlab.com/rebolek/redquire
Rebol2Red
13:24@hiiamboris I really appreciate your help, many thanks.
hiiamboris
13:29You're welcome ☻
toomasv
14:35@ComradeSparklePony Two ideas for custom scrollers. First is based on structured faces:
clear-reactions
view [
	p: panel 370x200 [
		origin 0x0 space 0x0
		pan: panel 350x800 [
			origin 0x0 space 0x0
			style ar: area 350x200
			below
			ar "A" ar "B" ar "C" ar "D"
		]
		pad 1x-1
		panel 17x200 [
			origin 0x0 space 0x-1
			below
			button 17x16 [knob/offset/y: val/data: min 126 max 0 knob/offset/y - 7]
			base 220.220.220 17x168 with [
				pane: layout/only compose [
					at 1x0 knob: box silver loose (as-pair 15 168 / 4)
					on-drag [face/offset: as-pair 1 val/data: min 126 max 0 face/offset/y]
				]
			] on-down [
				knob/offset/y: val/data: min 126 max 0 knob/offset/y + pick [-42 42] event/offset/y < knob/offset/y
			]
			pad 0x-1
			button 17x16 [knob/offset/y: val/data: min 126 max 0 knob/offset/y + 7]
		]
	]
	at 0x0 val: field "0" hidden
	react later [pan/offset/y: negate to-integer face/data * 1.0 / 168 * 800]
]

Second is draw-based:
clear-reactions
view [
	p: panel 366x200 [
		origin 0x0 space 0x0
		pan: panel 350x800 [
			origin 0x0 space 0x0
			style ar: area 350x200
			below
			ar "A" ar "B" ar "C" ar "D"
		] 
		box 17x200 draw [
			pen off fill-pen 200.200.200
			upper: box 0x0 16x16
			lower: box 0x184 16x199 
			fill-pen 220.220.220
			long: box 0x16 16x184
			fill-pen silver
			knob: box 1x16 14x58
		] on-down [
			either all [within? event/offset knob/2 knob/3 - knob/2] [
				face/extra: knob/2/y - event/offset/y
			][
				knob/2/y: val/data: min 142 max 16 knob/2/y + case [
					within? event/offset upper/2 upper/3 - upper/2 [-7]
					within? event/offset lower/2 lower/3 - lower/2 [7]
					within? event/offset long/2 knob/2 + 16x0 - long/2 [-42]
					within? event/offset knob/3 - 16x0 long/3 - (knob/3 - 16x0) [42]
				]
				knob/3/y: knob/2/y + 42
			]
			'stop
		] all-over on-over [
			if all [within? event/offset knob/2 knob/3 - knob/2 event/down?][
				knob/2/y: val/data: min 142 max 16 event/offset/y + face/extra
				knob/3/y: knob/2/y + 42
			] 
		]
	]
	at 0x0 val: field "0" hidden
	react later [pan/offset/y: negate to-integer face/data - 16 * 1.0 / 168 * 800]
]

And then there is @rebolek's object-based [scroller style](https://gitlab.com/rebolek/red-styles/blob/master/scroller.red) to learn from.
lepinekong_twitter
18:31@Rebol2Red I'm working on this as I have a huge system with hundreds small libraries. I have made this simple macro https://redlang.red/include which worked really great except there seems a red bug that prevents it to work inside a function https://gitter.im/red/help?at=5c4f7ad513a2814df6e17e57 so hope it will be fixed @dockimbel ;) meanwhile I'm looking for an other idea (not found yet) and I'm also working on a cache engine to have full offline mode or online mode depending on user choice or internet connection (when I travel in cambodia I may not have internet connection for example). This is just the beginning https://redlang.red/cache (things more complicated for me as I also have to take into account "html proxy" https://redlang.red/html-proxy)
greggirwin
19:18@Rebol2Red modules will come in a future release. In the meantime, what I've done in the past is to use a context as a namespace, and you can choose to selectively expose functions from it.
lepinekong_twitter
20:58@greggirwin is there info somewhere about what features will red module have ?
21:24Found this :) https://www.fys.ku.dk/~niclasen/nicomdb/thesis.pdf

rebred
00:14since this doesn't work:
partial: copy/part empty-img 64x64
I am copying one pixel at the time with this but it's very slow:
poke sprite1 1x1 sprite_sheet/(1x1)
is there a faster way ?
greggirwin
01:13@lepinekong_twitter the design is not set yet. We have a lot of history to learn from, but also can't just take one whole cloth, because of Red's design and capabilities. The combination of dynamism and a clear need for modular compilation support, are an example.
rebred
02:14is there a way to attach/append an image to another on the x axis or y axis
greggirwin
03:52Not natively. It's a good exercise for you. :^) Check out https://doc.red-lang.org/en/datatypes/image.html and ask questions here as you try things.
nedzadarek
09:32@greggirwin can we resize images?
@rebred here is my try, if you want to compare:
red-image: make image! 100x100 red-image/rgb: red
blue-image: make image! 100x100 blue-image/rgb: blue
res-x: draw 200x100 [
    image red-image 
    translate 100x0 [image blue-image]
]
? res-x
res-y: draw 100x200 [
    image red-image 
    translate 0x100 [image blue-image]
]
? res-y
lepinekong_twitter
10:21@greggirwin ok thanks. So I'll continue my dev and will replace some parts when red module will be out :)
toomasv
10:33 @nedzadarek

> can we resize images?

One possibility is to use scaling:
res-x: draw 200x200 [
	scale 1 2 
	image red-image
	translate 100x0 [image blue-image]
]
nedzadarek
10:46@toomasv sorry, If I haven't mentioned it but I mean "in place". For example you have img: make image! 100x100 and few steps later your img has size 200x200. We are using draw that returns new image.
toomasv
rebred
11:36@nedzadarek great!!! thank you!!!!
nedzadarek
12:51@rebred You're welcome.
lepinekong_twitter
17:20@schwarzbox I think the usual way is to use unset!
greggirwin
17:53@nedzadarek you can draw images into new images, as you've shown, but you can't just change the /size of an image and have it update its contents.
Rebol2Red
20:25> Maybe as a function for common use
>
> splitting-filename: function ["Splits a complete filepath into folder, filename-no-extension and filename-extension"
> 	filename [file!]
> ][
> 	folder-and-filename: 	split-path filename
> 	folder: 				folder-and-filename/1
> 	filename-no-extension: 	skip filename length? folder-and-filename/1
> 	filename-extension: 	suffix? filename
> 	return reduce [folder filename-no-extension filename-extension]
> ]
> 
> filename: %/C/Users/Tijs/Desktop/ONE-TIME-PAD/IMG-20190126-WA0008.jpg
> 
> splitted: splitting-filename filename
> probe splitted/1
> probe splitted/2
> probe splitted/3
>

> This can be better though. Any idea how?

Oeps, code was wrong, updated version:
split-filename: function ["Splits a full filepath into folder, filename-no-extension and filename-extension"
	filename [file!]
][
	
	filename-folder: 		copy/part filename next find/last filename #"/"
	filename-complete: 		skip filename length? filename-folder
	filename-no-extension: 	copy/part filename-complete find/last filename-complete #"."
	filename-extension: 	suffix? filename
	return reduce [filename-folder filename-no-extension filename-extension]
]

filename: %/C/Users/Tijs/Desktop/ONE-TIME-PAD/IMG-20190126-WA0008.jpg
splitted:				split-filename filename				
filename-folder: 		to-string to-local-file splitted/1 
filename-no-extension: 	to-string splitted/2
filename-extension: 	to-string splitted/3
print filename-folder
print filename-no-extension 
print filename-extension
; Adjust the code (not the code inside the function!)
; for ex. if you want the results as a (Red)file-type and/or the extension with/without "."

This code could be better, i only don't know how :(
nedzadarek
20:58@Rebol2Red You could use split-path & suffix? but split-path just split into dir - last element pair, so you have to check if the last element is a file:

split-filename: function [path [file!]] [
    splitted: split-path path
    either dir? splitted/2 [
        do make error! "Wrong filepath" ; I assume you want proper file, not directory, hence an error
    ][
        dir: splitted/1
        filename: splitted/2
        
        extension: suffix? filename
        
        
        filename-no-extension: either dot: find filename #"." [
            copy/part filename dot
        ][
            filename-no-extension: filename
        ]
    ]
    
    return reduce [
        'dir dir
        'filename-no-extension filename-no-extension
        'extension extension
    ]
]

Output:
>> split-filename %foo.red
== [dir %./ filename-no-extension %foo extension %.red]
>> split-filename %foo/baz.red
== [dir %foo/ filename-no-extension %baz extension %.red]
>> split-filename %foo
== [dir %./ filename-no-extension %foo extension none]
>> split-filename %foo/baz/
*** User Error: "Wrong filepath"
*** Where: do
*** Stack: split-filename  
>> split-filename %foo/baz
== [dir %foo/ filename-no-extension %baz extension none]
endo64
22:26@nedzadarek dot: find filename #"." gives you the first dot which is not necessarily the extension if the filename has more dots, find/last would be better.
lepinekong_twitter
22:38trim/auto => Auto indents lines relative to first line: I tried it doesn't seem to work?
endo64
23:07From the source code of trim: auto? [--NOT_IMPLEMENTED--]
23:08So it should give not implemented error, doesn't it?
amreus
23:12@endo64 Similarly, mold/flat appears to work but docs say "TBD"

a: [a b c d e f g]
b: new-line/all a on
mold/flat b
== "[a b c d e f g]"

nedzadarek
23:24@endo64 good point! :+1: I have forgotten about such file names.
23:58@endo64 load just note it in the help:
/header      => TBD.
     /all         => Load all values, returns a block. TBD: Don't evaluate Red header.

lepinekong_twitter
01:08I've been shuffling files around and had finally found the perfect organization to scale the organisation of hundreds of files for complex project (I'm not the only to use this "method" that's what reactjs guru does also :) https://publish.twitter.com/?query=https%3A%2F%2Ftwitter.com%2Fdan_abramov%2Fstatus%2F1027245759232651270&widget=Tweet) and It's really frustrating to have this nasty bug about #macro https://gitter.im/red/help?at=5c4f7ad513a2814df6e17e57 because I cannot find a workaround.
greggirwin
06:28/auto should at least have a "TBD" in the doc string.
06:28An error would be even better.
06:34It does look like mold/flat works, so we can remove the TBD in that doc string.
06:36@Rebol2Red on your file splitting function, having direct funcs for the values can make things clearer, and avoid a lot of work, as you don't always need all the parts. But it can also be nice to do it like you are, in some cases. There I would use an object as the return type, so the fields are named. Otherwise people have to know the offsets of each field in the return block, which is, again, more work.
lepinekong_twitter
10:11:point_up: [February 3, 2019 11:21 AM](https://gitter.im/red/help?at=5c56c0a2ca428b06454936da) @greggirwin nevertheless one should learn from dozens of years of experiences in other programming languages, module alone is not enough to scale a big project or rather a bunch of loosely couples projects, so they use ugly hacks like OS symbolic links, git sub-modules etc... which I don't want to use. That's why I insist on solving the red bug about macro, it helps to solve the problem elegantly.
hiiamboris
10:15@lepinekong_twitter :point_up: [January 29, 2019 2:13 PM](https://gitter.im/red/help?at=5c50356454f21a71a1c4394b)
10:16Complaining is a valid but ineffective move in this game ;)
lepinekong_twitter
11:13@hiiamboris what game is red just about toy ;) in fact I have decided I'm going to switch the project to nodejs in coming months, though I'll continue in // in red as experimental.
rebolek
11:26Red is not toy, but alpha software.
nedzadarek
11:29@rebolek but it does not mean you cannot toy with it. But, yes, it is in early stage.
rebolek
11:30@nedzadarek of course you can, you just don't have to expect it's fully featured yet.
nedzadarek
11:30I agree @rebolek
hiiamboris
11:36@lepinekong_twitter The game between you and Red.
11:38You like to bring about changes, make a stronger move. You like complaining, keep it up ;)
lepinekong_twitter
12:23@rebolek I'm not talking about feature I'm talking about a bug in core feature. There are others in fact like http. The community should become focused on the right priority or I fear red is going to finish like rebol:
https://arnoldvanhofwegen.com/blog/r3n-taking-control-of-open-sourced-rebol-3/
rebolek
12:24@lepinekong_twitter if there's a bug, you should [report it](https://github.com/red/red/issues)
12:26I'm not going to comment on iArnold's blog.
lepinekong_twitter
12:26@rebolek ok I'll report it.
rebolek
12:28@lepinekong_twitter Thanks. This way it can get proper attention and won't be buried in chat.
lepinekong_twitter
12:29@rebolek I will add this: if you have ever participated in a true software business application today, not just system language, you'll know the problem is no more about coding as said:
"There’s a big gap—a veritable chasm, you might say—between the mere act of writing code and the development of mobile apps that deliver the highest value to customers, and do so at the lowest cost to your business.

The various practices that have come to be known collectively as DevOps are essentially what help you bridge that chasm." https://msdn.microsoft.com/magazine/mt767694
so if you want red to be have any real advantage it should be on stuffs that helps managing code and just be expressive.
hiiamboris
14:37@lepinekong_twitter As I've promised, you now have a [workaround](https://github.com/red/red/issues/3771#issuecomment-460271079) for your MAJOR bug ☻
rebred
23:03I am trying the sqlite library
23:03https://github.com/red/code/tree/master/Library/SQLite
23:03I downloaded all the files in a folder
23:04do these files need to be compiled ?
23:05when I copy and paste the content of SQLite3-test.red in the terminal, it gives me a bunch of errors
greggirwin
23:09@rebred, yes, Red/System code (%.reds extension) always has to be compiled. We'll eventually have an interpreted FFI at the Red level as well though.
rebred
23:17
./redlast.dms -c SQLite3.reds

-=== Red Compiler 0.6.4 ===- 

Compiling /scripts/SQLite3.reds ...

Target: Darwin 

Compiling to native code...
*** Loading Error: file access error: %definitions.reds 
*** in file: %/scripts/SQLite3.reds 
*** at line: 15
23:50I added definitions.reds from the red OS folder on github
23:50I compiled all the .reds files without errors
23:52SQLite3.reds, definitions.reds, SQLite3-test.reds, SQLite3-test-basic.reds
ComradeSparklePony
23:52@toomasv I'll take a look. Thank you.
rebred
23:53when I execute SQLite3-test.red I get *** Script Error: SQLite has no value
greggirwin
23:57How are you executing it? Can you compile the test program in that folder?
rebred
23:58I am copying and pasting SQLite3-test.red into the console

greggirwin
00:12Did you clone the entire repo, so you have the %os/ folder, and the definitions it depends on?
rebred
00:12not. so I have to get all the files in the OS folder
greggirwin
00:13Correct.
rebred
00:13and compile all the .reds ? including the files inside the datatype folder
greggirwin
00:14If you compile the main %.red programs, e.g. the test apps for SQLite, they will include the %.reds files they depend on. Compiling them separately isn't what you want to do.
rebred
00:15I see
00:35I compiled again SQLite3.reds SQLite3-test.reds and SQLite3-test-basic.reds
00:36this time with all the OS files
00:36
definitions.reds 
key-hit.reds
linux.reds
time-elapsed.red
time-elapsed.reds
wait.reds
windows.reds
lepinekong_twitter
01:03@hiiamboris thanks a lot to all will look tomorrow going to bed :)
rebred
01:38I am still getting SQLite has no value. I wish he would have wrote basic instructions on how to install it
01:47will the 0.7 red include anything related to SQLite ?
ComradeSparklePony
02:19When appending an area's text to a text-list, the value of each thing in the text-list seems to change when I add something new to the text-list. For example, in the code snippet:
view [
    a: text-list data []
    b: text-list data []
    my-area: area
    button "submit a" [append a/data my-area/text]
    button "submit b" [append b/data my-area/text]
]

When I append the text "a" to the first text-list (when running the app), then append the text "b" to the second one, the text in the first list also changes to a "b." I am curious both as to why this happens, and what I can do to prevent it. I have tried unset my-area and the problem still persists. I peeked around on helpin.red and the documentation, and could not easily find an explanation. Thank you.
toomasv
04:05@ComradeSparklePony This doesn't happen on W10 but try copy my-area/text while appending. See more about [copy](https://github.com/red/red/wiki/%5BDOC%5D-Why-you-have-to-copy-series-values).
04:46I doubt this inconsistentcy between platforms is intended. According to your description macOS behaves like
>> append b1: copy [] s: "abc"
== ["abc"]
>> append b2: copy [] append clear s "def"
== ["def"]
>> print [b1 b2]
def def

But Win behaves like
>> append b1: copy [] s: "abc"
== ["abc"]
>> append b2: copy [] s: "def"
== ["def"]
>> print [b1 b2]
abc def

ComradeSparklePony
12:03@toomasv The issue arose from the fact that I did not use copy. Using copy fixed things. Thank you very much.
toomasv
12:52@ComradeSparklePony You are welcome!
githubnyn
13:52I have a text file with 1 million rows, 93MB in size.
Each row is kind of like this:
["Cheryl" "Harris" "8 Smith Court" "East Elmhurst" "NC" "44133" "352-993-7768" "drezet@me.com"]

When I first launch RED and execute:
t0: now/time/precise
temp: read/lines %test.red
final: now/time/precise - t0

it takes 2.38 seconds to read and execute the file

when I run this command again it takes 4.65 seconds

as I keep running the command it takes between 5 to over 7 seconds

why does it takes more then double and almost triple after the first time ?
rebolek
13:54I guess GC is doing the slowdown.
13:55try recycle/off and run your tests again (but expect that you may run out of memory)
githubnyn
13:56with recycle/off it takes 1.3 seconds !!!!!!!!
13:58could I do something like this every time to speed up the reading ?
recycle/off
t0: now/time/precise
temp: read/lines %test.red
final: now/time/precise - t0
recycle/on

rebolek
14:06@githubnyn well you can, but then expect some slowdown when turning the GC back on.
nedzadarek
14:11@githubnyn well, instead of turning it on and off you can turn it off, and recycle it manually:
> 2. The second function is called recycle, which triggers a manual garbage collection pass

[source](https://www.red-lang.org/2018/12/064-simple-gc-and-pure-red-gui-console.html)

You can for example do something like this:
recycle/off ; just turn it off for main session
; some code later
f: has [temp t0 final][
 temp: none
 recycle ; garbage collect your file (and maybe something else)
 t0: now/time/precise
 temp: read/lines %test.red
 final: now/time/precise - t0
]
f
f
rebolek
14:13@nedzadarek that's right, but it still won't eliminate the time required to clear the GC.
githubnyn
14:14http://www.rebol.net/cookbook/recipes/0012.html
I am using the search function from Carl

the problem is that when I use load:
temp: load %database.txt

it takes over 4 minutes and sometimes it even crashes

but when I use:
temp: read/lines %database.txt

it takes 2 to 5 seconds.

------

is there a way to search and work on the string lines directly instead of blocks or a fast alternative to load
rebolek
14:15With full IO I expect you can search in file directly instead of loading whole file into memory.
14:16Right now load/lines is the fastest way I guess.
nedzadarek
14:17@rebolek
> @nedzadarek that's right, but it still won't eliminate the time required to clear the GC.

Yes but (as it with your solution) it moves it out of "measured code".
githubnyn
14:24@rebolek @nedzadarek thank you
14:35if you open a big HTML file, modify it and use the command write to re-write it again when someone is accessing it, will they get an error ?
nedzadarek
14:56I think you should get an error because they were first.
14:56@githubnyn
githubnyn
14:59then updating a web page multiple times a day would create lots of errors
rebolek
15:00certainly not
githubnyn
15:03I guess RED could be used as scripting but it would need to be connected to a Web server or file system mechanism in order to put user on hold when saving a file
15:06does this mechanism exist where users are put on hold if the file they are trying to access is been currently been written on?
hiiamboris
15:27If your web server wasn't written by complete morons it will probably cache the file anyway, schedule update when it detects a change in the file, and read it once it becomes unlocked.
lepinekong_twitter
19:30@hiiamboris I don't understand the syntax of

#macro ['§include file!] func [s e][new-line load s/2 true]

why do I have 2 params: what is e ?

So how do I call for example like I did with my macro:

§include https://redlang.red/compare-checksum.inc



hiiamboris
19:45's' for start, 'e' for end. Of what? Of the part of the code that the [include file!] parse pattern matched.
19:45so there you have 2 tokens, s/1 = e/-2 = include, s/2 = e/-1 = file
19:47the block that the function returns - after new-line load - is substituted in the pattern's place
lepinekong_twitter
20:25@hiiamboris I try to understand: so I just need to copy and paste your line above my own macro §include and do my stuff as usual ?
hiiamboris
20:35you could've tried that 10 times already instead of asking :D
lepinekong_twitter
20:38@hiiamboris I tried but by throwing a dart at random so it didn't work ;) Now this works thanks :

#macro ['§include file!] func [s e][new-line load s/2 true]

f: function[][
§include %../hello.red
§include %../cache.red
]

hiiamboris
20:51:+1:
greggirwin
23:15> if you open a big HTML file, modify it and use the command write to re-write it again when someone is accessing it, will they get an error ?

@githubnyn, the "when someone else is accessing it" part is the key. If someone opened the file with another tool, and locked it from writing, or marked it as read-only, your write would fail. In normal use, the OS should queue file access to avoid these issues. It's possible to see problems if things are under a high load, or files are large, but not likely.
23:21> will the 0.7 red include anything related to SQLite ?

@rebred no, SQLite will not be part of basic full I/O. Maybe @Oldes will chime in with suggestions on the SQLite binding though, to get you going.
loziniak
23:28Hello. I've cross-compiled a simple program under linux with -t Windows. It's just printing a short string: Red [Needs: 'View] print "dfg". When I run it from wine, or VirtualBox with Windows 7, nothing is printed. I also experienced this behavior in other programs (eg. red wallet). Am I missing something?
Oldes
23:31@rebred @greggirwin It is not difficult to add it to console:
>> about
Red 0.6.4 for Windows built 6-Feb-2019/0:29:29+01:00

>> ? sqlite
SQLITE is an object! with the following words and values:
     output  block!        length: 0  []
     init    function!     Initializes SQLite.
     free    function!     Shutdowns SQLite.
     do      routine!      Evaluate SQLite dialect commands.
     query   function!     Executes SQL query.
23:34But there are two obstacles:
1. the Red/Code repository does not play with Red's main repository.
2. includes from included files are not relative.
23:37Ideally it would be enough to put line like:
#include %/x/GIT/Red-code/Library/SQLite/SQLite3.red

for example into [CLI console source here](https://github.com/red/red/blob/a4d8240d8b14cfdd7b4c1d9051210253ef974cd9/environment/console/CLI/console.red#L16)

But because of obstacle number 2 one must modify also the [SQLite3.red](https://github.com/red/code/blob/master/Library/SQLite/SQLite3.red) file and change [this line](https://github.com/red/code/blob/2371ed70ff96f303b1f3528e14d14ff69f42e589/Library/SQLite/SQLite3.red#L9) to look like:
#include %/x/GIT/Red-code/Library/SQLite/SQLite3.reds

(in my case)
hiiamboris
23:40@loziniak -t MSDOS
loziniak
23:41@hiiamboris thanks. And If I want both display UI and write output to console? Is there such a possibility?
hiiamboris
23:42@loziniak yes, it will display the UI as well.
loziniak
23:42So what's the benefit of using -t Windows?
hiiamboris
23:43@loziniak to not scare users with a console window when they don't need it
Oldes
23:45@rebred and yes... it must be compiled! I compiled the CLI console with the Sqlite as I demonstrated above using this command (executed from Red's repository root directory):
X:\UTILS\rebol-view-278-3-1.exe -csw red.r -r -t MSDOS environment/console/CLI/console.red -o console.exe
loziniak
23:46Ah, so in MSDOS target console is opening automatically if we run the program by clicking an icon? Cool :-)
hiiamboris
23:47@loziniak Yes, there are usually 2 types of executables - CLI and GUI. Both for Windows and Mac. So, that makes 2 build options for each OS.
Oldes
23:52@rebred to add it into GUI console version, you can include the sqlite.red file [here](https://github.com/red/red/blob/a4d8240d8b14cfdd7b4c1d9051210253ef974cd9/environment/console/GUI/gui-console.red#L41) and compile using:
X:\UTILS\rebol-view-278-3-1.exe -csw red.r -r -t Windows environment/console/GUI/gui-console.red -o gui-console.exe
23:56Although when I try it, it crashes in the GUI console. Don't know why... I'm CLI user.

Oldes
00:00I guess, that the reason will be, that the library code needs the system (CLI) console for the text output, which is not opened with the GUI console). The library code was written before GUI console.
00:03Maybe it would be enough to comment lines like [this one](https://github.com/red/code/blob/2371ed70ff96f303b1f3528e14d14ff69f42e589/Library/SQLite/SQLite3.red#L12) (which you would want anyway for real use)
rebred
00:03@Oldes I went to red/code on GitHub and downloaded the file that includes Apps, Library, Screenshots etc.
Oldes
00:04Sorry... too late here... must go sleep.
rebred
00:04then I updated the line #include %SQLite3.red in with #include %/x/GIT/Red-code/Library/SQLite/SQLite3.reds
Oldes
00:05You should also know, that you need the sqlite.dll :) and not to use my paths!
rebred
00:05@Oldes ok to the next time! thank you
Oldes
00:06@greggirwin as you can see... the obstacle number 1 is existent... people don't know how to link files from library into Red.
rebred
00:08or may be @Oldes when he would find a minute could update these SQLite files with the current library paths ?
00:09or I could do it if there are instructions
Oldes
10:25It does not make sense to modify the paths in the code repository, because than it would not be possible to compile the test versions there (which were meant to be a standalone apps). If you want to use the library in your code, you must find your way how to structure your files and use proper paths to them (relative or absolute).

But I think that in this case, there are at least 2 Red bugs. First that if you include .red file, which includes .reds file from #system directive it should use location of the parent file, which actually does not. And second issue is, that if there is not standard output open (as in case of GUI console and other view only apps), the application should not crash when its _red/system_ code calls some of print* functions. @dockimbel @qtxie
10:32Btw... the SQLite code in the Red/code is not fully featured product. It was meant as a proof of concept for me. Something what you could use to start yourself to improve.

Just the [SQLite.reds](https://github.com/red/code/blob/master/Library/SQLite/SQLite3.reds) file was full binding to the latest version of SQLite (3.20.1), which was at the time I made it. It was made semi-automatically from SQLite's C header file.
lepinekong_twitter
12:22Is there a way to fullfill this wish with macro :)
A wish for a future language:
https://i.imgur.com/bV73D5K.png
https://blog.jayway.com/2016/08/23/name-types-not-just-variables/
nedzadarek
15:37@lepinekong_twitter I don't know about macros but I think it's possible without it.
First the syntax:
val: func [:name :type1 :type2 :op value] [
    reduce [name type1 type2 op value]
]
val a: integer![ab] = 3
; == [a: integer! [ab] = 3]

And about the User Defined Types, I have tried doing it using parse. [Here is the source.](https://github.com/nedzadarek/red_custom_type_proposal). I haven't touched it for a long time but it seems that it support type-checks ([line 77](https://github.com/nedzadarek/red_custom_type_proposal/blob/master/ct-functions.red#L77) and [line 84](https://github.com/nedzadarek/red_custom_type_proposal/blob/master/ct-functions.red#L84)).
gltewalt
19:16Can we rename files with Red? I see that R2 has a rename, but the source isn't compatible
lepinekong_twitter
19:26@nedzadarek thanks will look at your solutions :)
19:27Instead of:
#macro ['§include any-type!] func [s e][new-line load s/2 true]


I tried:
#macro ['§include [file! url!]] func [s e][new-line load s/2 true]

it doesn't work, is there another possible syntax to restrict type for the macro above ?
19:30@gltewalt I don't think there is a red function for that, so I called dos or powershell on windows from red.
gltewalt
19:42Easy enough to use call I guess
hiiamboris
19:44@lepinekong_twitter the block has a parse syntax, remember? :)
greggirwin
23:51@oldes, good thoughts on include.

@gltewalt it will come with full I/O.

rebred
00:00
#!/Library/WebServer/Documents/red2.dms
Red[]
print "Content-type: text/html^/"
print "<body><center>"
str: rejoin ["Post data: " mold input]
print str
print "<BR><BR>"

I am using the red script above to correctly display the text submitted from a HTML with a text form. It works perfectly.
<HTML>
<BODY>
<form action="/main.cgi">
  <input type="file" name="pic" accept="image/*">
  <input type="submit">
</form>
</BODY>
</HTML>

now i am trying to upload an image using the HTML above
how do I get the binary image ?
greggirwin
00:01read/binary
rebred
00:08@greggirwin
#!/Library/WebServer/Documents/red2.dms
Red[]
print "Content-type: text/html^/"
print "<body>"
a: read/binary
print "<BR><BR>"
print "</body></html>"

it gives me:

*** Script Error: read does not allow unset! for its source argument *** Where: read *** Stack:
greggirwin
00:14Use help read. You'll see that you need to give it a target to read.
00:39Ah, sorry, I thought you wanted to read an image from disk/url. We don't have full I/O yet, but @rebolek has written great support tools for CGI use. See: https://github.com/rebolek/red-tools
lepinekong_twitter
10:16@hiiamboris ha yeah thanks ;)
endo64
15:40@rebred if your image file is not too big you can encode it as Base64 and use directly inside the HTML file:

print {<img src="data:image/png;base64,}
print enbase to binary! load %file.png
print {"}


Didn't test, but it should work (not sure about to binary! is necessary or not)

Or may be:
i: load %file.png
print enbase i/rgb
lepinekong_twitter
16:54I want to load libraries in background for offline mode a bit like service workers with PWA app https://developers.google.com/web/fundamentals/instant-and-offline/web-storage/offline-for-pwa since there is no async yet, I want to use time event in a hidden view, but can I really hide it while it continues to run or can I use console time herself then where is it ?
hiiamboris
18:07try adding actors/on-time and rate to system/view/screens/1/pane/-1 maybe
18:13I just tried view/options/no-wait [base rate 1 on-time [...your code...]] [visible?: no] and works for me on W7 just fine. Timer working and no window.
rebred
21:11@endo64 thank you. it’s a form where people can upload images so they would not be able to easily encode it
21:13I know the text is passed and RED is able to read it correctly but I don’t know how to read a form containing a binary attachment
21:14i read rebolek HTTP scripts but I wasn’t able to understand how to pass a binary file
lepinekong_twitter
22:36@hiiamboris great thanks, will try then :)
23:39My surface pro resolution is 2736 x 1824 red draw doesn't seem to support high resolution as it interpolate, will it support it one day ?
hiiamboris
23:46Haven't seen any problems on my surface pro. Got an example?

WiseGenius
01:22In the Windows cmd, when I do:
red build libred

It works, but it says:
Target: MSDOS

Is there going to be any difference between targeting MSDOS and Windows when using libred, as there sometimes is when compiling other code?
How do I make it target Windows as I can when compiling code with -t Windows, which doesn't seem to have any effect in this case?
02:38Here's an extremely n00b question, I'm sure:
I tried putting the code from the first libred example from [here](https://www.red-lang.org/2017/03/062-libred-and-macros.html):
#include "red.h"

    int main() {
        redOpen();
        redPrint(redString("Hello World!"));
        redClose();
        return 0;
    }

...into a file named a.c, and put that in the libRed folder which was built in my previous question, but I got this when I tried compiling:
H:\libRed>gcc a.c
H:\DOCUME~1\WiseGenius\LOCALS~1\Temp\ccWEPHEg.o:a.c:(.text+0xf): undefined reference to `redOpen'
H:\DOCUME~1\WiseGenius\LOCALS~1\Temp\ccWEPHEg.o:a.c:(.text+0x1b): undefined reference to `redString'
H:\DOCUME~1\WiseGenius\LOCALS~1\Temp\ccWEPHEg.o:a.c:(.text+0x23): undefined reference to `redPrint'
H:\DOCUME~1\WiseGenius\LOCALS~1\Temp\ccWEPHEg.o:a.c:(.text+0x28): undefined reference to `redClose'
collect2.exe: error: ld returned 1 exit status

Though I can write simple C code, I'm still very new to the whole libraries thing. What other things do I need to include in my gcc command to include libRed?
06:54This was the solution to my 2nd question above:
gcc a.c -L. -llibRed

Where . is the path to the files in the libRed folder generated by red build libred.
hiiamboris
10:53@WiseGenius
> Is there going to be any difference between targeting MSDOS and Windows when using libred, as there sometimes is when compiling other code?

In short, no. Although DLLs are better compared to -t Windows, since they have no console of their own.
lepinekong_twitter
12:52@hiiamboris I mean the resolution of view is not the full resolution, let's say you want to create a clone of VSCode (pure imagination but why not ;)) you're gonna to have pixelated UI if you want to match the same resolution.
Oldes
12:54Pixelated your images or pixelated GUI? Because I have current Red GUI console nicely working with the hiDPI.. not like good old Rebol
rebolek
12:54@lepinekong_twitter if you do something like view [base 2000x1500 draw [line 0x0 2000x1500]], it doesn't work or what?
lepinekong_twitter
13:41@rebolek I get this: https://imgur.com/a/yUxC1Vi
rebolek
13:44@lepinekong_twitter That's strange, thanks. So the base widget is not properly placed in window and has some strange size?
rebred
13:46
<form action="/image.cgi" method="post" enctype="multipart/form-data">
  <input type="file" name="pic" accept="image/*">
  <input type="submit">
</form>

@rebolek how do I read the binary file ?
13:46from this html form. I am able to read the text but not the binary file
rebolek
13:47@rebred how are you reading the text?
rebred
13:49
<form action="/main.cgi" method="post">
  <input type="text" name="username" value="Mickey"><br>
  <input type="text" name="password" value="Mouse"><br><br>
  <input type="submit" value="Submit">
</form>

-----
#!/Library/WebServer/Documents/red2.dms
Red[]
print "Content-type: text/html^/"
str: rejoin ["Post data: " mold input]

by reading the variable input
hiiamboris
13:51@lepinekong_twitter I don't see any pixelation on your screenshot. And it looks like the window size is currently limited by the screen size, so you shouldn't make the window bigger than system/view/screens/1/size
rebolek
13:52@rebred Ah, on server? I see. rejoin expects you have textual data, but Red should't have problem getting binary from input, I believe.
hiiamboris
13:53With input, CR/LF translation may happen, ^C signal (03h char), etc. Needs testing to rule out the possibilities.
rebolek
13:54@rebred what error do you get exactly?
rebred
14:26@rebolek
print "Content-type: text/html^/"
print "<body>"

a: input
print ["input: " a]
b: load input
print ["<BR>load input: " b]

print rejoin ["<img src=" a ".png>"]

print "<BR><BR>"
print "</body></html>"



when I print a: input I get:

------WebKitFormBoundaryGR4jl5ceDvBm62Yj

when I print b: load input I get:

Content-Disposition form-data
rebolek
14:30@rebred GR4jl5ceDvBm62Yj seem like base-64 encoded data. input reads data to newline and empties that line, so a and b can't be same. I guess you should read in loop until input is empty.
rebred
14:32how do I get an image from input
rebolek
14:33@rebred if it's base-64 encoded (and it looks like it is), when you read all data, then just debase data or debase/base data 64.
14:33and you'll get binary data
lepinekong_twitter
14:35@hiiamboris not on this picture I had one but I don't remember where I put it have to create another one on occasion :)
rebred
16:30@rebolek
#!/Library/WebServer/Documents/red2.dms
Red[]
print "Content-type: text/html^/"
print "<body>"
print ["<BR>input1:" input]
print ["<BR>input2:" input]
print ["<BR>input3:" input]
print ["<BR>input4:" input]
print ["<BR>input5:" input]


this give me the following html output:

input1: ------WebKitFormBoundaryxBNH9pwUye3VNRvU 
input2: Content-Disposition: form-data; name="pic"; filename="img0.png" 
input3: Content-Type: image/png 
input4: 
input5: *** Runtime Error 100: no value matched in CASE *** at: 000D5922h

16:35where is the image ?
rebolek
18:32@rebred
*** Runtime Error 100: no value matched in CASE *** at: 000D5922h
this is bug, please report it
rebred
18:34@rebolek ok I guess it’s not possible at this time to upload an image
rebolek
18:34@rebred if you get crash, probably not, I'm afraid.

gltewalt
00:05Is there a way to send Ctrl+C to the repl using call?
01:03With fresh Red call/console {red —cli} lands me in the repl when it’s done and then ignores a subsequent call/console {red}
ne1uno
02:48maybe ^(03) I was trying to break out of hunspell pipe mode last week and gave up and instead wrote a temp file to redirect as input. it may be you need an extra literal escape ^ too like with redirect symbols
gltewalt
03:40Mmm... not an extra ^
03:40
>> call/console {^^C}
== -1
>> print {^^C}
^C
>> print {^C}
♥
04:09
Red []

red-directory: first split-path system/options/boot
binary-name: %red.exe  
binary-url: https://static.red-lang.org/dl/auto/win/red-latest.exe

enforce-directory: func [dir][unless what-dir = dir [change-dir dir]]  

fetch-binary: func [name url][
    if exists? name [call/shell form reduce ["rename" name append name ".old"]]
    write/binary name read/binary url
]

compile-consoles: does [
    call/console {red --cli}
    print "Done with CLI."
    call/console {taskkill /IM console-* /F} ; this wont even work - just launches repl and is stuck there
    call/console {red}
    print "Done with GUI."
]

enforce-directory red-directory
print ["In directory" what-dir]
print "Fetching Red..."
fetch-binary binary-name binary-url
compile-consoles
04:21Just a sketch right now
dander
05:26I thought this used to work for getting the console to compile, then quit, but it gets stuck too. Maybe something changed... echo "q" | red --cli
gltewalt
05:37I’ll try it
05:37Oh “it get stuck too”
05:38A mode might be useful where consoles don’t launch after compilation
ne1uno
05:52all the crashers fixed?
05:52could try adding /shell and escape the bar? echo "q" ^| red --cli
gltewalt
06:35Ah, just reverse the order.
binary-name: %red.exe  
binary-url: https://static.red-lang.org/dl/auto/win/red-latest.exe

update-binary: func [name url][
    if exists? name [call/shell form reduce ["rename" name append name ".old"]]
    write/binary name read/binary url
]
compile-consoles: does [
    call/console {red}
    call/console {red --cli}
]

print "Updating Red..."
update-binary binary-name binary-url
compile-consoles
06:36Still leaves you in CLI repl, but gets both consoles compiled
hiiamboris
09:39@gltewalt In my experience, Red does not allow 2 console build processes at once, so you should use /wait as well.
09:40Personally I just wrote a batch file that rebuilds CLI, GUI console and libRedRT.
gltewalt
23:33Batch file is no fun
nedzadarek
23:36Is query supposed to return (some) date? Or is this going to change (full info: creation/edit data, size etc)?

Oldes
07:32@nedzadarek if you mean query on file.. it returns modification date. I did it and it was not enhanced as I did not found how to return object from r/s. There was some chat about it somewhere.
c61292558
09:11i can't click into http://www.red-lang.org/ .......Who can help me ..?o(╥﹏╥)o...
meijeru
09:19Resident of China?
c61292558
09:20yes @meijeru
09:20yes @meijeru
PeterWAWood
09:25@c61292558 Can you access - https://red.github.io
c61292558
09:27yes,I can.ok,thank you very very very much(^.^) @PeterWAWood
09:28but only 0.6.3,not 0.6.4?
rebolek
09:34@c61292558 try replacing 063 in filename with 064
nedzadarek
09:38@Oldes I see, thank you for the informations.
Oldes
10:25@nedzadarek here is the chat: :point_up: [January 24, 2018 4:20 PM](https://gitter.im/red/red?at=5a68a42298927d57452e4e2f)
gltewalt
10:36“When you use the /input, /output, /error, or /console refinements you automatically set the /wait refinement.”

Does that hold true with Red?
10:38http://www.rebol.com/docs/shell.html
c61292558
10:47[![image.png](https://files.gitter.im/red/help/OWBv/thumb/image.png)](https://files.gitter.im/red/help/OWBv/image.png)
10:48error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory
10:48why?on DEEPIN OS(LINUX)
10:48@rebolek
rebolek
10:55@c61292558 you need 32 version of libcurl4
hiiamboris
10:56@gltewalt
> Does that hold true with Red?

Not according to my experience, no
Maybe unintented? but if you compile call/console "cmd" with -t Windows it will start the process but won't wait. And in GUI console it just throws a NOT_IMPL error.
10:57Perhaps there should be an issue about that.
c61292558
11:04Is there no GUI interface on linux like it in windows?
11:04[![image.png](https://files.gitter.im/red/help/QhW5/thumb/image.png)](https://files.gitter.im/red/help/QhW5/image.png)
11:04@rebolek
11:07@rokf
11:19
>> do hello3.red
*** Script Error: hello3.red has no value
*** Where: do
*** Stack:

11:19
>> do %hello3.red
*** Access Error: cannot open: %hello3.red
*** Where: read
*** Stack: do-file
11:19why??
11:21@rebolek
Oldes
11:52Because the hello3.red file does not exists? What you see when you use ls in the console.
11:53And no... there is no GUI console on Linux yet... maybe in the [GTK branch](https://github.com/rcqls/red/tree/GTK-dev). Don't follow it too closely.
c61292558
13:13
>> do %Desktop/hello3.red
*** Script Error: view has no value
*** Where: do
*** Stack: do-file
13:14@Oldes
rcqls
13:33@c61292558 You’re on linux and you seem to need the View module to execute this code. So you have to visit GTK branch.
c61292558
13:58how can i run the .red source on deepin os (linux)??
13:58@rcqls
13:59[![image.png](https://files.gitter.im/red/help/vdOM/thumb/image.png)](https://files.gitter.im/red/help/vdOM/image.png)
14:00[![image.png](https://files.gitter.im/red/help/f2yA/thumb/image.png)](https://files.gitter.im/red/help/f2yA/image.png)
amreus
14:13Should this print "tab"? I thought so but doesn't for me.
Red []

switch tab [
  tab [print 'tab]
]
meijeru
14:32The values on the switch alternatives are not evaluated, so the second tab in your code is a word! value, whereas the first one is a char! value. You may wish to replace the first one by 'tab OR apply reduce to the block of alternatives.
c61292558
14:33下载之后怎么编译?
14:37how can i run red source on linux???
14:37@meijeru
meijeru
14:41I am a Windows only user. Hopefully some Linux experts may be able to answer.
c61292558
14:45
>> do "%hello3.red"
== %hello3.red
>> red "%hello3.red"
== "%hello3.red"
>> "%hello3.red"
== "%hello3.red"
>> hello3.red
*** Script Error: hello3.red has no value
*** Where: catch
*** Stack:
rebred
14:48
dehex "%E7%26%238710"

gives me

*** Access Error: invalid UTF-8 encoding: #{E7262300}
*** Where: dehex
*** Stack:
rcqls
14:49@c61292558 Install the developement GTK branch and follow the [wiki page](https://github.com/red/red/wiki/%5BNOTES%5D-Gtk-Bindings-Development)
14:50There is also a room red/GTK more suited for linux View with GTK.
c61292558
14:54if i don't use GTK ,how can i run the source?
rcqls
14:56you can’t without GTK branch… Only Windows and MacOS View backends are included in master branch because Linux GTK backend is in development.
c61292558
15:09but i download the red-lang executable file which support linux in https://red.github.io/index_CN.html.
rcqls
15:10Linux does not mean linux/View ! You can only use red in console without View...
c61292558
15:11@rcqls
rcqls
15:13See the wiki page in my previous message and you’ll probably be able to. Go to [https://rebolek.com/builds](https://rebolek.com/builds/) to download binary but this of course requires preinstallation of gtk libraries
amreus
15:20@meijeru
So this? Still no output.

switch tab [
    reduce [
        tab [print 'tab]
    ]
]

15:22Or this? Still no output.
Edit - maybe this makes more sense.
key: tab
switch key [
    'tab [print 'tab]
]

hiiamboris
15:25try ? tab maybe to see what you're comparing to what :)
amreus
15:27@hiiamboris Yes it works with #"^-" Why not tab? tab is of type? char!
hiiamboris
15:28switch doesn't reduce. You can do that yourself: switch tab reduce [...]
amreus
15:28I tried - doesn't work.
hiiamboris
15:28It does ☻
amreus
15:29I see - I had an extra wrapper of [] Thanks.
hiiamboris
15:29:+1:
amreus
15:30Not evaluating the conditions seems counter-intuitive.
hiiamboris
15:31I agree. I was caught in the same trap myself once.
amreus
15:38Now I can do the following. However I get an unwanted system sound whenever a press the tab key. Is this still the best way to allow tabbing through fields? Any idea why the system sound is played? (Windows 10)
key-handler: function [evt next-fld] [
    switch evt/key reduce [
        tab [ set-focus get next-fld ]
    ]
]
15:40Full form:
Red [
    needs: 'view
]

key-handler: function [evt next-fld] [
    switch evt/key reduce [
        tab [ set-focus get next-fld ]
    ]
]

view [
    title "New Person"
    style fld: field 150

    text "First Names"
    name: fld on-key [key-handler event 'surname]
    return

    text "Surname"
    surname: fld on-key [key-handler event 'name ]
    return

    button "Save" []
    button "Cancel" [unview]

    do [ set-focus name ]
]
hiiamboris
15:42Wow I didn't know about system sound being played. @amreus I think it's worth reporting.
c61292558
16:03
~/Desktop/releases/rebol-core$ cp rebol-core/rebol red/
cp: 无法获取'rebol-core/rebol' 的文件状态(stat): 没有那个文件或目录
16:04not that file or dir
16:04@rcqls
16:04do this
16:05[![image.png](https://files.gitter.im/red/help/vy1j/thumb/image.png)](https://files.gitter.im/red/help/vy1j/image.png)
16:05[![image.png](https://files.gitter.im/red/help/azsv/thumb/image.png)](https://files.gitter.im/red/help/azsv/image.png)
16:05[![image.png](https://files.gitter.im/red/help/9ll8/thumb/image.png)](https://files.gitter.im/red/help/9ll8/image.png)
amreus
16:24@hiiamboris https://github.com/red/red/issues/3779
hiiamboris
16:42Good. I commented there.
nedzadarek
16:45@Oldes thank you for the link
Rebol2Red
19:03
if "not empty" [print "not empty"]
if "" [print "empty"]
if none [print "does not print anything"]

A string is true and none is false???
gltewalt
19:16Yes. Everything is truthy except for none and false
Rebol2Red
19:23Good to know, thanks.
nedzadarek
20:41@Rebol2Red even unset! value (e.g. from print: >> if print "42" [print 1111111] ; 42 ;1111111).
endo64
21:29@nedzadarek
>> if probe () ['ok]
unset
== ok

21:30This also shows a difference between Red and Rebol:
Red> mold ()
== "unset"
R3> mold ()
== "unset!"
R2> mold ()
** Script Error: mold is missing its value argument
nedzadarek
22:05@endo64 yes, I guess version with probe () is much cleaner than print.

lepinekong_twitter
00:38@greggirwin just discovered this script https://raw.githubusercontent.com/greggirwin/red-code/master/Scripts/capture-demo.red why didn't anyone mention it I've been looking for something like this for months :)
PeterWAWood
01:12@c61292558 > but only 0.6.3, not 0.6.4?

I know that you've found what you needed including the GTK branch, just to let you know that the links on https://red.github.io have been updated to 0.6.4
GiuseppeChillemi
17:54In [RED Blog](https://www.red-lang.org/2012/12/red-v031-functions-support-added.html) I have read :

Still some features are not yet implemented:

building a function at runtime (requires the ability to JIT-compile source code)
17:56Is this still true ?
burque505
20:20Hi, thanks in advance for any help. I'm getting started with Actors (i.e. event handlers), and haven't come across any examples of using "on-drop" to drop files on a text-list. I thought Rebol might be a good source too, but the page at Saphirion says The w:on-drop actor is also called if a file is dragged and dropped from the system desktop over the face. This is a special case. There follows an example which says - on-drop: [ ; write an example here ]. Does anyone have an example of dropping files on a text-list? Regards, burque505
endo64
21:25@burque505 drop-file event is not implemented yet, here you can see @Oldes 's PR for that: https://github.com/red/red/pull/2838
lepinekong_twitter
21:44Does list with drag and drop example exist somewhere ?
nd9600
22:10Is there a general way of parsing recursive data structures with parse?
I'm trying to parse strings a bit like str: "[123[45]67]" (obviously I can just load this example, I'm trying to parse a more complicated thing), but I'm having some issues
Right now I've got
f2: function [
    str [string!]
] [
    output: copy []

    digit: charset "0123456789"
    arrayRule: ["[" any [element] "]"]
    element: [
        copy arrayData arrayRule (
            ?? arrayData
            parsedArray: f2 arrayData
            loop length? parsedArray [remove back tail output]
            append/only output parsedArray
        )
        | copy digitData digit (
            ?? digitData
            append output to-integer digitData
        )
    ]

    parse str arrayRule
    output
]

str: "[123[45]67]"
probe f2 str

which _does_ work, but I need to remove elements in the output right after I add them, because of how the recursion works
22:11You can see the issue in the output - it reads "4" and "5" twice:
digitData: "1"
digitData: "2"
digitData: "3"
digitData: "4"
digitData: "5"
arrayData: "[45]"
digitData: "4"
digitData: "5"
digitData: "6"
digitData: "7"
[1 2 3 [4 5] 6 7]

Is there a better way?
gltewalt
22:17into arrayRule, or some kind of use of into
22:18https://www.red-lang.org/2013/11/041-introducing-parse.html
22:18Maybe?
nedzadarek
22:20@gltewalt
>> parse "aaa" r: ["a" into r | to end]
*** Script Error: PARSE - input must be of any-block! type: "aa"
*** Where: parse
*** Stack:

but the post says:
> into rule : switch input to matched series (**string** or block) and parse it with rule.

... I guess there is some basic error but my mind isn't fresh.
gltewalt
22:27I’m not sure. (And on mobile right now so I cant experiment)
nd9600
22:40I thought it might be something like that @gltewalt , but it seems like into is only for block!s
22:40according to the Rebol docs
22:40> When parsing a block, if a sub-block is found, it is treated as a single value that is of the block! datatype. However, to parse a sub-block, you must invoke the parser recursively on the sub-block. The into word provides this capability. It expects that the next value in the input block is a sub-block to be parsed. This is as if a block! datatype had been provided. If the next value is not a block! datatype, the match fails and into looks for alternates or exits the rule. If the next value is a block, the parser rule that follows the into word is used to begin parsing the sub-block. It is processed in the same way as a sub-rule.
22:42to/thru are also options, but there's an issue with jumping to the right closing bracket then
burque505
22:45@endo64, thanks for the link. I downloaded it and ran it (uncompiled, just red.exe view-drop-files.red), with no luck. But that's not necessarily the end of the story. For example, with AHK, drop files only work for me on Win7 64-bit with compiled scripts, not those run as an argument to AutoHotkey.ahk. So I compiled it as red -r -t Windows view-drop-files.red, ran it as admin, still no luck (the GUI appears, of course, but dropping isn't allowed). I'm assuming that's because the pull request has not been accepted?
lepinekong_twitter
23:03I would like to have something like whatif in Powershell https://4sysops.com/archives/the-powershell-whatif-parameter/: know if it will generate error or not, I can't see how with load/trap and neither with attemp:

system/lexer/pre-load: func [src part][

        (if none? attempt [do src][
            print [src "not valid."]
           src: "" 
        ])
	
]

do {test}

gives:

test not valid.
test not valid.
test not valid.
test not valid.
test not valid.
test not valid.
test not valid.
*** Syntax Error: invalid value at "time!"
*** Where: do
*** Stack:


hiiamboris
23:42@lepinekong_twitter do will call load and load will call pre-load from within pre-load

lepinekong_twitter
00:54@hiiamboris ok so that mean I cannot do that use case or can I :)
toomasv
04:25What about this?
>> do*: func [test][if error? try [do test][print "source not valid"]]
== func [test][if error? try [do test] [print "source not valid"]]
>> do* {print 1}
1
== none
>> do* {test}
source not valid
c61292558
08:46I can't cross-compile to linux easily like that in red.github.io
08:46$ ./red -t Windows hello.red
$ ./red -t Darwin hello.red
$ ./red -t Linux-ARM hello.red
08:48not supported linux platform.
08:48what should i do?
08:49@rcqls
rebolek
08:49@c61292558 -t Linux-ARM works for me.
09:04@c61292558 can you post the exact error message?
nedzadarek
09:41@lepinekong_twitter whatif sounds interesting. I wonder if it could be (efficiently) implemented in the Red.
9214
11:35@nd9600

> Is there a general way of parsing recursive data structures

Yes, with recursive grammars. E.g.:

>> array: ["[" any [keep digit | array] "]"]
== ["[" any [keep digit | array] "]"]
>> digit: charset [#"0" - #"9"]
== make bitset! #{000000000000FFC0}
>> parse "[123[45]67]" [collect array]
== [#"1" #"2" #"3" #"4" #"5" #"6" #"7"]


into is of no use if you parse a string, but comes handy with lists.
11:37@c61292558 custom builds don't have an encapped toolchain in them, so you should rather compile from sources (see readme file on Github).
c61292558
12:10@rebolek
12:10[![image.png](https://files.gitter.im/red/help/FWf8/thumb/image.png)](https://files.gitter.im/red/help/FWf8/image.png)
12:10I want to cross-complipe on win10
12:10but why?
9214
12:10@c61292558 are you aware that you should run this commands from OS shell?
c61292558
12:10In red console
12:11cmd of win10 ?
rebolek
12:11you can't do this from Red console (well, you can using call, but let's not complicate it). Do it from terminal.
12:11Yes, cmd
c61292558
12:12can i do that in red console ?
12:12Red console
12:12@rebolek @9214
rebolek
12:13using call
9214
12:13You can, but, functionally, it would be the same as doing the same from command line.
rebolek
12:13something like call {red -t Linux-ARM test.red}
9214
12:14... provided that you have Red exe in your PATH. Otherwise you need to directly invoke toolchain binary.
rebolek
12:14yes, this is very basic example that you need to adapt to your needs
c61292558
12:16[![image.png](https://files.gitter.im/red/help/zLX1/thumb/image.png)](https://files.gitter.im/red/help/zLX1/image.png)
9214
12:17Just use command line, gee.
rebolek
12:17it returns process ID. If you're not familiar with call, you should compile from Windows cmd.
c61292558
12:20on windows , I must locate in the folder of red-064.exe ,right?
rebolek
c61292558
12:23[![image.png](https://files.gitter.im/red/help/CkLe/thumb/image.png)](https://files.gitter.im/red/help/CkLe/image.png)
12:23The feeling is going to be successful.
rebolek
12:23so it's working :clap:
c61292558
12:23thank you all very much.
rebolek
12:24you're welcome
c61292558
12:24I run it on deepin os (linux) now.
12:40[![image.png](https://files.gitter.im/red/help/bffq/thumb/image.png)](https://files.gitter.im/red/help/bffq/image.png)
12:41@rebolek
12:41why>
rebolek
12:41@c61292558 hard to say without seeing your source code. You have some error in your program.
c61292558
12:42but I can run it on win10
12:42[![image.png](https://files.gitter.im/red/help/bGLX/thumb/image.png)](https://files.gitter.im/red/help/bGLX/image.png)
rebolek
12:43So you want to compile GUI program for Linux? But then you need GTK branch.
c61292558
12:47oh.....I thought that cross-compiling can compile a gui program on linux.....
rebolek
12:47not yet, GTK support is not official
c61292558
12:48I try it again on linux platform
lepinekong_twitter
13:35@nedzadarek do you have an idea how because I need it now :)
13:36@nedzadarek Actually I don't need something as sophisticated as powershell whatif, I just need to detect error and cancel the command (a bit like in VBA when you cancel an event)
nedzadarek
14:01@lepinekong_twitter I guess (deep-)reactor!s and [object's ownership](https://www.red-lang.org/2016/03/060-red-gui-system.html) might help. I don't know whenever or not you can prevent to "run" an event (e.g. when you try to change something rea/arr/1: 11 it won't allow you to do so) but I guess you can revert the changes.
As for detecting an error - I don't know. You could work on the copy of an object but that wouldn't be efficient.
nd9600
15:52Turns out it _is_ doable with a stack @9214, it's just lot longer (I couldn't use your solution earlier because I wanted to do stuff with the data, not just recognise it as valid or not) :
https://gist.github.com/nd9600/c6942f6346aa526a1a4c4e9a7c1b3434
9214
16:27@nd9600 I left a comment on your gist.
c61292558
16:28how can i use cd command like that in windows cmd?
16:28@9214
16:28i need your help
16:28how can i know all the Red console commands?
16:29like "ls" etc
9214
16:29@c61292558 type ? cd in Red console. There's also ls. To list all available functions, type what.
16:30It's also a good idea to get familiar with built-in help. e.g., to list all functions related to directories, you can type ? "directory". You'll find cd, ls and many other listed in the output.
c61292558
16:32no examples
16:32[![image.png](https://files.gitter.im/red/help/h2js/thumb/image.png)](https://files.gitter.im/red/help/h2js/image.png)
16:34I don't understand the usage
16:34@9214
9214
16:35@c61292558 have you read any tutorials / documentation on Red?
c61292558
16:35https://www.red-lang.org/p/documentation.html
16:36I can't enter the website
9214
16:38I see, that's unfortunate. We have a list of [learning resources](https://github.com/red/red/wiki/[LINKS]-Learning-resources), I'd recommend to start with [Rebol/Core user guide](http://www.rebol.com/docs/core23/rebolcore.html). It's ~80% compatible with Red, but you should get the main idea on how to use the language. You can also use [this](https://github.com/red/red/wiki/%5BDOC%5D-REBOL-Core-Users-Guide-__-A-walkthrough-with-Red) for cross-checking.

In your cd example - are you sure that red-gtk is relative to the folder with Red binary? Maybe you need to set up folder's read/write permissions.
c61292558
16:42the folder only read
16:42but i just locate ,needn't write
16:43@9214
9214
16:45Okay, what's the output of ls? pwd? Do you see red-gtk there?
16:45IIRC cding into directory requires execute permissions.
c61292558
16:46oh,i found the problem already
16:47thank you
JacobGood1
20:19does view work in linux?

lepinekong_twitter
00:27@nedzadarek thanks interesting for events, now I gave vba example but not for the events stuff but just for canceling: if I type a bad command in console, I want to intercept it with lexer and do as if the command has never been typed. I'm surprised this would be impossible or there's a big hole in lexer features ?
00:33:point_up: [February 11, 2019 10:44 PM](https://gitter.im/red/help?at=5c61ecb2604f233ab6f2c9bf) nobody has answer: should I conclude it's not possible so one has to create a list from scratch to support drag and drop event ?
gltewalt
00:37Why does this work from a Red console, but not from a standalone, running program?
kill-proc: func [pnames [block!]] [
    foreach name pnames [call/wait form reduce ["taskkill /IM" name "/F"]] ; no mr. process, I expect you to die
]
00:41kill-proc ['console-2* 'gui-console-2*]
nedzadarek
01:05@lepinekong_twitter what is "a bad command"? Can you give us some examples?
hiiamboris
09:10@lepinekong_twitter personally I don't understand one bit what real world task you're trying to achieve ☺ More context might help.
toomasv
09:39[Experiment](https://gist.github.com/toomasv/6a65fadaf09ddf91810ee8e878160b8f) of dragging words from area to text-list:
[![drop-to-list](http://vooglaid.ee/red/drop-to-list.gif)](http://vooglaid.ee/red/drop-to-list.gif)
hiiamboris
09:41@gltewalt works compiled for me
09:56@toomasv on W7 it has a big misalignment. Caret-to-offset is worthless for everything except RTD.
toomasv
10:08@hiiamboris Thanks, good to know.
lepinekong_twitter
11:15@nedzadarek :) I have several use cases, shortest to explain is https://rosettacode.org/wiki/Respond_to_an_unknown_method_call which exists in many languages especially for a dynamic language this seems like a natural feature. I need it to work in console directly when user validates.
11:18@nedzadarek I was thinking about using lexer like javascript uses proxy to do the same "Metaprogramming in ES6: Part 3 - Proxies" https://www.keithcirkel.co.uk/metaprogramming-in-es6-part-3-proxies/
nedzadarek
12:03@toomasv :+1: good work.
12:28@lepinekong_twitter
> Respond_to_an_unknown_method_call

So let's say I have foo: func [a [integer!]] [a * 10]when I call it with the string (foo "string") it just raise foo does not allow string! for its a argument. However, you want to foo "string" to do something different, right? You could a casu ad casum do it, for example: foo: func [a ] [if string! = type? a [... {do something with it} ... ] but I guess you are more likely to do it with try, for example:
foo: func [a [integer!] ] [a * 10]
checker: func [bl [block!]] [ 
    either error? e: try bl [
        if e/id = 'expect-arg [ 
            probe reduce [e/arg1 'expected  e/arg3 'to-be e/arg2 ] 
            
            ; I guess e/arg3 is not bound so this won't work: 
            ; if e/arg2 = to-word string! [
                ; return foo to-integer reduce a/arg3
            ; ] 
        ]
    ][
        return e
    ]
    
]
checker [foo 1]
checker [foo "2"]
12:30About js' proxies: I will read it when I will have some time.
meijeru
12:49The examples in Rosetta are about calling an undefined field of an object -- that is yet another problem, I think.
12:52It can also be solved with try though -- just check on error invalid-path. The problem with this approach is that it cannot be positioned "inside" the object, unlike with some of the languages in the Rosetta example.
9214
12:53@meijeru
> This task is intended only for object systems that use a dynamic dispatch mechanism without static checking.

But who reads tasks' descriptions these days anyway? Pfft.
nedzadarek
13:17@meijeru invalid-path - can you show some simplified example?
meijeru
13:19@nedzadarek

>> o: object [a: 1]
== make object! [
    a: 1
]
>> probe try [o/b]
make error! [
    code: 328
    type: 'script
    id: 'invalid-path
    arg1: o/b
    arg2: 'b
    arg3: none
    near: none
    where: 'try
    stack: 43909852
]
*** Script Error: cannot access b in path o/b
*** Where: try
*** Stack: probe

nedzadarek
13:22@meijeru ah, missing field. Well, I think it's doable with wrappers:
o: object [
    f: func [a [integer!]] [a * 10]
    wrapper: func [bl] [
        return either error? e: try bind bl self [
            probe e/id
        ][
            e
        ]   
    ]
]

o/f 1 ; 10
o/wrapper [self/f 1] ; 10

o/f "1" ; Script Error: f does not allow string! for its a argument
o/wrapper [self/f "1"] ; expect-arg
o/wrapper [self/non-existent-function] ; invalid-path
meijeru
13:36@nedzadarek The point is, you will have to call the object with the explicit wrapper function, not with any field name that then gets caught.
9214
13:36> the method named at the point of invocation must not be defined.
meijeru
13:49:+1:
9214
13:50Like I said, you can't implement this task in a language without class hierarchy and dynamic dispatch. Subclass with called non-existent method should fallback to its class hierarchy, or have some sort of a fallback function implemented inside it, which gets triggered if no other method got dispatched.

The only way is to roll out your own "dispatcher" (like e.g. wrapper above), but that's an ad-hoc solution, and clearly violates the task description.
nedzadarek
14:15@9214 Does it really need class hierarchy (I guess you mean class based OOP)? The [Javascript](https://rosettacode.org/wiki/Respond_to_an_unknown_method_call#JavaScript) is allowed. Maybe proxy implements this (I don't know I haven't used it).

> > the method named at the point of invocation must not be defined.

And what is defined in my example?

@meijeru
> The point is, you will have to call the object with the explicit wrapper function, not with any field name that then gets caught.

Is this important whenever you call it obj/foo or obj/wrapper [foo]?
14:26* not defined in my example
meijeru
14:34Yes, it IS defined, namely wrapper. Always having to call o/wrapper is not a problem as such, just a bit more inconvenient, AND as @9214 pointed out, against the task as set in Rosetta. But that need not bother you...
9214
14:45OTOH, in object field and select object field return none if field is not present. One can use that in combination with unless, instead of trying workarounds.
15:00Calling functions inside object!s "methods" is a misnomer though. They are just like any other function! values, and there's no clear mechanism of message passing (like in OOP) which can be intercepted. Ownership system might tackle this, but currently it's rather limited.
viayuve
15:45how to bind everything including database in single exe?
16:38Red Android bridge demo - I am trying to run this but it gives "undefined word font!" I did not modified anything except path of include
lepinekong_twitter
16:40@nedzadarek thanks, but you have to ask people to use a wrapper, which is not the smae use case as ruby missing method or javascript proxy: you really hook ALL and ANY direct command.
viayuve
16:41
admins-MacBook-Pro:build admin$ /Users/admin/Desktop/bananafoo/r -r -t Android  "/Users/admin/Desktop/bananafoo/eval2.red"

-=== Red Compiler 0.6.4 ===- 

Compiling /Users/admin/Desktop/bananafoo/eval2.red ...
*** Compilation Error: undefined word font! 
*** in file: /Users/admin/Desktop/bananafoo/eval2.red
*** near: [font! [
        name: "Arial" 
        size: 11 
        color: white 
        anti-alias?: no
    ] 
    font-A: make font! [
        name: "Times New Roman" 
        size: 15 
        color: red 
        style: [bold italic underline] 
        anti-alias?: yes
    ] 
    img1: make
]
rebolek
16:46@viayuve Android branch is old, new code hasn't been merged yet. You need to wait a bit more for Android support.
viayuve
16:50oh I was just catching up with posts on blog... I Guess, I will wait bit more hmmm...
rebolek
16:50You should, it's certainly worth it! :smirk:
viayuve
16:52@rebolek yes, Do you happened to know something about wrapping everything in one file.exe
rebolek
16:54@viayuve use #include for your files, compile and you should have one exe.
viayuve
16:55-r create nice package for single user but data are still exposed
16:56you mean #include will include any file even if its not necessary for program to run?
rebolek
16:57@viayuve right, you can #include %file-that-will-never-be-needed-at-all.red
16:57the preprocessor will just replace this line with a content of that file.
16:58it's very dumb (and I mean it as good thing)
viayuve
16:59you are genius bro, This had in my mind that #include needs to be used in app.
rebolek
17:00you can be genius too, just read docs, experiment and ask :smile:
viayuve
17:12I will try my best. @rebolek one more question, comparing two data from different place (two different database table) long time I have been doing (try to make it work) so far what I did Step1 - got data out from two different database tables (from MSSQL and Oracle). Step2 - compare data and could not figure out date datatype how to make it same to compare(with red).
nedzadarek
17:29@lepinekong_twitter It was just to group function call + arguments. As it is a block you can exclude/include things.
17:31@meijeru I would just call ojb/wrapper [...] a syntax (to call a method).
rebolek
17:35@viayuve how do the dates look like?
viayuve
17:43@rebolek mssql - YYYY-MM-DD hh:mm:ss & oracle - DD-Mon-YYYY HH24:MI:SS
rebolek
17:46have you tried to load the dates to Red and compare them? Can you post examples?
lepinekong_twitter
17:46@nedzadarek but you have to call checker, if you don't call checker you can't intercept all ;)
17:47link https://github.com/red/Red/tree/master/red/bridges/java on page https://www.red-lang.org/2013/08/033-released-shared-libraries-and.html broken
viayuve
17:50thanks @lepinekong_twitter
17:58I will put example here tomorrow don't have files with me @rebolek "load" tried but was not able to convert like make both same dd-mm-yyyy hh:mm:ss syntax to compare. the program i have written in c# it have function that can convert to particular date format but don't know how with red.
rebolek
18:00@viayuve it would need some simple changes do date for Red to be able to load it, like for example
>> load replace "14-3-1976 19:30:00" space #"T"
== 14-Mar-1976/19:30:00
viayuve
18:18@rebolek okay using parse. do we have some function that converts like all date in red standard date like Convert[ Anydateformat [data] , mask [default[which converts it to dd-mm-yyyy hh:mm:ss]]
gltewalt
18:47@hiiamboris I have to use call/console/wait on my Win7 build. Hmmm
rebolek
18:49@viayuve you can't convert Anydateformat, just supported one. And supported is Red format, ISO and some other variants (see docs). You can write parse rules to get more formats of course, but you'll never cover everything. What is for example 12-11-10? dd-mm-yy, yy-mm-dd, mm-dd-yy?
gltewalt
19:01Or call/console/output form reduce ["taskkill /IM" name "/F"] %nul
hiiamboris
19:02@gltewalt Red 0.6.4 for Windows built 30-Jan-2019/9:03:13+03:00 commit #25ef631 here, on W7 as well, tried -t Windows and -t MSDOS and -r/-c, but as kill-proc ['console-*] if that matters
19:03could it be that the 2nd call fails? well, works for me either way
gltewalt
19:06I open up both consoles first before testing. Second call seems to be fine.
-c -t msdos, Red 0.6.4 for Windows built 4-Feb-2019/11:45:38-07:00 commit #a4d8240
19:08Crap... call/wait is working. I don't know what was going on that had it so it wasn't working when I first posted.
19:11Well, thanks for looking anyway.
nedzadarek
20:30@lepinekong_twitter
> @nedzadarek but you have to call checker, if you don't call checker you can't intercept all ;)

Nothing is perfect...
rebolek
lepinekong_twitter
rebred
21:00
dehex "%238710"

gives me

*** Access Error: invalid UTF-8 encoding: #{E7262300}
*** Where: dehex
*** Stack:

21:00is this a bug ?
lepinekong_twitter
21:00@nedzadarek I won't give up yet, I'll let my brain think in background an maybe this we I'll get a new idea for lexer :)
21:12@toomasv would be great to have a gui option for your tree into something like this ;) https://codesandbox.io/embed/lp80n9z7v9 not just for aesthetic but for be able to have events.
hiiamboris
21:17@rebred
>> dehex "%238710"
== "#8710"
rebred
21:28@hiiamboris I guess it’s a bug then
hiiamboris
21:38@rebred what platform, version?
rebred
22:27@hiiamboris Red 0.6.4 for macOS built 4-Feb-2019/19:45:38+01:00 commit #a4d8240
nedzadarek
23:04@lepinekong_twitter I guess you could try lower level stuffs (macros or Red/System). Good luck.
ps. I would like to see lots of Toomas' codes built-in the Red.

gltewalt
04:03Shouldn't this print red --cli, then red?
04:03 repeat i 2 [print replace "red $" "$" pick ["--cli" ""] i < 2]
04:06
>> repeat i 2 [print replace "red $" "$" pick ["--cli" ""] probe i < 2]
true
red --cli
false
red --cli

toomasv
05:43@gltewalt On first iteration "red $" is changed into "red --cli", so on second iteration there is nothing to replace.
>> repeat i 2 [print replace copy "red $" "$" pick ["--cli" ""] i < 2]
red --cli
red
gltewalt
05:46lol, dammit. Forgot copy.
toomasv
05:46:smile:
gltewalt
08:55I hate it when the little basic things bite me. It still happens to me.
lepinekong_twitter
11:22So I'm not the only one to feel like an idiot each time it happens ;)
moliad
15:06after more than two decades, I still forget a copy now and then... and it takes longer to debug, cause I assume I've used copy... so I don't look for it as much ;-)
nedzadarek
15:08@lepinekong_twitter The Red/Rebol isn't exactly "user friendly" - you have to keep in mind few things at once. Where in other languages it's "built in" (I guess vice versa exists).
15:08^ at least some part of it
lepinekong_twitter
21:39@nedzadarek it is easier than VBA (I was super expert on VBA ;)) which is what I call user friendly. User doesn't a person who don't know how to code, it means people more business oriented like economists and traders.
21:45@nedzadarek main problem is advanced doc: you have only basic stuffs, the book on Red I bought doesn't go very far.
moliad
22:06rebol is much easier to learn than most languages... what is hard is to *unlearn* common and accepted Computer Science Idioms which people (programmers and professors) take for granted as de facto concepts in computer programming.
22:07 I am forced to look at a lot of python code lately, and wow is that disgusting . it's not the core syntax, it's that the whole concept and flow of development is just like C 30 years ago. lists, for loops, array index variables, etc.
22:08I haven't used 'FOR in Rebol for 10 years. its not useful. same for WHILE and many other concepts which just seem archaic once you've changed your mindset.
22:09the code is data is a very powerful idiom. none does this better than Rebol/Red. other things in the interpreter may be less sexy, but its often not a concept of the language, but rather a single function which is more or less in tune with one's style.
22:10though you can always redefine these (and I do so every now and then)... for example, I have my own 'COMPOSE, 'FUNCT, 'PRINT and many others.
lepinekong_twitter
23:58@moliad traditional coders may be have to unlearn but for people like me it's just closer to natural language though not perfect of course since it wasn't meant to be. For me reason rebol and in some large degree Red follows the same path is lack of focus on real needs of the market. Languages don't matter so much because toolings can compensate. For example I find red very expressive but when you have to debug more than 50 lines it becomes a nightmare. Above all there are two stuffs that people expects: lightweight web server like nodejs (and not something like apache) + a server framework and sophisticated gui apps (not your grandfather gui of the 90s) potentially red can do but in practice you don't have anything (yet). People lack time and won't take the time to learn a new programming language except if it brings them jobs or business: red seems to target only hobbysts or fanatics of the language which are a minority.

nedzadarek
00:13@moliad
> rebol is much easier to learn than most languages... what is hard is to *unlearn* common and accepted Computer Science Idioms which people (programmers and professors) take for granted as de facto concepts in computer programming.

It's not always the case that you can unlearn one thing and replace it with another. Let's "make something local":
- in lots of languages you have "local variables" - you define it inside lambda, mark it with local keyword or *something*. It's straightforward
- In the Red/Rebol(?) you have keep in mind: only set-words are local in the function (no set 'x ...`)/keep list of local words yourself; copy a series.
gltewalt
03:54One time not so long along I had completely forgotten that foreach could take a block.
9214
09:53Let's keep this room on topic and not forget about [community communication values](https://github.com/red/red/wiki/[NOTES]-Community-Communication-Values).
moliad
12:24@9214 don't know who you are targeting with your comment, but we are dead on subject (learning Rebol) and the discussion is nothing but civil and agreeable.
9214
12:41Cool then; keep it that way.
lepinekong_twitter
16:41The problem with these guidelines is just to protect from usefull feedbacks, red community tend to stay close to its core so that anyone who just want to make the language advance will be looked as a threatener like this thread shows https://news.ycombinator.com/item?id=18843544
hiiamboris
16:58What I see in that thread on a quick glance is an enormous team time investment to keep hilariously stupid views on Red from spreading. And time is everything, literally...
BuilderGuy1
21:15How do i make a UI in Red that has ONE window with multiple "pages"? My current experiment creates a new window for every "page" (layout).
21:16Page1: [Button 80x20 "Page 2" [view layout Page2] ]

Page2: [ Button 80x20 "Page 1" [view layout Page1]
return below
Button 80x20 "Quit" [quit] ]

view layout Page1
hiiamboris
21:18@BuilderGuy1 https://doc.red-lang.org/en/vid.html#_tab_panel
amreus
21:23I'm just learning but couldn't panel be used for this? Can a panel can be initially positioned outside the window's viewable size, and then could it be moved into the viewable area?
BuilderGuy1
21:24What if I don't want the Tabs to be seen?
21:24I was just looking at Panels too. Can they overlap?
rebolek
21:24you don't have to place panel outside, you just change it's content
21:26
view [p: panel [text "panel 1"] return button "Next" [p/pane: layout/only [text "panel 2"]]]
BuilderGuy1
21:30So I could define several UIs then use a single Pane and the layout/only to set that pane to the UI I want. Correct?
rebolek
21:32Yes, layout/only will convert your VID to face and you set panel's content (in panel/pane) to that face.
BuilderGuy1
21:32Does all of this need to be inside view [] ?
rebolek
21:33It's just a quick demo, so it was easier to put it there.
BuilderGuy1
21:34ok. I get it ! Thanks! I will try out some variations :-)
rebolek
21:34You can "pre-render" all faces with layout/only and then just use panel/pane: some-face.
amreus
21:35The Windows object has a pane so technically you don't need the panel I think.
lepinekong_twitter
21:36@hiiamboris I think you are too blind for certain things. I don't dismiss the fact that it's always depressing to receive what is felt as unjustified critics but when it accumulates one should do some introspection or red hasn't learned anything from rebol failed business model.
rebolek
21:36@amreus right, that should work too
moliad
21:37@lepinekong_twitter thing is... this is not a channel for critisism. its a place to help people learn rebol :smirk:
rebolek
21:37@lepinekong_twitter Rebol's failed business model was closed-source language.
BuilderGuy1
21:37how do I properly reference the window object?
amreus
21:38@BuilderGuy1 lol my next question also. Maybe self?
moliad
21:38I use Rebol and Red commercially, used by fortune 500 companies. There is little justification in saying that Rebol cannot be used for real and complex applications, cause clearly, it can, and IS :smile:
rebolek
21:39@BuilderGuy1 for example:
>> w: layout [button "change me" [w/pane: layout/only [text "done!"]]]
== make object! [
    type: 'window
    offset: none
    size: 103x4...
>> view w
BuilderGuy1
21:40Ok cool! Time to play
moliad
21:40self will change based on where the block of code is used. much like scope and the this keyword in C++
amreus
21:41@moliad Same for Ruby which is where I'm coming from.
moliad
21:43dialects like VID will pass the block around until the part of the dialect which handles it (which may be within sub function calls, object methods or whatever) actually uses that block and create a function for it. then, that is where self will be bound. if the block is used within a singleton object, it doesn't make a lot of sense to use it.
rebolek
21:44I wouldn't complicate things with self
moliad
21:44reactors often tend to be reusable singletons which accept a widget as their first argument (red does it exactly this way).
21:46self is actually not required for the vast majority of code in Red because of the concept of static binding.
21:47which I like to call "dynamically applied static binding"
21:48so the scope of a word will stick to it directly, which makes self obsolete... it already knows from what object its from.
hiiamboris
22:06> reactors often tend to be reusable singletons which accept a widget as their first argument (red does it exactly this way).

@moliad can you elaborate on this one?
moliad
22:08the event handlers receive the face as their first argument. the face argument is the widget itself. so instead of using self/text to refer to the text of the widget within an action function, you'd use face/text
hiiamboris
22:09ah! actors then, not re-actors, correct?
9214
22:10Cor-re-ct.
moliad
22:10ah yes... sorry... this terminology I still mixup when talking about red, they are not the same thing.
22:10(but the same in other languages ;-)
hiiamboris
22:10It's just for the moment I was wondering if you invented a new way of using reactivity :D
moliad
22:11well yes, but its not yet in Red... its in use with Glass in Rebol 2
22:12my team is working on this and it will be released at some point, but there is no due date yet... we are taking the complex road... a custom datatype.
22:12and its more complex than the object! with reactor system... so its not a simple task to add natively
9214
22:13@moliad notes from the battlefield would be highly appreciated, as it's interesting to see how Red merits in production.
hiiamboris
22:13what makes it so complex? (sorry, I'm not familiar with Glass widgets)
moliad
22:14Glass is a 100% dataflow driven gui engine. even the layout is built with nodes... so resizing the window will automatically re-layout without a single thing to manage.
22:14all wrapped up within a hierarchical, VID-like dialect.
22:15nodes are used for layout, facets, rendering, reaction, piping and more
22:15its built over the liquid dataflow engine.
22:16a lazy computing node graph engine.
22:16which we are porting natively to red.
22:17we already have a high-level visual graph editor coded in Red which we will use to do the development of the liquid engine.
22:19Red/draw is already very stable and much faster than R2's
hiiamboris
22:19what serves as 'event' in this engine? a change in a parameter (node)?
and how do you detect/prevent cycles in the graph?
moliad
22:21yep, any change in a data container will signal dependencies. cycles are allowed, if the node can prevent the endless loop!
22:21(some actually can!)
22:21otherwise there are integrated cycle dependency algorithms embeded in the system.
22:22and it will prevent the graph from building a cycle if it can't handle it.
22:23anyhow. I feel like I'm overeaching the topic of the forum... ;-) we can continue in chit-chat if you want to ask more questions
hiiamboris
22:24sure!
lepinekong_twitter
23:34@rebolek not only and now that any programming languages are all opensourced, it is no more an advantage, as a whole team you clearly lack strategic business education which is a pity because that's not difficult to have, you just have to look at REALITY Ray Dalio has even written a book about this :) https://www.principles.com/principles-for-success/#play
gltewalt
23:38Always easier to say than do.
lepinekong_twitter
23:44Before doing you should have a vision, which is lacking. My vision is Red has lost many months on blockchain hype instead of focusing on 2 things: solving real world problem today as I said already people expects 2 things a lightweigth webserver so that a larger community could build a lightweight web framework around, and library/documentation complete enough for the same larger community to build sophisticated GUI on par with what people expect to see today (not the oldish look of your grand parent GUI) for desktop and mobile. Instead you tend to do everything to keep this large community from growing by escalating conflicts instead of calming people down.
BuilderGuy1
23:54I'm doing something silly here... I want to define two blocks with faces for a panel. In the View block I want to display an initial layout of faces then click a button to overwrite a Panel to be one of my predefined blocks containing face data ( i hope that makes sense).
23:54Page1: [
Text 80x20 "Welcome to Page 1"
]

Page2: [
Text 80x20 "Welcome to Page 2"
Button 80x20 "Quit" [quit]
]

view [
p: panel [text "Home Screen"]
return
button "Page1" [p/pane: layout/only [Page1]]
button "Page2" [p/pane: layout/only [Page2]]
]
23:55My last two buttons are goofed. it does not like [Page1] or [Page2] as data to change the panels pane.
9214
23:57@BuilderGuy1 remove the extra layer of [...].
BuilderGuy1
23:58So "p/pane: layout/only Page1" ?
9214
23:58Yes.
BuilderGuy1
23:58SWEET !!
23:59I'm going to have a great weekend :-)

9214
00:01Have fun, but don't forget to learn how to [format](https://gitter.im/red/help/~chat#markdown) your code properly - that will make a great weekend for us too :wink:
BuilderGuy1
00:01Not to worry ! I'll be doing LOTS of reading !
gltewalt
00:24@lepinekong_twitter It just isn’t ‘your’ vision.
Languages become successful for a variety of reason, not all of which make sense. If it were as simple as you think, every language with a web server and full documentation would be successful.
rebolek
06:40> people expects 2 things a lightweigth webserver so that a larger community could build a lightweight web framework around, and library/documentation complete enough for the same larger community to build sophisticated GUI on par with what people expect to see today (not the oldish look of your grand parent GUI) for desktop and mobile.

To be fair, it's what **you** expect, not what people expect.

> Instead you tend to do everything to keep this large community from growing by escalating conflicts instead of calming people down.

This is interesting claim. I would say that if anyone is escalating conflict (which I don't see here very often, but anyway), it would be people with such ridiculous claims as *as a whole team you clearly lack strategic business education*

Anyway, it has been explained many times, but it's clearly not enough - you think that Red lacks http server - and you're right! But there's one thing you need to understand - to have http server, Red first needs IO. If you are building house, you need walls first and then you can build roof. Nenad is author of Cheyenne web server so if you think that Red is not going to get one, you're wrong. There is a roadmap which you clearly never read, because then you wouldn't make such ridiculous claims.

So yes, there will http server, but only when things required to write one are finished. Red is is still alpha software.
pekr
07:01@rebolek thanks for stepping-in, as I just wanted to write something similar. I can find @lepinekong_twitter 's claims quite assertive, if not almost arrogant. I am working as an CIO in an enterprise segment, yet I don't share such opinions . My experience dicates, that sometimes even best meant strategies eventually don't necessarily fulfill initial plans, so it is difficult to say, what exactly makes the product successful in the end.

From my point of view, Red's plan seems to be well defined and of course it most probably does not fullfil everyone's preferences. As for me, I don't e.g. discount the cryptocurrency movement, quite the opposite - eager to see, how C3 shapes/up. For all those 20 years we redbollers call for some break-thru app and it simply can be that, so I just don't understand the criticism in this area ....
rebolek
07:18Thanks @pekr
07:21@lepinekong_twitter just one more point regarding GUI - what you call "grand parent GUI" is actually native system GUI. And some people may prefer it, especially for business apps. But I understand that some may prefer fancy UIs, or - as you call it -"sophisticated". It seems that you think that only way to get fancy UI is with web, but you can actually write fancy UI right now in Red with its Draw dialect. And it would be much cleaner code than the absolute mess of HTML+CSS+JS.
pekr
07:52Funny thing that GUI situation :-) For 20 years, rebollers were rudiculed by providing non-system "cash register" like GUIs of the past, then iPhone came and changed everything. Nowadays, we provide system level GUI, once again we are rudiculed by not providing non-system one :-) Once again Carl was at least 10 years ahead with his ideas ....
rebolek
07:53That's true :smile: But to be fair, he was also 10 years behind with his artistic skills :smirk:
pekr
07:58Yes, that's true. What I had in mind was kind of free-form GUI. I cna't find screenshot of RT's app they did for the Gateway company. Looket exactly how nowadays modern tablet apps look like.
hiiamboris
08:26When I get a program which GUI does not respect my own styling (defined for the whole OS as a native theme) and thus has no respect neither for my eye health not for my tastes, I just delete it right away. Period. ☺
Rebol2Red
09:07If i have a Red file (1) named default-folders.red:
Red []

default-datafolder:	"D:\DATAFILES\"

Put the file into C:\RED\

And another file (2) say test.red:
Red []

#include %\C\RED\default-folders.red

r: read to-file rejoin[default-datafolder "test.txt"]
probe r

Put it into a place where windows allows me to have access to

If i compile (2) then the created program shows test.txt

But when i change file (1) into:
Red []

default-datafolder:	"C:\DATAFILES\"

compile (2) then ... surprise ... it still shows test.txt!?

Because of this, what can i do to make such a construction?

Notes:
I use windows 10
Using get-env does not work because every program gets it own environment.
I could set some system environment variables but this ca'nt be done easily.
I need this to make programs, which still works after moving used files by Red
to another folder. Ofcourse i have to recompile the programs.
hiiamboris
09:16@Rebol2Red tried to-red-file instead of to-file?
Rebol2Red
09:18@hiiamboris Nope, but i'm going to test it right now. I let you know if this works.
09:22@hiiamboris No, it still behaves the same. I think Red changes used directories during compiling.
hiiamboris
09:24and you don't have DATAFILES on C : ?
Rebol2Red
09:25Nope, I have them on D:\DATAFILES
I can remove them to C:\DATAFILES
Would this matter?
hiiamboris
09:29I can't reproduce, for me it says *** Access Error: cannot open: ...
09:30use probe to check everything, like the path that's being formed by to-red-file
Rebol2Red
09:55I checked everything
I can change (1) and recompile (2) but the idea was to **only** edit (1) and **not** recompiling (2)
Only compiling (2) one time
hiiamboris
10:00Ah. I see. Previously you said your problem appears after you compile it again, but now it makes sense. Just replace #include with do. do is runtime.
Rebol2Red
10:07@hiiamboris Oeps, Facepalm.I should have found out myself.
I seldom compile programs so i thought it was necessary to use #include
Anyway, thanks for helping me out.
hiiamboris
10:26:+1:
habibalamin
14:31Hey, @9214, thanks for the help. I can see that you can include files with #include, which'd be great if I knew where the clipboard.reds file could be found. As it stands, the only reason I know a function like that exists is that I looked at the red codebase https://github.com/red/red/blob/595d8942f65e99e6762fffaea183ee6e03df7ddc/runtime/clipboard.reds.
14:33https://static.red-lang.org/red-system-specs.html#section-16.3 doesn't describe how to include files that are built in to the Red runtime.
9214
15:01@habibalamin I don't follow - file that is part of runtime is no different from any other file. You already located where it is, so, what's the problem? You can either include it from Red/System or work from inside #system [...] in Red, which IIRC makes all runtime library available, with no need for file inclusion.

The other question is why do you a need a clipboard code?
habibalamin
15:02Yes, but somehow, I can't locate the runtime files on my machine. I've tried running red build libRed and I get a libRedRT, which doesn't contain what I need.
15:03I don't particularly need the clipboard code in that module, but it just happened to be the file I was testing with to get started with Red/System. I happened to be looking at clipboard code, because macOS stores drag and drop data in a specific system clipboard.
9214
15:03@habibalamin well, to locate them you need source files. How can you do this otherwise? Go grab Red repo from Github. red build libRed builds you a runtime shared library.
habibalamin
15:04So if I understand correctly, anything define in those files in the repo is only accessible to Red developers.
15:04Is that what you're saying?
15:04My bad if so. I took them to be a standard library (in parts, at least).
9214
15:06It *is* a part of a standard library, open-sourced and accessible to anyone, and you can use them whichever way you want, provided that you abide to project's license :wink:
habibalamin
15:07Sorry, I'm not used to working with a language this early in its development. I guess the standard library is not included by default when I install Red?
9214
15:08You can't locate runtime files on your machine because there aren't any, all you have is a toolchain binary, with runtime library *compiled* inside it.
habibalamin
15:08With a Ruby installation, for instance, I can just require 'securerandom', for example, and it just works, because the standard library is included in the language distribution and the load path is also configured.
9214
15:09There's no need for load paths, Red comes full-packed. One 1MB executable with all batteries included. If you have a toolchain binary - you already have everything what Red has to offer, including standard library.
15:10... and you can use read-clipboard from the get-go.
15:10
text
>> read-clipboard
== {... and you can use read-clipboard from the get-go.}
habibalamin
15:11I was under the impression that when I first ran the red binary, that it had installed files needed by Red, as I saw some installation output go by when I first ran it (though I wasn't paying too much attention at the time).
15:11Hmm, okay, I just opened the REPL, and confirmed I got the clipboard output.
15:11Now I'm really confused, because I've been trying that for the past few hours to no avail.
9214
15:12It unpacks and compiles REPL (probaby in .red folder on *nix systems), but that's it.
habibalamin
15:12Ah, I see the problem. I was trying to access clipboard/read, not read-clipboard.
15:12Although I'm sure I tried both.
9214
15:12@habibalamin yeah, you've confused Red/System with Red.
habibalamin
15:13Okay. That makes sense.
15:13I believe I want Red/System, though, as I'm trying to write bindings for AppKit (which can be called from C).
15:14I want to get the pasteboard pointed to by NSPboardDrag from AppKit, which contains the drag and drop data.
9214
15:14I see, and you want to use clipboard.reds functions from Red/System?
habibalamin
15:15Well, I was looking to play around with it a bit. The objc_getClass function looks like what I want.
15:15(and others).
15:15I wanted to try getting the general pasteboard first pasteboard: objc_msgSend [objc_getClass "NSPasteboard" sel_getUid "generalPasteboard"].
9214
15:16The easiest way would be to just copypaste its content, at least the macOS part. Otherwise you need to work from Red layer, as it already contains clipboard code in runtime library.
habibalamin
15:16But I see now that these are internal functions, I guess?
9214
15:16They are internal, yes, but no one stops you from playing with them.
habibalamin
15:16Okay, this clarifies the problems I was having.
15:17Thank you so much for your help. I will clone the repo and start playing with it from there.
9214
15:19Np, have fun! We have a [red/system](https://gitter.im/red/red/system) room where you can ask for help from more R/S-savvy people. Maybe @Oldes will assist you a bit, as he's the author of the original on-drop-file PR.
habibalamin
15:19:+1:

lepinekong_twitter
14:25@gltewalt see that's the problem: you (I mean the collective you ;)) think it's about language whereas I'm saying it's about language less and less ;) You think it's my vision: it's the vision and trend of the software industry, go out of the cavern for example see who built github he wasn't a great geek and where they want to go https://www.youtube.com/watch?v=4_umRysuFjU
rebolek
14:35> go out of the cavern

Is such language really necessary?
lepinekong_twitter
14:36So if no one can build a software business that earns millions of dollars, the value of the language is not much. Since you play the elites game of excluding people from even expressing diversity of opinions, you can't expect achieve that since you're already too tiny to just develop the core of your language.
rebolek
14:37> Since you play the elites game of excluding people from even expressing diversity of opinions...

Do you have any example of excluding someone? I seriously doubt it.
greggirwin
18:49@lepinekong_twitter people can express their opinions here, but I sent you a PM so perhaps we can solve some of our communication issues. Let's you and I chat privately.
habibalamin
19:58@lepinekong_twitter for the record, I chose to use Red specifically because I needed something that would allow me to whip up small GUI programs with ease for my colleagues. If it had a web server instead, I wouldn't even have taken a second glance at it, since we use Ruby on Rails at work, so that need is already served. Outside of work, I personally use Haskell for web projects.

I've written GUI programs in Swift and Objective-C for macOS and iOS, and I'm not entirely satisfied with either of them for small programs. Just like Ruby, Python, and others fulfill the small program niche for command line scripts, for example, there is a desperate need, IMO, for something to fulfill the small program niche for graphical programs, and I think the use of native UI toolkits paired with easy cross-compilation is killer.

That definitely cinched my decision to learn Red, on top of the fact that it appeared to approach the problem anew on the surface layer; I can afford that, as I invest a lot of time into learning new ways to program to find the best way to approach different problems, so I priorotise radically better solutions over solutions that are easier to learn (though Red also did look really easy to learn, which still heavily influenced my decision, as I don't have infinite time).

Now, you could argue I'm not a typical case, but I, for one, am glad that Red exists to serve my need. Sure, you could serve a bigger ‘market’ (not that we're paying), but what does that accomplish when they are already pretty well-served, but few languages are really serving the people's needs that Red is?
19:58Sorry if that's too off-topic, not sure where else to post it.
greggirwin
22:04Thanks for the input @habibalamin, very helpful. I don't think there is a "typical case". :^)

lepinekong_twitter
11:55@habibalamin I'm not talking about your particular case, I'm talking about the broad market, rebol has already sunk, does red thinks he has infinite fund or what? Let's see after a stockmarket crash...
12:11Your business model is what ? Sell a pro license like rebol ? Hahaha !
rebolek
12:12@lepinekong_twitter this is red/help channel, not red/trolling-without-purpose channel, so please keep on topic. You're not helping anyone.
nedzadarek
12:54@lepinekong_twitter hmm... what kind of Web server/framework do you think Red would be good in?
13:09As this talk about web things appeared I thought about one think. Do you think it would be feasible to port Red's draw dialect to "multimedia" framework like p5.js? After webserver & IO support of course.
I mean Red would need (as fair I remember):
- drawing facility - draw
- interactivity - reactors
- sounds - no support at the moment
- html editing - there is tag! type, there is accepted [REP Template proposal by Peter W A Wood](https://github.com/red/REP/blob/master/REPs/rep-0002.adoc) but it has no informations
- video (sound + image) capturing - ?
moliad
13:11that's all client-side. until we can retarget Red to a javascript back-end like asm.js or emcripten, I don't really see how
nedzadarek
13:22@moliad why it needs something like asm.js? Would it be too slow if someone port it "directly" to such framework?
rebolek
13:22@nedzadarek port directly what? Whole Red? :-)
nedzadarek
13:26@rebolek no, I mean libraries/frameworks like p5.js have functions like [circle](https://p5js.org/reference/#/p5/circle). So you have to make function like red-circle that output circle(...).
rebolek
13:28 @nedzadarek I see. For some limited static stuff it should be very easy.
moliad
13:28no, draw is just a dialect, you can do it yourself :-) just take the spec of the draw dialect and spit out javascript text :-) its actually easy when the semantics are similar
rebolek
13:29Then it would be probably better to target Canvas directly, instead of some framework.
nedzadarek
13:38@rebolek canvas is only for drawing... you would need sound/video capturing support too
rebolek
13:40Hm, but what's the point? Instead of doing it directly in Red, it would require ton of boilerplate code to convert corresponding Red code to JS and then a browser to run it.
nedzadarek
13:54@rebolek you can run it on any device that has a browser.
rebolek
13:56As @moliad wrote, that would require some .js compiler target to be useful.
nedzadarek
13:57I see.
moliad
14:26there have been a few projects which use Rebol dialects and source data to create Web front-ends. some even auto-generate javascript source code and send all of that to the browser. it works well, but its practically as much work as building a web target. so I don't expect anyone to do it without some serious commitment.
nedzadarek
14:28@moliad I see - good information.
giesse
18:30@nedzadarek http://www.colellachiara.com/soft/topaz/try-topaz.html
greggirwin
20:06@lepinekong_twitter if you want to continue participating in the community, please respond to my private messages so we can iron things out. Thanks.
nedzadarek
20:16@greggirwin is it based on the Rebol or some older version of the Red?
20:16It's 7 years old, after all.
greggirwin
20:17@nedzadarek what are you referring to?
nedzadarek
21:42@greggirwin ah, I am sorry. It was meant to be answer for @giesse
lepinekong_twitter
21:44@nedzadarek actually people are fed up of heavy weighted server/frameworks of the past like Apache, Tomcat (or Cheyenne Web Server in rebol), that's why they loved when nodejs appears with its very lightweight server that they can start in no time for example a quick prototype. Then when needed they can add expressjs very easily. The server alone won't make it a breakthrough but without it, you cannot even hope to interest the majority. To make a breakthrough it should be able to be async and compete with performance and robustness of nodejs.
This is general trend people gives up heavy weigthed tools, servers etc.for example Visual Studio or Eclipse are left for VSCode when possible (if Red was able to make an even lighter editor than VSCode with same kind of plugin architecture I'm pretty sure it would have huge success also ;)).
21:55As for mobile doing android if not followed by ios is rather useless: clients spend 4 times more on ios than on android, companies are looking for tools to develop on both at the same times, that's why there are switching to reactnative, so if red strategy is to develop for android, it should be followed by ios hobbists will be interested not companies. Now if red only target hobbysts or a tiny number of companies fine but say it loud so it's clear.
21:58If Android and ios stuffs are really pro, that companies are ready to pay.
gltewalt
22:22There are many other humans who have considered these things, and more.
viayuve
22:23issue - red console stops working after some time and it does interrupt - restart and shutdown sequence because of "not responding" situation "force quit" does not work either. on mac for me only solution is to shut it down using power button.
gltewalt
22:25Can you kill the process from Terminal?
viayuve
22:27i do have very long event log
gltewalt
22:28Something like kill -9 console-*
viayuve
22:29
Date/Time:       2019-02-19 03:29:08 +0530
End time:        2019-02-19 03:29:10 +0530
OS Version:      Mac OS X 10.14.3 (Build 18D109)
Architecture:    x86_64h
Report Version:  27

Data Source:     Stackshots
Shared Cache:    0x1f672000 E4B3A94D-55C0-393C-A126-2603E9F8FC4E
Shared Cache:    0 0822F2B8-73B6-3640-8E91-04395E27F608

Command:         console-2019-2-4-67544
Path:            /usr/lib/dyld
Version:         ??? (???)
PID:             609

Event:           hang
Duration:        1.70s
Steps:           17 (100ms sampling interval)

Hardware model:  MacBookPro14,3
Active cpus:     8

Time Awake Since Boot: 24000s
Time Since Wake: 13000s

Fan speed:       2155 rpm

22:36still there
22:38still not responding i mean can not kill wow looks like have to use power button.
greggirwin
22:39@lepinekong_twitter, are you intentionally ignoring me?
viayuve
22:41now I think, I must hold my horses before I move app to production server.
22:43in windows it works, in mac it does hang up and stop other triggers.
gltewalt
22:43@viayuve Can you move your info to red/bugs so gurus can help investigate?
viayuve
22:44how can i identify what is causing me issue ?
22:44okay @gltewalt

giesse
06:53@nedzadarek Red barely existed when I started with Topaz. Not to mention, I had a proof-of-concept R2-like interpreter written in Javascript around 2007.
Contrary to Red, Topaz did not have REBOL compatibility as a goal, so it has a number of major differences.
In any case, the idea of a REBOL-like or REBOL-inspired language running in the browser (or any other platform with a JS VM of any sort) is anything but new, and has been historically very unpopular.
pekr
08:22unpopular? I can easily claim, that Rebol's non presence in a browser is one of its failures.
nedzadarek
10:44@giesse I see, thank you for the information.
giesse
19:15@pekr, unpopular with this crowd at least :)
GiuseppeChillemi
23:47What should I expect using context?

If I use it on an object word I get ?function?. This is not so meningful to me.
I ask it beacuse I wish to find which functions returns what: I wish to compare if the context of words inside block is the same of the result when using extract, or contexts of words passed between funtions, or if words setted into a foreach loop maintain the context of the foreach block argument.

hiiamboris
23:52you're probably using it not on object's word but on it's associated value

GiuseppeChillemi
00:02AA: 1
00:02Context? 'AA
00:02( pardon, I am in mobile )
hiiamboris
00:11
>> o: object [w: 123  probe context? 'w]  ()
make object! [
    w: 123
]

no function as you can see
can't tell you more without seein the code
toomasv
04:11@GiuseppeChillemi Or, if you have bound words somewhere else, e.g.:
a: [b]
o: object [b: 2]
bind a o
context? a/1
;== make object! [
;    b: 2
;]
GiuseppeChillemi
09:14@toomasv Yesterday it was too late. I was using PRINT instead of PROBE to get the context.
rebolek
09:15Careful with that, print evaluates
GiuseppeChillemi
09:15@toomasv I still not undestand how to get the context of a word inside a block.
09:16@rebolek Yes, I have discovered it with long consolle output !
toomasv
09:17@GiuseppeChillemi If you have bound words in the block, you can ask context? of these words, as in above example.
09:22Also:
>> a: [context? 'b]
== [context? 'b]
>> o: object [b: 2]
== make object! [
    b: 2
]
>> bind a o
== [context? 'b]
>> do a
== make object! [
    b: 2
]
gltewalt
09:24If you’re wondering how to get the name that a value is set to... values are anonymous.
nedzadarek
09:27@GiuseppeChillemi to add to @toomasv answer:
you just need to extract a word!. As Toomas noted, you can use /n syntax (arr: [a b c] arr/3; c) or using pick (pick [a b c] 3). You can even find it (first find [a b c] 'a`). As fair I remember, it's like any other way to extract values.
09:30@toomasv has binding changed? I remember saving bindings (e.g. arr: [a b c] arr: bind arr context [a: 1 b: 2 c: 3]). I don't think it's necessary now.
toomasv
09:34@nedzadarek No need to "save". Bindings are changed in-place. But you can bind a (deep) copy with bind/copy.
nedzadarek
09:39@toomasv I see.
@toomasv @GiuseppeChillemi As fair I know bind binds any-word!:
>> arr: [a a: 'a :a] 
== [a a: 'a :a]
>> reduce to-word probe first (bind arr context [a: 42])
a
== 42
>> reduce to-word probe second (bind arr context [a: 42])
a:
== 42
>> reduce to-word probe third (bind arr context [a: 42])
'a
== 42
>> reduce to-word probe fourth (bind arr context [a: 42])
:a
== 42
GiuseppeChillemi
11:51Here:
11:52
y: [b c d]
probe context? y/1


I expected a result from context? but basically I was wrong. I supposed B has some context
rebolek
11:54But there is result.
11:54Also,
>> equal? system/words context? y/1
== true
nedzadarek
11:54@GiuseppeChillemi don't probe it - main context is huge to print
GiuseppeChillemi
11:55@rebolek , yes there is a result.
11:57Also I expected a result from:
z: make object! [b: 0 c: 1 d: 2]
probe context? z/1


But I get an error

*** Script Error: cannot access 1 in path z/1
*** Where: context?
*** Stack: probe 
>>


rebolek
11:57z is object, there's no z/1
11:57this has nothing to do with context?
GiuseppeChillemi
11:58@gltewalt
> If you’re wondering how to get the name that a value is set to... values are anonymous.

This is now clear to me.
11:59@rebolek I expected z/1 returning the first word in the object and returning the object Z itself as result of context?
nedzadarek
12:00@GiuseppeChillemi I guess you have used the Rebol to have such expectations:
z: object [a: 1 b: 2]
first z
; == [self a b]
second z
;== [make object! [
;        a: 1
;        b: 2
;    ] 1 2]
rebolek
12:01@nedzadarek certainly not, first z does return words-of, not first word.
12:01@GiuseppeChillemi Ah, you wanted this:
>> z: make object! [b: 0 c: 1 d: 2]
== make object! [
    b: 0
    c: 1
    d: 2
]
>> w: words-of z
== [b c d]
>> w/1
== b
>> context? w/1
== make object! [
    b: 0
    c: 1
    d: 2
]
nedzadarek
12:07@rebolek
> @nedzadarek certainly not, first z does return words-of, not first word.

I mean that only the Rebol allows you to use integer indexes (well, first and second) to retrieve words & values respectively. The Red is more descriptive (-of functions).
rebolek
12:09@nedzadarek right, it does, however @GiuseppeChillemi writes: *I expected z/1 returning the first word in the object...*, so this has nothing to do with first and second (and third also, IIRC) functionality in Rebol.
nedzadarek
12:12@rebolek Maybe he saw obj: make object! [...] ... second obj. So, he thought "I can use integer indexes on objects".
12:13After some time he tried it on the Red (not remembering exact details), expecting above.
rebolek
GiuseppeChillemi
20:37Yes, when I see a block I think automatically I can get its elements via integers
rebolek
20:38And you of course can. However, object is not a block.
GiuseppeChillemi
20:40I always think that there is an uniform access method in RED or REBOL so I apply the knoledge of blocks in object as when I probe them they actually seem an block with a "make object!" just before.
20:41It's common to abstract a rule and apply it on similar things.
20:41But REDBOL has many so many changes that this method can't be always applied.
rebolek
20:43There's no literal form of object which may be confusing for some people. But have a look at map!, it has its literal form - #( ... ), so you can't confuse it with block, can you? And objects are more like maps in this regards.
GiuseppeChillemi
20:43However I think that having uniform access methods make easier to handle the language.
20:44I don't know what you mean for "literal form" but I can imagine
rebolek
20:44There is uniform access method in form of path: x/y/z, but that does not mean that you can use integers everywhere, only where appropriate.
moliad
20:45objects have little to do with blocks. objects are not series.
rebolek
20:45Literal form is datatype specific syntax.
20:45Map has one, object doesn't.
GiuseppeChillemi
20:47Yes @moliad but first/second/third or obj/1 ../2 /3 is a method you could apply to object content. In fact in rebol you could use it on the third element of an object. (i.e.: probe first third obj)
9214
20:49@GiuseppeChillemi because third obj in Rebol is equivalent to body-of obj in Red.
GiuseppeChillemi
20:50So, having

z: make object! [b: 0 c: 1 d: 2]


a first z returning b could be a valid access method.
20:50@9214 Yes, now I have understood
20:51In RED a more explicit and verbose method is used
moliad
20:51@GiuseppeChillemi in fact /1 /2 /3 doesn't work in Rebol :smirk:
>> a: context [a: 8]
>> a/1
** Script Error: Invalid path value: 1
** Near: a/1
GiuseppeChillemi
20:51Just had to learn the proper way to get object contend
20:53@moliad

Yes, we have another way

>> z: make object! [b: 0 c: 1 d: 2]
>> probe pick third z 1
b:
== b:
rebolek
20:53words-of, values-of, body-of and of course object/key
moliad
20:54@GiuseppeChillemi I know, but just clarifying
9214
20:54@rebolek and select.
rebolek
20:55@9214 right. And in and other esoteric stuff ;)
GiuseppeChillemi
20:56@moliad I know you know but was me which didn't know.
rebolek
20:57
>> a: context [b: 2 c: 5]
== make object! [
    b: 2
    c: 5
]
>> get in a 'b
== 2
>> do bind [b] a
== 2
>> a/b
== 2
>> select a 'b
== 2
>> do reduce [first words-of a]
== 2
GiuseppeChillemi
20:59So, lets return on my first struggle

y: [b c d]
probe context? y/1


I supposed context? y/1 returned an empty context but instead it is the global one.
rebolek
21:00it can't return empty context, word cannot be member of empty context
moliad
21:00@GiuseppeChillemi yes, cause you created the [b c d] block on the console, so the created words where global at that moment
GiuseppeChillemi
21:01So, which is there rule here: words on a block have the global context when not created inside a function/object ?
moliad
21:02short answer yes
21:02long answer, it depends.
GiuseppeChillemi
21:03Noooo, I can't live with "depends" !
moliad
21:03it will use the "current" context. which is the global one by default (at root of app, on the console, etc.)
GiuseppeChillemi
21:04When I have written:

>> words on a block have the global context when not created inside a function/object

I meant that when created inside them they get their context which is the current one.
moliad
21:04it is possible that if you read code and load it within some other code, it will bind some of it there, and bind some of its words to the global context, if the words are new
GiuseppeChillemi
21:04Not as easy as it seems....
moliad
21:05dialects have a tendency to have a bind inside somewhere... ex: foreach, binds to a new hidden context, all the words in the 'words argument (the first)
21:06the rest stay as they where.
21:06function dialect binds all set-words to a new inner context.
GiuseppeChillemi
21:08If I have a:

foreach [value] block-with-specific-context
		[
...
		]


How do I manintain the context of block-with-specific-context
moliad
21:08what do you mean by "maintain"?
21:08here 'value is local to the loop.
rebolek
21:09@moliad not in Red:
>> x
*** Script Error: x has no value
*** Where: catch
*** Stack:  

>> foreach x [1 2 3][]
>> x
== 3
moliad
21:09all the rest of the content in 'block-with-specific-context stays bound to the same value
GiuseppeChillemi
21:10but value get its value for a block and block words could a context you may want to have on value too
moliad
21:11@rebolek
> not in Red:
>
> >> foreach x [1 2 3][]
> >> x
> == 3
>



what! is this by design or is it an unresolved side-effect?
9214
21:14@moliad unresolved design.
21:14Iterators' words remain in global context.
moliad
21:15was it a debate or just not addressed?
rebolek
21:15it's faster this way right now
21:15but it's not final design
GiuseppeChillemi
21:15@9214 I have already read about it on a discussion on GITTER time ago...
9214
21:17@moliad there's no "current" context though. All words that pass the lexer defaults to global context. Then, at run-time, words acquire new contexts as evaluation of everything related to function! and any-object! builds up.
moliad
21:17I often hear the argument about foreach being "slow" in R2... well its the *fastest* iterator in the language.
I did a 10 hour study on all iterators. the single binding pass isn't a bit deal... unless you use foreach in a huge block
rebolek
21:19I believe there are implementation differences between R2 and Red that may have something to do with that decision.
moliad
21:24hum... looks I'll have to redo a few tests to discover some of the more complex binding issues that crop up with self-modifying code and run-time compilation.
GiuseppeChillemi
21:40I am working on having a single function with different arguments length depending on the "method" of the function.

Example:

alter-db 'add-rows ["db-name" "table-name" [column1 column2 column3]]
alter-db 'remove-table ["db-name" "table-name"]


The same alter-db has different number of arguments depending on the method used

Inside alter-db I have a block which specifies the words of the arguments

Alter-DB is defined as

Alter-DB: function [
    method
    arg-block
]
[
   fnc-args: [
      'add [db table rows]
      'remove-table [db table]
   ]
]


I want to associate each word in a method i.e. 'ADD has -db table rows-

To the corresponding word in arg-block


21:41Note: I know I could use objects but I wish to build from this the learn some red topics.
21:42Actually I am stuck into building a global function which is used to associate method words to arguments when called from any functions which is built this way
9214
21:46set select fnc-args method arg-block
GiuseppeChillemi
21:47@9214 block to block mapping ?
9214
21:50A crude substitute for what should be an object with dedicated methods.
nedzadarek
21:54@moliad so foreach's word is binded to a local context (e.g. function) but set doesn't bind. I wonder why setdoesn't behave like foreach.
GiuseppeChillemi
21:54@9214
What if I use a global function like:

set-args: function 
[my-args arg-words] 
[
    set select my-args method arg-words
    .....
]


and call it from the inside of alter-db

using
set-args fnc-args arg-block

After selecting them ?

How do I bind words to the calling function ?
moliad
21:55in Red, it seems like foreach doesn't bind (confirmed).
21:56set doesn't deal with binding... that's the magic, it just uses the word's binding (remember that all any-word! types store their binding internally)
9214
21:56@GiuseppeChillemi they are already bound to calling function if they were /local to it.
GiuseppeChillemi
21:58@9214 I'll experiment tomorrow. Now I feel the need to sleep. Another evening with the pro's makes me so tired....
nedzadarek
21:59@moliad
> in Red, it seems like foreach doesn't bind (confirmed).

>> f: function [] [foreach w [1 2 3] [print w]]
== func [/local w][foreach w [1 2 3] [print w]]
>> f
1
2
3

It could be the function that does this but I mean the results (word is local)
GiuseppeChillemi
22:04A very last question:

>> aa: 1
== 1
>> zz: [aa bb cc]
== [aa bb cc]
>> same? 'aa zz/1
== true


I have always thought that

aa
in the main code
and
aa in [aa bb cc]
Are totally different
22:05But the implications of being same? has implications still to understand in my mind.
22:06No, thats not a question. Its simple a new topic to work on.
9214
22:06[aa bb cc] *is* the "main code".
GiuseppeChillemi
22:06@9214
Thanks, I'll spend my night having nightmares !
9214
22:07Your two aa's are idential because they have the same spelling and are bound to the same context.
GiuseppeChillemi
22:07@9214
I'll have a lot of problems in my REM phase.
9214
22:08Very funny.
GiuseppeChillemi
22:08@9214 However thanks, you are giving me topics to think on. See you tomorrow !
greggirwin
22:21> Yes @moliad but first/second/third or obj/1 ../2 /3 is a method you could apply to object content. In fact in rebol you could use it on the third element of an object. (i.e.: probe first third obj)

The key distinction here is intended use. Maps and objects are based on *unorderd* key-value slots, blocks are based on *ordered* slots. This is an important distinction. While this is not laid out in a design spec, it tells you that it is safe to use blocks based on their order, but that it's *not* safe to do so with maps and objects. That is, a block will always return values in the same order, but a different implementation of map/object *might* change the internal order of things, and return them in a different order in response to words-of/values-of.
GiuseppeChillemi
22:22Blocks were so innocents for me.. Now a have to build a whole new mind map
greggirwin
22:29On foreach, as @nedzadarek showed, it is special, along with remove-each and repeat, If you use function rather than func. _function/collect-words and _function/collect-deep are responsible for that special handling.

This is a workaround for now, but a fairly effective one in most cases. Not perfect, but better than nothing.
22:30_function is the context name in the function! datatype code.
moliad
22:32@greggirwin not sure I follow you. foreach currently doesn't "localize" words in Red
22:33or does it on set-word! within?

hiiamboris
22:34@moliad function constructor does that
moliad
22:35yes... but @greggirwin refers to foreach in his post. (btw I just checked and foreach doesn't localize set-word! values)
hiiamboris
22:37https://github.com/red/red/blob/master/runtime/datatypes/function.reds#L556
GiuseppeChillemi
22:37@9214 while coding I had the needing to reuse object method arguments without rewriting them for each method. The final version of this 'crude object' Will be a function with many methods that share a couple of arguments sets.
hiiamboris
22:37@moliad function constructor does that for foreach and some others ☻
moliad
22:38(I just tested, and foreach does no localization of any word.)
22:39the fact that its within another context (within a function or an object), isn't a property of foreach
hiiamboris
moliad
22:40sorry for being anal... I don't want people to get mixed up :smirk: ... its already easy to mess up binding understanding
22:41gtg, will be back tomorrow, ciao!
GiuseppeChillemi
22:52@moliad can't - bind sleep me -
22:53Words are floating in my mind in every RED context
greggirwin
22:57@moliad, correct. Foreach doesn't collect and bind words currently. Function does that.
o: object [
    f: func [][foreach w [1 2 3][]]
    ff: function [][foreach ww [11 22 33][]]
    f
    ff
    attempt [print w]
    attempt [print ww]
]

print mold words-of o
w
nedzadarek
23:06@moliad I (we) mean this:
- function makes all set-word! local (adds it to the /local refinement f: function [][a: 1] ; == func [/local a][a: 1])
- as you know, setting words without using *set-syntax* (foo: 42) won't make a word local (f: function [] [set 'a 1] ; == func [][set 'a 1] <- a isn't local)
- foreach make function collect that word ([wrong - to be more precise](https://gitter.im/red/help?at=5c6dd4be85b7eb456904d468)) -> f: function [] [foreach w [1 2 3][ print w]] ;== func [/local w][foreach w [1 2 3] [print w]]
23:11@greggirwin :point_up: [February 20, 2019 11:29 PM](https://gitter.im/red/help?at=5c6dd4be85b7eb456904d468)
1) Is there a plan to include other functions (especially set)?
2) Can we access & modify _function/collect-words and _function/collect-deep from within Red (console? compiled?)
9214
23:151. No.
1. No.
greggirwin
23:33@nedzadarek, set works the way it does by design. It allows you to externalize a word without having to use /extern, so it will not change. And you *really* don't want to mod things in the bowels of the langauge, even if you can, because that will create all sorts of problems when sharing code and staying compatible with language changes.
nedzadarek
23:57@greggirwin
>It allows you to externalize a word without having to use /extern

What about set (or other "functions") in the parse (f: function [] [parse [a] [set z word!] z] z; a)? It wasn't my intention to externalize a word by using set here.
Could you change that kind of functions (or introduce others) in the parse to be "local"?

9214
00:00If it wasn't your intention, then word should have been bound to another context in the first place.
nedzadarek
01:34@9214 I want to create some words in the parse. That's my intention.
It modifies global context (in the mentioned case) but have I specifically chosen that function so it behaves this way? No. I don't have a choice - there is no another function to choice from.
9214
02:21No idea what "create some words" means. Parse doesn't create them in any way, make, to and load do.

> but have I specifically chosen that function so it behaves this way? Yes.

Fixed it for you. There's plenty of functionality to make it work the way you want, but you seem to ignore all of it so as to strengthen your argument.
>> f: func [/local z][parse [a][set z skip]] :.
>> f: does [parse [a] bind [set z skip] context [z: none]] :.

You can even intercept set and copy within callback function and aggregate their arguments for further post-processing.
callback: func [event match? rule input stack][
	also yes if all [match? find [set copy] rule/1][
		append words rule/2
	]
]

probe unique also words: [] parse/trace [a b c][
	ahead [copy a [3 word!]] 
	ahead [set b skip]
	copy c [2 skip]
	set  d to end
] :callback

unset words


set and copy can support paths the way Rebol does, but that will cause a slight decline in perfomance. https://github.com/red/red/issues/3528

What was it with your "no choice" once again..?
greggirwin
08:02@nedzadarek I'm not clear on the goal or problem, but maybe @9214's example cleared it up.

> I want to create some words in the parse.

This is the part I don't understand.
pimgeek
09:15how to generate an array of numbers [0 1 2 3 4] like in Python3 : list(range(5)) ? I search for answers online but without luck 😥
09:20[![image.png](https://files.gitter.im/red/help/STh8/thumb/image.png)](https://files.gitter.im/red/help/STh8/image.png)
rebolek
09:21change num-list: [] to num-list: copy []
pimgeek
09:22> change num-list: [] to num-list: copy []
Oh, thanks very much! I will have a try
09:24It works! I believe I need to learn more about copy and Red's "word"
rebolek
09:30@pimgeek good idea :) If you have any questions, feel free to ask. Just a note, in Red, functions do not use (...) for arguments. It works in your case, because your function has just one argument and parenthesis evaluate all values and return last. So (3) in your case becomes 3. But if you'll have function with more than one arg, it won't work.
pimgeek
09:31oh, my god ... I mistyped it and didn't notice
09:31[![image.png](https://files.gitter.im/red/help/BxQv/thumb/image.png)](https://files.gitter.im/red/help/BxQv/image.png)
09:32I have checked the manual and found the following BEGGINER MUST KNOW, thanks for your kind help, I will finish all of BEGGINER's reading.
rebolek
09:33You're welcome!
pimgeek
09:34BTW, is there anything in Red like (let ... ) in the Lisp language?
09:35I mean, data "processing" without side effects?
bitbegin
09:36
>> range: function [num [integer!]][list: clear [] repeat i num [append list i] list]
== func [num [integer!] /local list i][list: clear [] repeat i num [append list i] list]
>> range 10
== [1 2 3 4 5 6 7 8 9 10]
>> range 10
== [1 2 3 4 5 6 7 8 9 10]
>>
rebolek
09:36In Red, words have their value based on context in which they are defined, so it possible to do something like let, but differently.
09:37
>> a: context [b: 1 print b context [b: 3 print b] print b]
1
3
1
09:38@bitbegin or you can use collect and get rid of local block:
>> range: func [num][collect [repeat i num [keep i]]]
== func [num][collect [repeat i num [keep i]]]
>> range 5
== [1 2 3 4 5]
bitbegin
09:41:+1:
nedzadarek
11:31@9214 @greggirwin
> create some words

When you use parse you can set words to some value, for example in parse [a] [set w word!], parse creates word w.

> Fixed it for you.

No. You are wrong.

>There's plenty of functionality to make it work the way you want, but you seem to ignore all of it so as to strengthen your argument.

Why do you think I'm using function by default? It's the closest to a "I don't care, just don't mess global space - make everything local" attitude. I'm not ignoring anything - it's just they are less suited to more complex code. Let's dissect your examples.

> f: func [/local z][parse [a][set z skip]]

You have only one local word z. What if you have 10 or 20 words that have more than 4 characters in it? For example:
f: func [
  /local abakus abrakadabra ...
][..]

You are making code longer (harder to understand, even it's by "a little).

> f: does [parse [a] bind [set z skip] context [z: none]]

You find this in someone's code. What's the purpose of the bind here? You have to go to the context to see whenever or not someone are changing some core functionality of the parse. It makes code less readable.

> You can even intercept set and copy within callback function and aggregate their arguments for further post-processing.

>> f: function [] [
[    probe unique also words: [] parse/trace [a b c][
[        ahead [copy a [3 word!]] 
[        ahead [set b skip]
[        copy c [2 skip]
[        set  d to end
[    ] :callback
[    unset words
[    ]
== func [/local words][
    probe unique also words: [] parse/trace [a b c] [ahead [co...
>> a
*** Script Error: a has no value
*** Where: catch
*** Stack:  

>> a: 42
== 42
>> f
[]
>> a
== [a b c]

Yes, it's that easy.

> What was it with your "no choice" once again..?

If you are going to say I have choice because the language is (is it?) turing complete then you should check what is [the Turring tarpit](https://en.wikipedia.org/wiki/Turing_tarpit). Is it the turring tarpit? I guess no... but It starts to depart from the Rebol's motto "Rebol against complexity". Especially your binding code.
pimgeek
12:14😍 So much precious knowledge sharing~
12:21@nedzadarek Thanks for quoting the Turing-Tarpit anecdote, it's really mind-refreshing 🤯
12:32@rebolek the collect ... keep procedure is amazing, if you don't show me the code, I would have to struggle much more to understand if by reading the manual 👍😊
12:36@bitbegin Thanks for demonstrating the usage of clear 👏
nedzadarek
14:22@pimgeek If you liked collect then you could try [cold](https://github.com/nedzadarek/cold.red).
pimgeek
14:24@nedzadarek Okay, I will star it and create a reference in my TheBrain KB 👌
14:26Do you know whether I can declare a constant value in Red lang?
14:34[![image.png](https://files.gitter.im/red/help/HgrN/thumb/image.png)](https://files.gitter.im/red/help/HgrN/image.png)
rebolek
14:36@pimgeek you can't (yet).
pimgeek
14:37@rebolek thanks for confirming that 👌
moliad
14:48doesn't red support a macro prepropressor built-in? or is that just for R/S?
rebolek
14:50Hm, it does, I guess. But if you're in console, it doesn't help you very much.
moliad
14:50but constants don't really make sense in a console anyways ;-)
rebolek
16:16well for testing, they do
nedzadarek
16:19@pimgeek nice visualisation - can we see it online?
9214
16:57@nedzadarek

> Why do you think I'm using function by default?

Because you're naive enough to think that it can cover all cases properly, and take care of set and copy in Parse.

> it's just they are less suited to more complex code.

Maybe the problem is in your code then? As you yourself so boldy affirmed: *but It starts to depart from the Rebol's motto "Rebol against complexity"*

> Let's dissect your examples.

Straw man fallacy. Do you understand how ridiculous it is to "dissect" one-liners written for demonstrative purpose? They show an idea, not an implementation.

> What if you have 10 or 20 words that have more than 4 characters in it?

Then you probably should reconsider your design approach.

> whenever or not someone are changing some core functionality of the parse. It makes code less readable.

I have a hard time trying to follow this argument. Purpose of bind is evident here, and you can change "core functionality of Parse" from Red, because it's a parsing engine written in R/S.

> Yes, it's that easy.

If you try to discredit me, at least do so properly:
>> f: function [][
[    	callback: func [event match? rule input stack][
[    		also yes if all [match? find [set copy] first rule][
[    			append words rule/2
[    		]
[    	]
[    
[    	probe unique also words: [] parse/trace [a b c][
[    		ahead [copy a [3 word!]] 
[    		ahead [set b skip]
[    		copy c [2 skip]
[    		set  d to end
[    	] :callback
[    
[    	unset words
[    ]
== func [/local callback words][
    callback: func [event match? rule input stack] [also yes if all [match? find [set copy] first rule] [append words...
>> reduce [:a :b :c]
== [unset unset unset]
>> set [a b c][1 2 3]
== [1 2 3]
>> f
[a b c]
>> reduce [:a :b :c]
== [unset unset unset]

Above works as expected, contrary to your claim.

> If you are going to say

Oh, no, I'm not going to say anything. Seeing how you don't have anything constructive (or original) to add to this discussion, I'm rather disinterested in continuing it. Arguing for the sake of arguing is solely your prerogative.
rebolek
17:00I think that the discussion can be less personal.
9214
17:02@pimgeek

> is there anything in Red like (let ... ) in the Lisp language?

let: func [environment body][
	do bind copy/deep body context environment
]

set [a b][1 2]

let [a: 3 b: 4][
	probe a + b
]

probe a + b
nedzadarek
18:27
> Because you're naive enough to think that it can cover all cases properly, and take care of set and copy in Parse.

No, read the next sentence...

> Straw man fallacy. Do you understand how ridiculous it is to "dissect" one-liners written for demonstrative purpose?

I'm sorry. I should have used different word. I guess "examine" should be better.

> Then you probably should reconsider your design approach.

https://github.com/red/red/blob/master/runtime/allocator.reds#L466

> Purpose of bind is evident here,

Yes, it's easy to understand. You know why? Because it's just one line. When you write more line you will start to understand this.

> and you can change "core functionality of Parse" from Red, because it's a parsing engine written in R/S.

Not sure why mentioned R/S but I agree, I can change (at least some part) parse.

> If you try to discredit me, at least do so properly:
> Above works as expected, contrary to your claim.

So, do you expect to **destroy** some words from some other context? Well, I'm not sure why you corrected it. I'm really confused about this code. We were talking about "local words in the function" (how to make it local) and your function changes/delete those words (and it shouldn't do this)

> Oh, no, I'm not going to say anything. Seeing how you don't have anything constructive (or original) to add to this discussion, I'm rather disinterested in continuing it. Arguing for the sake of arguing is solely your prerogative.

I'm sorry. I believe in my arguments but I cannot explain it clearly to you. It might be my knowledge (language and/or programming).
I respect you for your knowledge and willing to help others so I, as you said, I don't want to waste your and mine time.
I'm fine If you don't want to answer to this post.>
GiuseppeChillemi
20:44I would try to create self generating code from "specs", either as function, or objects or parse code to create a DSL.
Could I define an object and then make it even if not defined at code start ?
Could I do the same with a function ?
Is there any code I could not create dynamically in RED ?
rebolek
20:46> Is there any code I could not create dynamically in RED ?

No.
20:50@nedzadarek @9214 I think that there's a misunderstanding. There are no "local words in the function" in Red/Rebol. There are only words that belong to some context and that's what some people don't understand and some people can't explain. But only patient explanation can bring understanding, restlessness is just a distraction. There should be some Zen of Red guide that can calm everyone down.
GiuseppeChillemi
20:50@rebolek I ask again, because I had no answer to this gitter question:

--------------
In [RED Blog](https://www.red-lang.org/2012/12/red-v031-functions-support-added.html) I have read :

Still some features are not yet implemented:

building a function at runtime (requires the ability to JIT-compile source code)
-----------------
rebolek
20:51@GiuseppeChillemi that's a statement, not a question. It's not implemented, yes.
GiuseppeChillemi
20:53@rebolek It's me who has written this the gitter question and I was asking if this affirmation is still valid.
20:54> It's not implemented, yes.

Do you mean "yes, you can't build a function at runtime, this affirmation is valid " ?
rebolek
20:55Yes, you can't build a function in Red/System at runtime, this affirmation is valid.
20:56It's really low priority.
20:56It would be nice to have, but compiling is so easy that it's really not a problem.
GiuseppeChillemi
20:58@rebolek Excuse my ignorance: what does mean "building a function at runtime ?" could you make an example ?
9214
21:00How can @rebolek make an example if it's not implemented?
rebolek
21:01@GiuseppeChillemi it means building a **Red/System** function at runtime. Are you using Red/System?
GiuseppeChillemi
21:02@9214 No
21:02Pardon
21:02@rebolek No
rebolek
21:02Then you should forget about it and enjoy the world as it is.
GiuseppeChillemi
21:05@9214 I tought that "building a function at runtime" was something related to code like

a: func [] []

In RED
21:05But built with COMPOSE
rebolek
21:07Nope, this is only related to Red/System.
GiuseppeChillemi
21:08Ok, so I can leave without it (by now !)
9214
21:08Jeez... you link a 7 year old blog post about Red compiler and ask if it's possible to create function's at runtime *in compiled code* - the answer is **no**, because that would require just-in-time compilation, and current compiler is ahead-of-time one. In general, current compiler cannot support dynamic code.

You **can** build functions at runtime in interpreter though, that's what func, function and other function constructors do all the time.
rebolek
21:09@9214 please...
9214
21:09You can create them, but you can't modify their specs, because that would require JIT compiler too.
GiuseppeChillemi
21:11Actually I discovered that I can't use a SELECT in place of functions arg block or code block, selecting them form another block which acts as a library. This because after the first run the associated code is maintained and no more selection is possible.
This is the reason why searching for documentation on functions I tought that post was still valid, even after 7 years.
21:13@rebolek
> @9214 please...

:-))))

Vladimir can answer in any way he wants to me. I have started to get used and apreciate the good thing of him (talking personally)
rebolek
21:14@GiuseppeChillemi of course the docs are still valid, but you need to differentiate between Red and Red/System. If you can post some examples of your code, it would be really helpful.
21:15@GiuseppeChillemi
> Vladimir can answer in any way he wants to me.

Great :smile:
GiuseppeChillemi
21:20@rebolek his personality and knowledge makes him the great person he actually is and he does not need to change to "sweeten the pill". I have learnt to read what he writes and not anymore the sound that make his words in my head.
21:22@9214 , @rebolek
So RED/System functions are different from RED functions. The first ones are not so flexible like the last.
rebolek
21:41Yup, there's some subtle difference.
nedzadarek
22:27@rebolek I don't think I confused someone like him.
Well... do you have better short phrase to describe this?
Rebootr
23:03Good night. When I try to start red-064.exe, after a while compiling the console closes. While compiling, I looked at the %ProgramData% directory, and a dll and gui-console.exe was created. As soon as the gui-console file has been created, it is deleted and the screen closes, with no error or warning message. Anyone have any idea what's going on? The version red-063.exe works normally.
hiiamboris
23:18@Rebootr could be a malicious prank of some "antiviral" software
nedzadarek
23:19@Rebootr I don't have such problems. I assume you are on windows. Could you start the console (cmd) and run it from there? You may see some errors this way.

pimgeek
03:07@nedzadarek it's not synced with the cloud 😅 but possible, I can used thebrain cloud service to publish my local data online. But the cloud service is way too expensive. I plan to develop my personal customized publishing site, as well as a desktop client. 😊
03:10 Can I use the red language to manage a sqlite3 database? If I can do that, it will be cross-platform 😊
nedzadarek
08:37@pimgeek I see. Well, I'll be waiting for it.
viayuve
09:04how many core red uses when compiling.
rebolek
09:05Red does not compile, compiler is written in Rebol. And it's single threaded application.
viayuve
09:07rebol pro sdk :(
rebolek
09:07No, you don't need SDK license for compiling.
09:08Free version is enough.
viayuve
09:08i just want fast compilation :cry:
rebolek
09:09I don't understand.
viayuve
09:11my one program compilation takes about 5 to 7 min
rebolek
09:12That must be a big program.
09:13Anyway. compiler is written in Rebol, so it's interpreted. You can't expect it to run fast. Once it gets rewritten to Red and compiler could be compiled, then it should get faster.
viayuve
09:340.9.5 right ?
rebolek
09:35I guess so.
Rebootr
10:17@hiiamboris You're right! in the McAfee log I found this: BehavesLike.Win32.Dropper.th, GenericRXGX-HD!9F7841A16EA4
9214
15:09@Rebootr please report it as a false positive. We fight an uphill battle with AV vendors whose recognize Red as "generic malware", McAfee included.
GaryMiller
15:36Couldn't you compress the .exe file before distribution to prevent it from being falsely identified as Malware.
endo64
19:05> my one program compilation takes about 5 to 7 min

@viayuve You might compile your program with -r if it is not necessary compile without it, it would be faster (if you don't have R/S in your code of course)
GiuseppeChillemi
21:13Ops... wrong group
21:13No... right one !
21:13@9214
Well, I have tried the SET words-block values-block solution with no success.


test: function 
[
	action 
	passed-args-block [block!]
]
[
	
		args-def: [
		add 
		[
			the-path [string!]
			key [word!]
			value [any-type!]
		]

		del
		[
			the-path [string!]
			key [string!]
		]
	]

		function-words: extract select args-def action 2
		
		set function-words passed-args-block 		

]

test 'add ["a-path" "a-key" "a-value"]


probe the-path 
probe key 
probe value


"a-path"
"a-key"
"a-value"
>>>


Words set into function seems to exists after function exit:


9214
22:01
text
test: function [
	action arguments
	/local
		path key value
][
    table: [
        add [path key value]
		del [path key]
    ]

    set select table action arguments
]
nedzadarek
22:10@GiuseppeChillemi I haven't followed the discussion but:
that's because function only collect set words (+ some exception) and [the-path key value] are words.
ps. if you want post simple code snippets that people would run in the repl then avoid unnecessary new lines (e.g. after function, after first ]. Your code might compile but it won't run correctly in the repl.
GiuseppeChillemi
22:20@9214 is there any solution without enumerating words in the argument block ? I would have the table block as the only source of words.
22:21@nedzadarek what Is the REPL?
Respectech
22:54@GiuseppeChillemi REPL is the Red console. It is a generic term for a console that takes commands and executes them.
nedzadarek
23:19@GiuseppeChillemi google is your friend: read–eval–print loop ([source](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)). Just like Red's console:
1) it reads what you type
2) evaluates it to some data
3) print that data to the user
4) go to 1 till you close the console
More in-depth information in the [source](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop).
gltewalt
23:49@GaryMiller Yes, compressing it with upx tends to be a workaround
23:53@viayuve Are you using -c option to compile as you work. It’s much faster than -r (release mode).
You should only need release mode when your ready to distribute the binary. Release mode might take awhile, but it’s a one time thing

GiuseppeChillemi
09:08@nedzadarek
> ps. if you want post simple code snippets that people would run in the repl then avoid unnecessary new lines (e.g. after function, after first ]. Your code might compile but it won't run correctly in the repl.

Those "unnecessary" new lines avoid me being confused. Words are isolated and clear and there are not so many symbols that my mind have to decode.
09:19It seems there is no other way to have "local" words in a function other than the argument block (I have not found one). I have tried Bind 'word self with no success. Now I am wondering if SET could have a /current context refinement, to express the context that RED automatically adds to words. Another way would be to have a SET/BIND where you can express one in some way as argument of SET.
11:19I have tried even binding directly passing the current function name with no result:

test: function []
[
		set 'should-be-local "You should not see me"
		bind 'should-be-local 'test
]
probe should-be-local 

== "You should not see me"
>>
rebolek
11:45of course, that's the expected result
GiuseppeChillemi
12:00@rebolek , I do not expect this but and error 'should-be-local should not be in the global context.
toomasv
13:26@GiuseppeChillemi I don't think you should expect people to first correct your formatting and then advise you:
>> test: function []
*** Script Error: function is missing its body argument
*** Where: function
*** Stack:
gurzgri
13:33@GiuseppeChillemi , function is auto-localising only set-words and using set with a lit-word explicitly bypasses that mechanism, adding should-be-local to the global context. Even if should-be-localwould've been declared in the function's context, bind 'should-be-local 'test would rebind it to the context thetest word is bound to. With the context of the testword being the global context rather than the function's context (as you seem to assume).
13:35The main question probably is why you would need a way to have local words in a function by other means than declaring them in the argument block at all.
GiuseppeChillemi
14:00@toomasv Tooms, I have never tested my own code from coping and paste from gitter. Thanks to your example I have now realized that writing on the REPL console causes this problem. I thought @nedzadarek complain was about my "uncommon" formatting and not about unusability.
14:30@gurzgri Having a lot of functions operating on the the same kind of dataset, usually you have identical or simular arguments block.

I am experimenting a "simpler" approach which let me express in a way like:

db 'add-table [arguments]
db 'delete-table [arguments]
db 'add-row [arguments]


This because, as I have written: [arguments] is the same for 2 or more functions. Selecting them from a table let me:

1) Change the argument interface once and for all
2) Save a lot of typing
About this point I have still not show the block of code which maps an arguments to multiple methods.

mapping: [
   arguments-block-name-a [method1 method2 method3]
   arguments-block-name-b [method4 method5]
]


or another one (have to choose)

mapping: [
   method1 arguments-block-name-a 
   method2 arguments-block-name-a
   method3 arguments-block-name-a
   method4 arguments-block-name-b
   method5 arguments-block-name-b
   ]


(In my mind I see also function composing built from tables of code but If I won't solve this problem I can't further experiment)
14:45@gurzgri

>> Even if should-be-localwould've been declared in the function's context, bind 'should-be-local 'test would rebind it to the context thetest word is bound to. With the context of the testword being the global context rather than the function's context (as you seem to assume).

If I had a way to express bind this word to test function inner context and not to the outher (global) one. But SELFseems it doesn't exists and this is now blocking.
gurzgri
14:58@GiuseppeChillemi There may be other ways, e.g. something like
spec: [add-table delete-table [db table] add-row [db table row]] ;-- function specs 
code: [add-table [a: 1] delete-table [b: 2] add-row [c: 3]]      ;-- function bodies

db: object collect [foreach name spec [all [
    word? name
    keep reduce [to set-word! name 'function first find find spec name block! select code name]
]]]

? db
GiuseppeChillemi
15:28@gurzgri Yes, it is another way.
But a question remains: why SELF isn't available for functions ?
15:28Is it planned ?
gurzgri
15:54@GiuseppeChillemi , Sorry, I can't make any statements on Red features planned/not planned. I know of no use cases which would require it.
GiuseppeChillemi
15:58@gurzgri extending the words of a function and binding them to the function inner context actually seems an use case.
gurzgri
16:05 @GiuseppeChillemi With extend on objects being reserved for future use (or not yet implemented) it seems having selfin functions wouldn't gain you anything for now (I may be missing something here). Why not just have a function local word set to a map! and extend that if you think that's the way to go?
GiuseppeChillemi
16:16@gurzgri Christian, I feel that something is missing not having the ability to access SELF for functions and if you want dynamically add some words from the inner of it, you simply can't do it. But maybe I am still to "young" to express a more argumented opinion.
16:17About EXTEND, I know you can't actually extend an object and I'll wait with curiosity in mind how it will be implemented.
hiiamboris
17:19> But a question remains: why SELF isn't available for functions ?

@GiuseppeChillemi It's easy: self is used mostly inside object's functions to address that object. If it was overridden inside a function, you wouldn't be able reference the object anymore.
GiuseppeChillemi
18:45@hiiamboris what you mean for overriding It in a function as It does not exists ?
gurzgri
18:56@GiuseppeChillemi Given selfwould be available in functions to access a function's context, self would no longer be available to access the context of a function's outer (object) context. Which is an ubiquitous [pattern with OOP](http://www.rebol.com/docs/core23/rebolcore-10.html#section-7), and no doubt used in large codebases.
JLCyclo
19:45yep! About github and repository red/community... I would like to add a script in the repository, but I can't make the pull request.. I click "create pull request" on github but nothing appears...
19:46I made a fork: cyclo07/community and I woul like to create a pull request for red/community
GiuseppeChillemi
20:57@gurzgri
> @GiuseppeChillemi Given selfwould be available in functions to access a function's context, self would no longer be available to access the context of a function's outer (object) context. Which is an ubiquitous [pattern with OOP](http://www.rebol.com/docs/core23/rebolcore-10.html#section-7), and no doubt used in large codebases.

I have read the article. In my scenario, a function is like an encapsulating object for words and functions but it has no way to access extend itself using SELF. It is somehow more limited than an object. While the encapsulator object method to have local variables and access them from the inner function solves thing, it forces to use a OBJECT-NAME/FUNCTION-NAME notation where FUNCTION-NAME is shorter and more readable.
21:09@gurzgri
I can see why function SELF could override SELF of the encapsulator object. Also like a newbye I could suggest having SELF with parents to navigate SELVES backwards if possible but I imagine is not so easy. Regarding this topic I have read there is no backlink in blocks and @9214 once "suggested" to read the code and try to write a double linked table (or something like this). Maybe it is the same reason why we have not nested SELVES which are backward accesible.
nedzadarek
21:34@GiuseppeChillemi about "unnecessary" lines:
You can always edit it in the browser. Choice is yours.

About local words:
There are probably many ways to simulate it. You can keep local words in a map (1) or bind body words to some context (2).
1) f: function [/local local-words] [local-words: #() local-words/should-be-local: 42]
2) g: function [] bind [should-be-local] context [should-be-local: 42]
GiuseppeChillemi
22:42@nedzadarek What you mean for "you can always edit in the browser" ?
22:43About solution number 2: I do not understand it ;-)
endo64
23:22@JLCyclo You should click on the Pull request link on your own fork: https://github.com/JLCyclo/community
23:22Here you can see:
23:22[![image.png](https://files.gitter.im/red/help/TA61/thumb/image.png)](https://files.gitter.im/red/help/TA61/image.png)
nedzadarek
23:29When you paste your code into gitter ("Click here to type chat message...") you can delete/remove (or add) some characters.
For example this:
>> 7 * 6
== 42

I will change to this:
7 * 6
; == 42

(no >> and added comment - ;)
23:32@GiuseppeChillemi
> About solution number 2: I do not understand it ;-)

You know what binding is?
23:37ps. It might not work with recursive functions.

gltewalt
06:49What is this strangeness about?
>> n: now
== 23-Feb-2019/23:48:26-07:00

>> repeat i 15 [print ["picking" i "from n returns:" pick n i]]
picking 1 from n returns: 23-Feb-2019
picking 2 from n returns: 2019
picking 3 from n returns: 2
picking 4 from n returns: 23
picking 5 from n returns: -7:00:00
picking 6 from n returns: 23:48:26
picking 7 from n returns: 23
picking 8 from n returns: 48
picking 9 from n returns: 26.0
picking 10 from n returns: 6
picking 11 from n returns: 54
picking 12 from n returns: -7:00:00
picking 13 from n returns: 8
picking 14 from n returns: 8
*** Script Error: value out of range: 15
*** Where: pick
*** Stack:
06:54And with time!
>> pick 12:23 1
== 12
>> pick 12:23 2
== 23
>> pick 12:23 3
== 0.0
>> pick 12:23 4
*** Script Error: value out of range: 4
*** Where: pick
*** Stack:

07:43Something I don't understand at the moment, or bugs?
rebolek
07:49see system/catalog/accessors
nedzadarek
10:58@gltewalt I think time! is fine -> 1st, 2nd and 3rd values are hour, minutes and seconds with milliseconds (in float).
toomasv
12:04@gltewalt Not bug. There are 15 accessors but 14 fields. 15 is not defined in [date.reds](https://github.com/red/red/blob/master/runtime/datatypes/date.reds#L100):
>> pick system/catalog/accessors/date! 15
== julian
>> n/julian
== 55
>> n/15
*** Script Error: cannot access 15 in path n/15

12:09And here's why there are [14 fields only](https://github.com/red/red/blob/master/runtime/datatypes/date.reds#L886):
sym = words/yearday	 [field: 11]
sym = words/julian [field: 11]
hiiamboris
12:13@toomasv but this (2 symbols mapped to one field) is a bug
toomasv
12:13@hiiamboris Isn't it just an alias?
hiiamboris
12:14That's what I just read on google:
> The Julian day or Julian day number (JDN) is the number of days that have passed since the initial epoch defined as noon Universal Time (UT) Monday, January 1, 4713 BC in the Julian calendar
toomasv
12:14Oh, then it is not yet implemented.
GiuseppeChillemi
15:16@nedzadarek
> @GiuseppeChillemi
> > About solution number 2: I do not understand it ;-)
>
> You know what binding is?

I am learning it..
15:24@nedzadarek

Here:

2) g: function [] bind [should-be-local] context [should-be-local: 42]

g: function []


Your are defining the first part of the function

bind [should-be-local]


Here I don't understand why [should-be-local] instead of 'should-be-local

context [should-be-local: 42]

Here you create and object which is the body of the function.

I am missing the connection between the head of the function and its body with bind.
gltewalt
15:54Got it
nedzadarek
16:40@GiuseppeChillemi

> Here I don't understand why [should-be-local] instead of 'should-be-local

Because I want to create a block not just a word (block? (bind [a] context[]) ; == true). function takes 2 arguments: 2 blocks (spec and body).
spec: [] 
body: [] 
function spec body


Let me group function's arguments using parens: function ( [] ) (bind [should-be-local] context [should-be-local: 42])
function's body is an empty block ([]) and body is bind [should-be-local] context [should-be-local: 42]
bind BLOCK context [] will return a block - this is what function needs. I couldn't use words (bind 'word context[]) because it wouldn't return a block.
JLCyclo
19:10[![blob](https://files.gitter.im/red/help/1Nb7/thumb/blob.png)](https://files.gitter.im/red/help/1Nb7/blob)
19:13@endo64 thanks, but it does not seem to work...
GiuseppeChillemi
19:23@nedzadarek
Tried on the console

>> g: function [] bind [should-be-local] context [should-be-local: 42]
== func [][should-be-local]


What I has still not encountered is binding on a block.
I'll try to understand what we are doing, context and binding.
Here you are creating the second block of function. The second block consist of only a word which is should-be-local.
You have then created a context where should-be-local value is 42.
Then you have "linked" (bound) the context to the second function block, so should-be-local value is 42 in that context.
Function, which has become FUNC (why?) has now 2 block. An empty one, and the newly defined.
nedzadarek
20:21@GiuseppeChillemi
> function, which has become func (why?)

In the red you have "function constructors" (not sure if this is the right term). They just modifies spec and/or body argument (both are blocks) and "send" them to the func.
>> has [][]
== func [/local][]
>> does[]
== func [][]
>> func [] []
== func [][]
>> function [] []
== func [][]

Here is a little example where my newly created function constructor makes all function prints "Answer: 42":
answer-func: func [spec body] [
  insert body [print "Answer: 42"] 
  body: back body 
  func spec body
]
f: answer-func [a] [print a * 10]
f 3
; Answer: 42
; 30

g: answer-func [] [print "Hello world"]
g
; Answer: 42
; Hello world

20:29> has now 2 block. An empty one, and the newly defined.

The empty one - specification (argument list, its types etc)
The newly defined - body of the function, what it does
^^ I think you understand this. What else you don't understand?
endo64
21:04@JLCyclo Didn't work when you click on Create pull request button?
Anyway, I made a PR on behalf of you, from your fork to base: https://github.com/red/community/pull/13
21:16@JLCyclo Nice script by the way
gltewalt
23:45If I feed it to itself it seems to step over all the code with step

JLCyclo
12:05@endo64 Thanks for the PR
12:09input "n(ext) | s(tep) | <enter>" at the prompt line runs 1 do/next command... (disadvantages: overall loops and functions)
endo64
20:58What would be nice is to put a word somewhere in the source code and it will stop there when the execution arrives there, something like breakpoints, for example,
print 1
print 2
stop  ;execution stops here
print 3

toomasv
06:03@nedzadarek You don't need body: back body in answer-func.
GiuseppeChillemi
07:04When I think about code exection I lack the knowledge about how the code is interpreted, in other words, the flowing of code from load phase (lexer?), biding, interpretation and execution.
A particular aspect raises interest to me: what happens on
f-name: func [][]
or
obj-name: make object! []

I imagine that at load phase the function/object is not created but only when the "execution pointer" reachs that part and interprets it. Maybe it is in some "meta form". But I going there with my imagination.

I guess it because when I have tried to have a function with dinamyc bodies choosed by select (args and code) the select works only at when the function is called for the first time but not all the subsequents.
rebolek
07:08
>> source: {f-name: func [][]}
== "f-name: func [][]"
>> data: load source
== [f-name: func [] []]
>> code: reduce data
== [func [][]]
>> length? data
== 4
>> length? code
== 1
GiuseppeChillemi
07:10Why has [func [][] ] length of one ?
rebolek
07:15In data you have four values: f-name: with type set-word!, func with type word! and two empty block!s. When you execute this code, it returns one value, function!. This one value is displayed as func[][] for lack of better representation, but that doesn't mean it's three values, it's just one.
GiuseppeChillemi
07:16And what has it become in RED internal structure ?
rebolek
07:17function!
GiuseppeChillemi
07:24So, after that, it is no more "data" but it is something else.
07:25What becomes "something else" after the first code run ? Objects and .. ?
07:25Or everything ?
rebolek
07:25It's still data, but evaluated.
GiuseppeChillemi
07:26But I can't work on it as in the original data form !
rebolek
07:26Well the data has changed, there's now just one value instead of four.
GiuseppeChillemi
07:27Do the same happen to everything ? Blocks ?
rebolek
07:28Unlike parens, blocks are not evaluated by default:
>> reduce [(1 + 2) [1 + 2]]
== [3 [1 + 2]]
GiuseppeChillemi
07:32Now it is clear what happens at code execution and why I can't have dynamic function bodies without SET/UNSET that function. The function is there as expression of language but it is created just after execution. So, once created looses its dynamicity. It is "one" instead of "four" and the structure can't be changed.
rebolek
07:39that's actually not true
07:39function can be changed
07:40
>> f: func [x][1 + x]
== func [x][1 + x]
>> f 1
== 2
>> change body-of :f 2
== [+ x]
>> f 1
== 3
GiuseppeChillemi
07:42Body but not arguments interface ?
07:42And also, when you you change the body, have you to REBIND and what ?
rebolek
07:43You can change function's spec same way, just use spec-of instead of body-of.
07:44However, just because it's possible doesn't mean you should do it. There are certainly more same way to achieve what you want.
07:44Whatever that may be.
GiuseppeChillemi
07:47Tou can't let a function autoselect bodies after it is created (a select * * in place of arguments and body won't work) but you can modify them and then invoke the function.
rebolek
07:47And why should function select a body?
GiuseppeChillemi
07:51I have tried to find a way to have one name (the function) and some derivates of it without using an object and sharing the args block. The original attempt hase been made using a select in place of body block and args block. The words for selection have been set just before the execution of the function and it worked only the first time.
rebolek
07:52why can't you have select in the function?
GiuseppeChillemi
07:55Have to go, be back in an our.
toomasv
08:34@rebolek You can change the spec but this will not affect the behaviour of func:
>> f: func [x][1 + x]
== func [x][1 + x]
>> f 1
== 2
>> insert spec-of :f 'y
== [x]
>> f 1
== 2
>> spec-of :f
== [y x]
>> insert body-of :f [y +]
== [1 + x]
>> body-of :f
== [y + 1 + x]
>> f 1 2
*** Script Error: y has no value
*** Where: +
*** Stack: f  
>> bind body-of :f :f
== [y + 1 + x]
>> f 1 2
*** Script Error: y has no value

rebolek
08:37I said it's not good idea :)
toomasv
08:38:smile:
rebolek
08:43You can create 𐌼𐍈𐌽𐍃𐍄𐌴𐍂𐍃 that way:
>> f: func [x][x + 1]
== func [x][x + 1]
>> insert spec-of :f 'x
== [x]
>> :f
== func [x x][x + 1]
toomasv
09:18@endo64 Something like this?
>> eval: func [code][until [do/next code 'code if code/1 = 'stop [return code] empty? code]]
== func [code][until [do/next code 'code if code/1 = 'stop [return code] empty? code]]
>> eval [print 1 print 2 stop print 3]
1
2
== [stop print 3]
>> eval [print 1 print 2 print 3]
1
2
3
== true
09:59Or better:
>> eval: func [code /until stop][
    system/words/until [
        do/next code 'code 
        case/all [
            find/match code stop [return code] 
            all [not until code/1 = 'stop][return code] 
            not value? code/1 [
                code: next code 
                if any [
                    find/match code stop 
                    all [not until code/1 = 'stop]
                ][return code]
            ]
        ] empty? code
    ]
]
== func [code /until stop][system/words/until [do/next code 'code case/all [find/match code stop [return code] all [not until code/1 = 'stop] [re...
>> eval [print 1 stop print 2 stop1 probe "here" print 3]
1
== [stop print 2 stop1 probe "here" print 3]
>> eval [print 1 stop1 print 2 stop probe "here" print 3]
1
2
== [stop probe "here" print 3]
>> eval/until [print 1 stop print 2 stop2 probe "here" print 3] 'stop2
1
2
== [stop2 probe "here" print 3]
>> eval/until [print 1 stop1 print 2 stop probe "here" print 3] [print 2]
1
== [print 2 stop probe "here" print 3]
>> eval/until [print 1 stop print 2 stop2 probe "here" print 3] [probe "here"]
1
2
== [probe "here" print 3]
>> eval [print 1 print 2 stop2 probe "here" print 3]
1
2
"here"
3
== true
nedzadarek
10:26@toomasv :+1:
10:32@rebolek
> function can be changed

But is this a **feature** or a **bug**?

@toomasv
> You can change the spec but this will not affect the behaviour of func:

Is this a bug?
toomasv
10:51@nedzadarek I think function changeability is great feature. Although I understand nothing about compilation theory, I vaguely guess real changeability of specwaits for JIT compilation. I may be completely wrong though.
JLCyclo
11:02Very interesting the discussion about functions, their spec and bodies...
toomasv
11:03One step further with stoppable eval -- added error trapping:
eval: func [code /until stop][
   if error? res: try [
      system/words/until [
         do/next code 'code 
         case/all [
            find/match code stop [return code] 
            all [not until code/1 = 'stop][return code] 
            not value? code/1 [
               code: next code 
               if any [find/match code stop all [not until code/1 = 'stop]][return code]
            ]
         ] empty? code
      ]
   ][error: reduce [code res] 'error]
]
>> eval [print 1 print 2 / 0 stop print 3]
1
== error
>> error
== [[print 2 / 0 stop print 3] make error! [
    code: 400
    type: 'math
    id: 'zero-divide
nedzadarek
11:27^^ Nice! There are some works on debugger(s).
@toomasv I see, thank you for the answer.
endo64
11:38@toomasv Yes something like that, thanks! I refered https://github.com/red/community/blob/master/tools/rdbstep.red project of @JLCyclo
simonmc_gitlab
13:46Hello! I'm trying to access a script header attribute. In Rebol you could use system/script/header/..., is there a similar way in Red? The header field is present in the system/script object but it's always set to none
rebolek
13:46Hi @simonmc_gitlab , this is not yet implemented in Red.
simonmc_gitlab
13:47@rebolek Ok, I see. Thank you for your fast answer!
rebolek
13:47You can load %script.red and access header manually.
13:49For example:
>> system/script/header: context second load %text-table.red
== make object! [
    Title: "Text Table"
    Author: "Boleslav Březovský"
(...)
simonmc_gitlab
13:53nice! Thank you!
rebolek
13:56You're welcome!
GiuseppeChillemi
14:39@toomasv as far I have understood, the only way to change a function is to UNSET and then SET again. Still have not tried but I suppose it works.
14:43@rebolek about the "MONSTERS" I see from your examples that we loose the link between the "inner" function code and the outer rapresentation. RED should REACT to specs or body change with a reinterpretaion of the function (updating it) so it could be coherent. I don't know which are the implications of this.
14:44Their are ... how could I say... "not aligned".
14:44It is somehow a dangerous situation.
14:46The appearence of the code does not reflect itself.
rebolek
14:48Can you describe why you want to change the function? I believe there's much simpler way.
GiuseppeChillemi
14:49@rebolek As now, I am only learing how much RED could change itself and how.
15:03@rebolek it all started when I tried some code like this:

specs: [two [value1 value2] three [value1 value2 value3]
bodies: [two [value1 + value2] three [value1 + value2 + value3] 
sum: function select specs f-version select bodies f-version
f-version: 'two
sum 10 20
f-version: 'three
sum 30 5 42


My wish was to have a function that could be have variable arity and different code upon selecting which "version" of the function I want to execute.
rebolek
15:07Then make a functor that would return such function. I'm on phone now, but I can post the code later. It's trivial anyway.
GiuseppeChillemi
15:11Functor ?!? What is it ?
nedzadarek
15:15@GiuseppeChillemi arity:
1) if you have for example few options, let's say you can take only 2 or 3 arguments then use refinements. Make 2-arity function a basic thing and 3rd argument as refinement's argument:
f: func [ a b ; 2 arguments
     /third 
   c ; third argument
][
  reduce [a b c]
]
f "1st arg" "2nd arg"
; == ["1st arg" "2nd arg" none]
f/third "1st arg" "2nd arg" "3rd arg"
; == ["1st arg" "2nd arg" "3rd arg"]

or
15:18if you don't know how many arguments you will take just take some container (e.g. block):
sum: func [bl /local current-sum] [current-sum: 0 foreach el bl [current-sum: current-sum + el]] 
sum [1 10 100] ; == 111
sum [4 20 100]  ; == 124
15:22As @rebolek said, it's easy:
select-sum: func [arg] [
  if arg = 'two [return func[a b] [a + b]] 
  if arg = 'three [return func [a b c] [a + b + c]]
  ; case instead of ifs:
  ;  case [
  ;  arg = 'two [return func[a b] [a + b]]
  ;  arg = 'three [return func [a b c] [a + b + c]]
  ; ]
]

sum: select-sum 'two ; == func [a b][a + b]
sum 2 3 ; == 5
sum: select-sum 'three ; == func [a b c][a + b + c]
sum 2 3 4 ; == 9
GiuseppeChillemi
15:25@nedzadarek They are all options we have discussed during the last weeks/months but I faced some versions of the specs block where less arguments where needed and a refinement could only ADD. This makes the whole block/refinements not as "fluent".
15:26I am distant from RED
nedzadarek
15:27@GiuseppeChillemi ah right... so I don't need to repeat myself.
GiuseppeChillemi
15:28It is this I want to avoid:

sum: select-sum 'two ; == func [a b][a + b]
sum 2 3 ; == 5


Having two lines to execute a funtion
15:30I would like:

sum 'two 2 3


And have the result

Actualy the best way I have found together with you is:

sum 'two [2 3]

15:30So we can have

sum 'four [2 5 7 1]
15:31and
nedzadarek
15:31@GiuseppeChillemi sum 'two [2 3] <- you don't need 'two. You can deduce it from the block-arg (e.g. length? [1 2]).
15:32And even you wanted to specify it... I would just use numbers (e.g. sum 2 [2 3] sum 3 [1 2 3])
GiuseppeChillemi
15:36I know this but the example wording let you think that you can have the number of arguments from the lenght but I have created 'on the fly'
We could have:

add 'db [specs]
add 'table [name rows]
add 'row [values]

When length? has no sense


nedzadarek
15:40btw. I got a question about locality in the function:
Are those the only things that are not local (not added to the end of /local refinement by the function - let's call it "local group" for simplicity):
- set arg1 1 where arg1 isn't added manually to the local group
- parse [a b] [copy arg2 word! set arg3 word!] where arg2 & arg3 aren't added manually to the local group
- added to the /extern
15:46@GiuseppeChillemi Yes, in those cases length? isn't sufficient.
btw. /refinements would work too:
add/db [spec]
add/table [name rows]
add/row/table [values] [name rows]

It would force you to change function's specification each time you want to add another "type".
rebolek
16:02@GiuseppeChillemi going with your DB specific dialect is the right way IMO.
GiuseppeChillemi
16:28@rebolek just learing. However I like the idea of dynamically selected bodies and specs
rebolek
16:46IMO it adds too much unnecessary overhead.
Rebol2Red
18:06
How can i remove just one element (in this case "b") from a series?

Say i have this data:
data: ["a" "b" "c" "d"]
After removing "b" somehow 
I want to get this result:
data: ["a" "c" "d"]
ne1uno
18:21remove "b" or second item?
18:22take at data 2 ;removes 2nd
Rebol2Red
19:05Well i want to remove only "b" from data but not with an index.
So i need something like ... find "b" ...
rebolek
19:05remove find data "b"
Rebol2Red
19:07Yep that's it. Thank you very much!
GiuseppeChillemi
20:13> IMO it adds too much unnecessary overhead.

I agree. Function wich are executed hundred of thousands of times per seconds could have a slowdown.
20:14But you add readability and flexibility. And the purpose of a language like RED is to be flexyble and readable.
nedzadarek
20:41@GiuseppeChillemi
> But you add **readability** and flexibility. And the purpose of a language like RED is to be flexyble and readable.

I don't think that when function can take different number of arguments then it will add to it's readability. my-weird-func is a function that could take different number of arguments:
my-weird-func 1 2
my-weird-func 1 2 3 4

are simple enough but what about this:
my-weird-func tux baz qux bar

is this my-weird-func tux baz qux bar or my-weird-func tux (baz qux bar) (qux is an op!) or my-weird-func (tux baz) (qux bar).

As you can see it's not readable. vid managed to make it nice. It's based manly on types and "tags" so when you see, for example, a pair! you know that's face's size.
GiuseppeChillemi
21:51
add 'db name 
add 'table name 
add 'row [values]
add 'field 'fieldname 'fieldtype

add 'shape 'line start end
add 'song name  interpreter


you can create small dialects using this kind of coding delegating cases to spec and body defined somewhere in a block
21:54
change 'block start-point values
change 'samplerate from-value to-value 'recode

21:56To me they seem very simple and coherent
21:56You have only to learn the dialect...
21:56Without having to deep learn block parsing.
21:56It a simple way to have dialects and one you manage FUNC and SELECT you are able to use them.
22:04However, with the available istructions, the most usable and flexible way to express thing is:

add 'something [parameters]


The last istruction would be

change 'samplerate [from-value to-value 'recode]

22:08Until adoption by the RED team of this GREAT MEGA IPER idea of simple dialecting using variable functions :-)
I'll build from [this:](https://gitter.im/red/help?at=5c715f939155d45d90604f0a)
nedzadarek
22:11@GiuseppeChillemi
> To me they seem very simple and coherent

Because they are small and isolated examples.
add 'row [values]
add 'field f: at field-names 4  f/field-type

Here I would assume that add takes 2 arguments. In the second example you are just returning (f/field-type). I wouldn't guessed that it was a 3rd argument to the add.
GiuseppeChillemi
22:12In fact the idea is for small domains of coding where no parse block complexity is needed
nedzadarek
22:15ps. of course you wouldn't use add and change for obvious reason. If it wouldn't destroy the red then it would confuse some people (especially change).
GiuseppeChillemi
22:22You are right, this let me think it would be good having the ability to add variations to a function to select its specs and body in a way like:

add/rows

But we already have refinement...

add :('rows) ?

I am just letting my imagination go
nedzadarek
22:30@GiuseppeChillemi refinements, as the name suggest are for this. Nothing stops you from using non-refinement argument (e.g. a in func [a /ref b][...]) as something different, depending on existence of a refinement (e.g. func [a /ref b] [either ref [return a * b] [return append a "!!!!!!!!"]. It might not be "nice".
However, I think separate DSL is better options:
text1: "foo"
color: red

view compose [
  base (color) (text1) 
  base (color)
]
; some code

rebolek
06:53@GiuseppeChillemi
> you can create small dialects

And that's exactly what you should do. Create dialects.
06:56Here's simple validator for your example, adding actions to it is piece of cake:
>> db-dialect: func [dialect][parse dialect [some ['add ['db word! | 'table word! | 'row block! | 'field word! word!]]]]
== func [dialect][parse dialect [some ['add ['db word! | 'table word! | 'row block! | 'field word! word!]]]]
>> db-dialect [
[    add db table
[    add table name
[    add row [values]
[    add field fieldname fieldtype
[    ]
== true
06:57It's MUCH easier than messing with self-modifying functions.
GiuseppeChillemi
09:00@rebolek I will work on it.
toomasv
09:04@GiuseppeChillemi @rebolek I cooked also something similar - very crude adhoc implementation of your dialect:
Red []
;@GiuseppeChillemi [February 26, 2019 11:51 PM](https://gitter.im/red/help?at=5c75b4d7d2d62067b7101b03)
assign: func [words values][collect [forall words [keep to-set-word words/1 keep values/(index? words)]]]
dbs: clear []
selection: clear []
dbquery: func [code /local s i j][
	parse code [
		some [
			'add [s: ;(probe s)
				'db (repend dbs [db-name: s/2 db: copy []])
			|	'table (
					repend db [
						tbl-name: s/2 table: copy/deep [spec: [] rows: []]
					]
				)
			|	'fields (append spec: second table s/2)
			|	'rows (
					append rows: fourth table s/2 
					new-line/all table/rows on
				)
			] skip
		|	'use [s: (spec: none)
				'db (db: select dbs s/2)
			|	'table (table: select db s/2)
			|	'spec (spec: table/spec)
			|	'row (row: pick table/rows s/2)
			] skip
		|	'select [s: (selection: clear [] fields: extract table/spec 2)
				'row integer! (append/only selection row: pick table/rows s/2)
			|	'rows [
					'where block! (
						foreach row table/rows [
							if all bind s/3 context assign fields row [
								append/only selection row
							]
						]
					)
				|	block! (
						parse s/2 [any [i: 
							integer! '- integer! (
								repeat j length? table/rows [
									if all [j >= i/1 j <= i/3][
										append/only selection table/rows/:j
									]
								]
							)
						|	integer! '- 'end (
								repeat j length? table/rows [
									if j >= i/1 [
										append/only selection table/rows/:j
									]
								]
							)
						|	integer! (append/only selection table/rows/(i/1))
						]]
					)
				]
			]
		]
	]
]

code: [
	add db redverse 
	add table persons
	add fields [
		alias [email!]		fname [string!]	lname [string!]
	]
	add rows [
		[@GiuseppeChillemi 	"Giuseppe" 		"Chillemi"]
		[@rebolek 			"Boleslav" 		"Březovský"]
		[@nedzadarek 		"Nedza" 		"Darek"]
		[@toomasv 			"Toomas" 		"Vooglaid"]
	]
]
dbquery code
dbquery [use table persons]
dbquery [select row 1] selection
;== [
;    [@GiuseppeChillemi "Giuseppe" "Chillemi"]
;]
dbquery [select rows [2 4]] selection
;== [
;    [@rebolek "Boleslav" "Březovský"] 
;    [@toomasv "Toomas" "Vooglaid"]
;]
dbquery [add rows [[@greggirwin "Gregg" "Irwin"][@gtewalt "Greg" "Tewalt"]]]
dbquery [select rows where [find/match fname "G"]] selection
;== [
;    [@GiuseppeChillemi "Giuseppe" "Chillemi"] 
;    [@greggirwin "Gregg" "Irwin"] 
;    [@gtewalt "Greg" "Tewalt"]
;]
GiuseppeChillemi
09:17@toomasv Fantastic ! I'll spend many nights with this RED girl !
toomasv
09:18:smile:
nedzadarek
09:31@toomasv @rebolek Good job!
@GiuseppeChillemi ^^ In my opinion, their codes are much better than separate functions you wanted to make.
GiuseppeChillemi
09:36@nedzadarek I also think so. The idea of having a function with multiple specs remains in my mind for further use but I will continue on parsing DSL.
nedzadarek
09:37:+1:
GiuseppeChillemi
22:05@toomasv

First evening with the RED girl: I am dissecting the RED girl to understand how she works.

assign: func [words values][collect [forall words [keep to-set-word words/1 keep values/(index? words)]]]

Lets probe the result of COLLECT

words: [first-word second-word]
values: [1 2]
probe collect [forall words [keep to-set-word words/1 keep values/(index? words)]]

>> red-lady.red
[first-word: 1 second-word: 2]


assign seems a function whose body is built at runtime. It seems it creates global values but I could be wrong. Also I think what will happen once it is run for the first time, will the body persit or it will be recreated at each run of assign ?
22:25Thinking.... have to dissect the full code to have the answer
nedzadarek
22:26@GiuseppeChillemi unless you specify /into refinement, every time you run collect it will create new block by calling make each time:
unless collected [collected: make block! 16]

(^^ from the collect source (?? collect))

GiuseppeChillemi
05:51@nedzadarek So I read the assign: function in a different way: it returns a block of set words (and does not modify itself)
05:55I often misread the console about the blocks returned and the code emitting it when there are one or more []
toomasv
09:26@GiuseppeChillemi assign just combines provided words and values into new block with words changed into set-words. This block can be further used as object spec or reduced to set values to given words. I made some changes to it so that a single value (e.g. none) can be initially given for all words. It is currently used only in selection of rows according to provided criteria. Also added some functionality. See examples in gist [dbquery](https://gist.github.com/toomasv/fc597f59e9c73ca6d0f8786aa20585a7)
nedzadarek
10:34@GiuseppeChillemi I sometimes check it by appending something to a block:
f: func [/local arr] [arr: [] ]
bl: f ; == []
append bl 1 ; == [1]
f ; == [1]

It won't cover most cases but I think it's a good start.

virtualAlan
01:43I've updated a few things: mycode4fun.co.uk/red-beginners-reference-guide - and also: http://www.mycode4fun.co.uk/red-apps - take a look - Regards, Alan.

ralfwenske
02:40I’m having so much fun playing with red again and having seen so much progress.
I am attempting to write a tiny slide show for a shop window display. It is working well so far. However after displaying images for a while it crashes due to memory loss.
I believe garbage collector is not yet complete - is memory loss in following app to be expected?
02:41
Red [Needs: View]
files: [%bg1.png %bg2.png %bg3.png] ; each 1920x1024
imgs: []
forall files [
  append imgs load files/1
]
forever [
  forall imgs [
    img: copy imgs/1 ; img: imgs/1 also looses memory
    view/no-wait [ image img ] wait 1 unview
  ]
] ; each loop about 8MB are lost --> eventually crashes
; Red 0.6.4 for macOS built 4-Mar-2019/8:37:14+10:00 commit #a3d9204
NjinN
02:52@ralfwenske I found that problem too. It seems can't use view/no-wait and waitat the same time. Maybe we should use the rate and on-time in view.
9214
04:18@ralfwenske bitmap objects allocated for image! values are not freed by GC (yet), so memory leak is expected.
toomasv
04:35@GiuseppeChillemi :point_up: [March 3, 2019 9:43 PM](https://gitter.im/red/red?at=5c7c2e47e1446a6ebe7895c6)
Comment out line until... and its closing bracket and you'll see the culprit.

Or replace until with loop to see how outblock changes.
05:14Hint: Check your set-words.
ralfwenske
06:35Thank you both. @NjinN I tried rate and on-time already: same result. @9214 that explains it.
GiuseppeChillemi
06:51@toomasv

The problem is: I test VA1 while I use VAL

The font I am using makes "1" and "l" quite identical.
toomasv
06:51Bingo!
ralfwenske
06:58@NjinN I eliminated all words and compacted the app more. It shows that memory leak happens in view (as @9214 had pointed out).
Red [Needs: View]
files: [[%bg1.png] [%bg2.png] [%bg3.png]] 
forall files [append files/1 load files/1/1]
forever [
  forall files [
    view/no-wait compose [ image (files/1/2)] wait 1 unview
  ]
]

(A tiny working slideshow - except for memory leak).
nedzadarek
07:04@ralfwenske I'm on the Windows so it may be different.
First, you don't need to copy images (img: copy imgs/1) - you are not editing them. I have done 2 & 10 loops with ~9MB files and I have gotten ~2 MB with copy. You run it forever and with some images bigger than mine... so it may lose more memory.
Secondly, view/no-wait [ image img ] might not cache results, so each time forever runs it might add some MB. I'm not sure if it's garbage collected. It's my **wild guess** so take it with a grain of salt.
07:04ps I've run it on: Red 0.6.4 for Windows built 19-Jan-2019/13:54:56+01:00 commit #4880ddb I'll try it on the newest build later.
ralfwenske
NjinN
07:38I try some code like forever [ view/no-wait [ ... ] wait 1 unview], except that it open only one GUI window , but it open some windows , and then quit. It only happens with view/no-wait and wait.
GiuseppeChillemi
09:11@toomasv

> Bingo!

It's Bingology !
toomasv
09:12:smile:
GiuseppeChillemi
09:22I have also learnt that SELF binding in server: [self/server-name 1]is mantained when used in the foreach loop. I thought that the elements of a block are not bound if you don't "insert/append" them and when defined this way they have an "empty" context . In other words I didn't think that I could be able to use SELF this way from an external function.
09:22@toomasv
09:58However, I still do not understand in which phase arised the SELF -> OBJECT binding in the word SELF inside the BLOCK. I thought that words inside blocks, when not "appended" already having a context, have an empty one. Now it seems different.
10:06(corrected)
ralfwenske
10:22@9214 Could it be that something else in view image ... is not right? I have run the app by displaying different image sizes (20% and 50%). The amount of memory eaten up has been reduced accordingly and is nowhere near exhausting my available memory. However what I found is that in any case the app crashes after exactly 12 forever iterations:
*** Runtime Error 1: access violation
*** at: 000C9F01h

the modified app
Red [Needs:	View]
files: [[%bg1.png] [%bg2.png] [%bg3.png]] 
forall files [append files/1 load files/1/1] count: 0
forever [ count: count + 1 print count
  forall files [
    view/no-wait compose [ image (files/1/2) (files/1/2/size / 5) ] wait 1 unview
  ]
]
hiiamboris
10:44@ralfwenske I have stable memory profile with your script on W7. No crashes or leaks.
10:45Red 0.6.4 for Windows built 30-Jan-2019/9:03:13+03:00 commit #25ef631
dsgeyser
9214
12:00@ralfwenske might be some bug in Quartz or macOS backend. Try to boil this down to the smallest possible example and write a short report in /bugs room. Also, check if turning off garbage collector (recycle/off) changes anything.
vazub
12:29Does to conversion support explicit endianness selection when converting from binary! to other types, especially integer!? So far, I am under impression, that the binary is treated as Big Endian by default with no means of switching to Little Endian. Is this the case at the moment?
rebolek
12:30@vazub You're right, there are no endianness options ATM.
PeterWAWood
13:04@vazub binary! is simply a list of bytes. It has no implicit endianness. It is the equivalent of an array of char in C.
rebolek
13:05@PeterWAWood the question was about to conversion, where endianness matter:
>> to integer! #{01020304}
== 16909060
PeterWAWood
13:07@rebolek Such a conversion makes no sense to me. Here is one reason:
>> to integer! #{0102030405060708}
== 16909060
rebolek
13:09I find it useful (also integer->binary). It might error on length > 4, that probably makes sense.
9214
13:15> no means of switching to Little Endian

Reversing binary! should suffice.
vazub
14:06Yes, reversing the binary! is exactly how I solve for it at the moment. However, I was wondering if a cleaner approach was supported.
nedzadarek
17:51Good morning. What do you think about [such mezzazine (function creator that makes most world local)](https://github.com/nedzadarek/function-all-local)?
17:53ps. Have I missed something? If you want something to add then create issue (so I can track it). Than you.
rebolek
17:54@nedzadarek I see any [['set | 'copy] keep word! skip
what about set to word! "gotcha!" #nowwhat
GiuseppeChillemi
20:43@toomasv Even SELF on self/server-name is not needed. Al the words inside the block are bound to the object. I hoped for this but I didn't expect this.
toomasv
21:07@GiuseppeChillemi Vivat Red!
GiuseppeChillemi
21:27Finally I had the path build from my function. I have appended each element to a string and the converted using "to-path" but I got the error
"path must start with a word"

Where am I wrong here ?

Red [
	purpose: {Test building an access path from its blocks}
	
	]

dbs: [servers
			[a-server-name 
				[
					[tables
						[
							a-table-name
								[
									[fields
										[a-field-name "NAME-OF-FIELD"
										]
									]
								]
							]
						]
					]
				]
			]


db-parts: context [
	base-path: "dbs"
	server-name: 'a-server-name
	table-name: 'a-table-name
	field-name: 'a-field-name
	server: [base-path "servers" server-name 1]
	table: [server "tables" table-name 1]
	field: [table "fields" field-name]
]

dp: function [word] [
	val: copy probe reduce db-parts/(word)

	until [
		probe "!!!!!!!!!! STARTING LOOP !!!!!!!!!!!"
		outblock: copy []
		probe "This is outblock PHASE-ONE"
		probe outblock
		foreach [value] val
		[
			probe "before either: value" probe value
			either probe ((type? value) = block!) [probe "on append outblock BLOCK" append outblock  probe reduce value] [probe "on append outblock other" append outblock  probe value] 
			probe "This is outblock PhASE-TWO"
			probe outblock
		]
		probe "after either" 
		val: copy outblock
		probe "this is VAL" probe val
		probe (find val block!) = none
		;probe not block? (find val block!) 
	]
	exit-path: copy ""
	forall outblock [
		append exit-path first outblock
		if (length? outblock) > 1 [append exit-path "/"]
		]
	probe to-path exit-path
]

probe reduce dp 'field

21:28
....
....
"this is VAL"
["dbs" "servers" a-server-name 1 "tables" a-table-name 1 "fields" a-field-name]
true
dbs/servers/a-server-name/1/tables/a-table-name/1/fields/a-field-name
*** Script Error: path must start with a word: dbs/servers/a-server-name/1/tables/a-table-name/1/fields/a-field-name
*** Where: reduce
*** Stack: probe 
>>
21:29

>> probe dbs/servers/a-server-name/1/tables/a-table-name/1/fields/a-field-name
"NAME-OF-FIELD"
== "NAME-OF-FIELD"


Works>
hiiamboris
21:40@GiuseppeChillemi dbs/servers/a-server-name/1/tables/a-table-name/1/fields/a-field-name is not a word
> Script Error: path must start with a word: dbs/servers/a-ser...
21:42https://github.com/red/red/wiki/[DOC]-Path!-notes this is for you, sir ☻

ralfwenske
00:14@9214 bug reported: :point_up: [March 5, 2019 10:03 AM](https://gitter.im/red/bugs?at=5c7dbcc047276019e9b805a6)
9214
05:23Thanks @ralfwenske.
GiuseppeChillemi
07:54@hiiamboris That document has very useful.
It confirms the something I have recently suspected:
1) Paths are blocks of elements
2) Visual rapresentation of RE(D|BOL) cound differ from the internal structure and not everything could be rapresented.

I have changed the last part of the script converting all string values to WORD values and removing the adding of "/"

{...}
	exit-path: copy []
	forall outblock [
		either (type? first outblock) = string! [append exit-path to-word first outblock] [append exit-path first outblock]
		]

07:54Now it works
07:56Point 2 is really important becouse you open to the fact that what you see is not what it is and the visual rapresentation of things could you led to misunderstanding or confusion on the inner RE(D|BOL) world.
07:58GOOD WORK RED team. You have documented things that have never been documented properly !
toomasv
07:58@GiuseppeChillemi (type? first outblock) = string! --> string? first outblock
GiuseppeChillemi
08:06Thanks @toomasv , this kind of expression is still not fully in my mind.
toomasv
08:13@GiuseppeChillemi You might also consider these variations:
exit-path: to-path copy []
forall outblock [
    append exit-path  either string? item: first outblock [to-word item] [item]
]
probe exit-path

Or
forall outblock [if string? outblock/1 [outblock/1: to-word outblock/1]]
probe exit-path: to-path outblock
GiuseppeChillemi
08:16Just a note from this experience:

from: help find

ARGUMENTS:
     series       [series! bitset! typeset! any-object! map! none!] 
     value        [any-type!]


Value, in my mind are like 1 'a-word "a-string" [a-block] . I have tried block! instead of a "value" and it works. It should be explained in some that you could search for a KIND of a VALUE and not only a VALUE.
08:18@toomasv Thanks, another expression of the power of this language.
toomasv
08:19@GiuseppeChillemi :smile: Red is very rich. Another:
parse outblock [some [s: change string! (to-word s/1) | skip]]
probe exit-path: to-path outblock
GiuseppeChillemi
08:23I am having mentalgasms. Stop now ! Nooo, don't stop ! Oh, yes, go on !
toomasv
08:28
exit-path: to-path copy []
parse outblock [collect into exit-path some [s: string! keep (to-word s/1) | keep (s/1) skip]]
probe exit-path

probe exit-path: to-path parse outblock [collect some [s: string! keep (to-word s/1) | keep (s/1) skip]]
08:49And recent lesson from @9214
probe exit-path: to-path collect [foreach s outblock [keep reduce skip [to-word s] 1 - make integer! string? s]]
nedzadarek
12:37@rebolek
> @nedzadarek I see any [['set | 'copy] keep word! skip
> what about set to word! "gotcha!" #nowwhat

I changed any to some and it seems to work. But I'm not sure why. I should investigate it. Thank you for this bug.
laturk
16:17I have a rebol 2 problem. I've made a nice data entry screen for a Postgresql database using VID. For some reason when I edit data in one field the data in that field copies to other fields corrupting them. What is causing this, and how can it be corrected?
9214
16:19https://github.com/red/red/wiki/[DOC]-Why-you-have-to-copy-series-values
laturk
16:51@9214 Thank you!
GiuseppeChillemi
20:00How do I play sounds in RED ?
nedzadarek
21:17@GiuseppeChillemi as fair I remember you have to do it on your own. Here is the [red/audio room](https://gitter.im/red/audio).

toomasv
04:22@GiuseppeChillemi on Win10 this makes a sound call "rundll32 user32.dll,MessageBeep"
NjinN
06:39@GiuseppeChillemi Red/System call the winmm.dll

laturk
06:20How can ; be used as a regular semi-colon instead of the beginning of a comment?
rebolek
06:21What do you mean by regular semicolon?
laturk
06:21I want it to print.
rebolek
06:21print ";"
laturk
06:23OK. Thanks.
Sunnypt
23:16Hello, I was looking at the Red parse, back in early 2018 - 'A DSL compiler' by Nenad - on the Red home page
- it worked fine Apr 6th 2018 and older, but newer and newest builds do not work - I just cant see why - looks like a 'parse' change. - Please help.
thank you Sunny.
hiiamboris
23:36what compiler? you have a link?
Sunnypt
23:51https://www.red-lang.org/search?updated-max=2017-03-26T20:22:00%2B02:00&max-results=7&start=18&by-date=false - it's the bit about macros - 'A DCL compiler'
23:53You need to scroll down a way to find it.
hiiamboris
23:57ah, basic... let me see..

Sunnypt
00:00yes, it worked fine early 2018 - but now it fails - I just do'nt know enough to work out why - I am guessing it's a 'parse' thing, but not sure.
hiiamboris
00:04it looks like a bug to me:
>> parse [LET] ['let]
== false

introduced between April 6 and April 12
00:08I see that @9214 already reported a regression https://github.com/red/red/issues/3029#issuecomment-436438710
Sunnypt
00:08if it is, please let them know - i dont know how to. thanks
00:10ah, ok thank you
hiiamboris
00:10@greggirwin you might wanna reopen that ticket
@Sunnypt you can workaround it for now by uppercasing every keyword of the parse rule I believe
00:11@Sunnypt thanks for getting our attention to it
Sunnypt
00:42thanks The workaround does not work
9214
06:48@Sunnypt try the other way around - use lowercase keywords.
do-basic [
    10 let A = "hi!"
    20 let N = 3
    30 print A
    40 let N = N - 1
    50 if N > 0 then goto 30
]
greggirwin
07:51Thanks All. @PeterWAWood beat me to reopening the ticket.

burque505
01:08Might I ask where would be a good place to post a fix for a script at [Short Red Code Examples](http://redprogramming.com/Short%20Red%20Code%20Examples.html)? The "Coin Flip" example does not work for me with v0.64 (64-bit). I have a modified version that does. Thanks!
9214
07:34@burque505 site's maintainer hasn't been active in a long while, so your fix is unlikely to be incorporated.
burque505
14:01@9214, thanks. Is there a good site for users to post working scripts?
9214
14:58https://github.com/red/community
burque505
16:03Thanks!
20:12Hello, I have the following code using Red/System that appears to property #import Autohotkey.dll. In using this DLL (whether from Autohotkey or not) it's frequently imperative to insert a delay after the code runs, or the command won't be executed. The simple script in AHK to run Notepad may illustrate this.<br>
AhkCom := ComObjCreate("AutoHotkey.Script")
AhkCom.ahktextdll("Run notepad.exe")
While AhkCom.ahkReady()
Sleep, 100
<br>The red-lang code I have so far is this:
Red/System []

#import 
	[
		"AutoHotkey.dll" cdecl 
		[
			Exec: "ahktextdll" [pointer! [integer!]]
		]
	]

Exec ["Run notepad.exe"]
<br>No delay is inserted, because I can't find any documentation on how to insert a delay in Red/System. the Red 'wait' command does not work. All help appreciated. Also greatly appreciated would be any examples of using #import for any non-Windows-OS DLLS, and any real-world examples of using the Visual Basic API as described [here at Visual Basic API](https://doc.red-lang.org/en/libred.html). Thanks in advance.
hiiamboris
20:23@burque505 the command is sleep (ms) https://github.com/red/red/blob/master/runtime/platform/win32.reds#L270
burque505
20:28@hiiamboris, thanks. Sorry about that code above. This formatting is still alien to me. I ran out of edits. I'll try again:
Red/System []

#import 
	[
		"AutoHotkey.dll" cdecl 
		[
			Exec: "ahktextdll" [pointer! [integer!]]
		]
	]

Exec ["Run notepad.exe"]

sleep (1000)

'sleep' threw an error.
GiuseppeChillemi
20:55Could a function know if it has been called recursively without passing any arguments or setting any refinement regarding this ?
hiiamboris
21:18@GiuseppeChillemi you can use a static counter inside your function
GiuseppeChillemi
21:26@hiiamboris avoiding reinitializing it if the counter is higher than zero.
21:27Yes, it is a solution.
21:27Thanks
hiiamboris
21:28☻ like this: f: context [d: 0 return func [n] [d: d + 1 if 1 < n [f n - 1] probe pick ["recursive" "flat"] d > 1 d: d - 1]]
>> f 3
"recursive"
"recursive"
"flat"
== 0
21:30or other way around, f: context [d: 0 return func [n] [d: also d do [d: d + 1 if 1 < n [f n - 1] probe pick ["recursive" "flat"] d > 1]]]
GiuseppeChillemi
21:30I have another question:
I wish to navigate in a foreach/forall loop blocks like in: 'a-block: [a b c [e d f] g] printing all letters, so reaching the [e d f] block it should go inside, print everithing and then go back to the upper level and continue.
21:31I see no simple solution to this, expecially a recursive one.
hiiamboris
21:31use parse's builtin recursion
GiuseppeChillemi
21:32Still don't know how to enter inside a block. Could you please make a simple example or point me to documentation ?
hiiamboris
21:32sure, on it... sec
21:37foreach-deep: function ['w b c] [parse b rule: [any [ahead block! into rule | b: skip (set w :b/1 do c)]]]
>> foreach-deep x [a b c [e d f] g] [probe x]
a
b
c
e
d
f
g
== true
21:38@burque505 c'mon man, can't you copy/paste these lines into your code or what:
#import ["kernel32.dll" stdcall [
	Sleep: "Sleep" [
				dwMilliseconds	[integer!]
	]
]]
GiuseppeChillemi
21:52@hiiamboris your first example is complex for me:

f: context [
	d: 0 
	return func [n] 
	[d: d + 1 
		if 1 < n [f n - 1] 
		probe pick ["recursive" "flat"] d > 1 d: d - 1
	]
]

So, lets go.

f: context [
	d: 0

Here you create a context and you initialize it.

return func [n]

I don't understand what you are doing here.
It seems you return a function but I to me RETURN is an istruction which get executed at object creation and I do not know who is RETURN returning the value too !
Also, func [n] to me need to be assigned to a word...

probe pick ["recursive" "flat"] d > 1 d: d - 1

I have already encountered this kind of expression, but I don't rememeber how it works.

21:55Maybe I should read it this way:

probe pick ["recursive" "flat"] d > 1 
d: d - 1

burque505
21:59Thanks, that fixed the "sleep" part of my code ... now for the dll call, which apparently did NOT work. @hiiamboris, you know red - I don't. That's why I posted asking for help. You helped, and thanks for that. But it is NOT intuitively clear from ANY of the documentation that
Sleep: "Sleep" [
				dwMilliseconds	[integer!]
]

also required the #import statement for kernel32.dll.
hiiamboris
21:59@GiuseppeChillemi yeah, I intentionally fill the examples with tricks.. ☻
return from inside a context block works as if it was inside a function that gets executed, so in effect you get f: bound to the function! value
pick accepts a logic value as index, true is the 1st one, false is the 2nd
22:00@burque505 it's in the link I gave you :)
22:02you can check MS docs for in what dll what func resides https://docs.microsoft.com/en-us/windows/desktop/api/synchapi/nf-synchapi-sleep
22:08@burque505 for AHK you should consult their documention, I have no idea about this stuff, but pretty sure from common sense that "ahktextdll" is not a valid function name
GiuseppeChillemi
22:35@hiiamboris , I'll tell you in italian language: "Disgraziato, mi stai facendo impazzire !!!"
22:36So, this is the reason for ☻
22:41As I have undestood:
The code inside the context is executed during context creation.
D is set to 0.
Then, the function is created, RETURN is executed and it binds the function to F . I don't know how this internally works, I am curious and want to learn. Could you explain me step by step ?

hiiamboris
22:47@GiuseppeChillemi well, compare:
>> g: does [print "G"]
>> h: does [return does [print "H"]] probe type? h  h: h       ;) return is not needed here really
function!
>> i: context [return does [print "I"]]
>> g h i
G
H
I
22:49the advantage of returning function from a context is that it's body is already bound to that context (that's why I can use the d word there)
or you can do it another way:
f: func [n] bind [
   d: d + 1 if 1 < n [f n - 1]
   probe pick ["recursive" "flat"] d > 1
   d: d - 1
] context [d: 0]
22:57> "Disgraziato, mi stai facendo impazzire !!!"

languages shape the way we think... so by using Red you can keep your wits intact! ☺
22:57if nothing else...
GiuseppeChillemi
22:59@hiiamboris , this is the most tricky part and am sure that it I will learn this everything on RED will be easier.

You are bindind the body of the function to the context where D: 0...

Question:
Why this ? Without BIND, to which context the body would be bound and which is the difference without using BIND ?
23:02Question:

Also on return func [n] [... I am now starting to understand that the function is BOUND to the context by the RETURN function as there should be some mechanism that binds its parameter to the context where RETURN is part.
hiiamboris
23:04no, it's bound at the time of context creation: context body binds body to itself
GiuseppeChillemi
23:07@hiiamboris context body ? Which line of your code are you referring to ?
hiiamboris
23:07
>> ? context
USAGE:
     CONTEXT spec

DESCRIPTION: 
     Makes a new object from an evaluated spec. 
     CONTEXT is a function! value.

ARGUMENTS:
     spec         [block!]

ok, context spec binds spec to a newly created context/object
GiuseppeChillemi
23:11Ok, I reformulate my question:

How:

f: func [n] bind [] context []


Is different from:

f: func [n] []
hiiamboris
23:22@GiuseppeChillemi here's a helper function for you (ctx?):
>> ctx?: function ['w] [print [w "is bound to" either (sw: system/words) = c: context? w ['system/words][pick words-of sw index? find/same values-of sw :c]]]
>> ctx? ctx?
ctx? is bound to system/words
>> context [set 'a self  x: context [set 'b self  y: context [set 'c self z: 1  ctx? x ctx? y ctx? z]]] ()
x is bound to a
y is bound to b
z is bound to c
23:23each context binds only those words of a block that were defined inside of it
bind does the same, so bind anything context [] does nothing, but bind something c: context [a: 1] will rebind a inside something to c
23:24haven't you studied the spoon bending script? ☻
GiuseppeChillemi
23:30@hiiamboris I did it but some parts are still obscure. RED code aspect does not help me understand the underlying structure.
As Now I have undestood that:

- Words an block could be bound to a context where words are defined
- Contexts have no name but I not sure if contexts are objects and so they have a name :)
- Visual aspect of FUNCTION [] [] Letit seems it is made of 3 parts but as I have learnt they are translated to 1 once encountered, I do not understand if the first (spec) block is bound to a context to or it is different.
hiiamboris
23:36> not sure if contexts are objects and so they have a name :)

in interpreter - no difference, in compiler - after a: context [..] you can't reassign a

> do not understand if the first (spec) block is bound to a context to or it is different

hmm... let's see...
>> f: func [new-word] []
== func [new-word][]
>> ctx? (first spec-of :f)
new-word is bound to system/words
23:37good questions man, by the way (:
GiuseppeChillemi
23:39@hiiamboris

> > not sure if contexts are objects and so they have a name :)
>
> in interpreter - no difference, in compiler - after a: context [..] you can't reassign a


Oh you took an argument which is very important to me:

Before continuing I have to ask: What is INTEPRETER mode and COMPILER mode.
When we execute a script from console we are in interpreter mode and when we compile and execute the code we are in compiler mode ?
hiiamboris
23:41put simply, yes
GiuseppeChillemi
23:42@hiiamboris So, there are scripts that could not be converted to executable ?
hiiamboris
23:46when you've a problem, you can enforce interpreted mode from a compiled script with -e option
23:46I'll have to leave you ;) sorry :city_sunset:
GiuseppeChillemi
23:46'from' or 'for' ?
23:47I have to go to sleep and I will have enough nightmare on this run.
23:47@hiiamboris thanks for you support. Each step here is unvaluable !

burque505
02:09@hiiamboris, "ahktextdll" is indeed a valid function name (as is "ahkReady"). The following code accomplishes in AHK what I am trying to do in red.
AhkCom := ComObjCreate("AutoHotkey.Script")
AhkCom.ahktextdll("Run notepad.exe")
While AhkCom.ahkReady()
Sleep, 100

Regarding the "common sense" aspect of AHK, many unkind words have been said about this :). Nonetheless, it does a bang-up job of automating many Windows functions. The function referenced takes a string (or series of strings) and executes the code as if it were run via AutoHotkey.exe from the command line. I want to get this working with red, and I am sure it can be done.
giesse
03:13@burque505 I don't know much about Windows, but if I'm not mistaken a COM object is an entirely different beast compared to a plain DLL. Perhaps that's why it's not working for you?
9214
07:43@burque505

> I was advised to use sleep (ms), but it throws an "undefined symbol" error.

I believe you were advised to copypaste the importing part in your code. Sleep is defined in Red runtime, and won't work from bare-bone Red/System.

Red/System []

#import [
    "kernel32.dll" stdcall [
        sleep: "Sleep" [
            dwMilliseconds [integer!]
        ]
    ]
]

print-line "Instantly"
sleep 5000
print "5 seconds later"


> I want to be able to execute AHK commands from red, and pass variables to red. I believe it to be possible.

I would highly advise to keep things simple and use call with various shell commands and environment variables... unless interaction with AHK library is the only way.

> but neither the demo nor any real-world examples of VBA/red interaction are to be found.

Original [blog post](https://www.red-lang.org/2017/03/062-libred-and-macros.html) about libRed provides a link to [all examples](https://github.com/red/red/tree/master/tests/libRed), so, perhaps you should look better.

> The reason I mention this is that AHK can create COM objects for which the VBA/AHK correspondence is very close, making it relatively easy to use COM from AHK. Easy from red? I have no clue.

Red/System linker does not support COM objects yet.
burque505
15:33@giesse, thank you for the comment about COM. The point is certainly valid. Unlike some other DLLs, however, AutoHotkey.dll has an entry point rendering it accessible via FFI (or DLLCall, or p/invoke, or whatever name suits). Below is an example from the AutoHotkey.dll docs, only slightly modified to reflect the presence of the DLL in the script folder, as an illustration of what I mean.
dllpath:=A_ScriptDir "\AutoHotkey.dll"
DllCall("LoadLibrary","Str",dllpath) ; Load the AutoHotkey module.
DllCall(dllpath "\ahktextdll","Str","MsgBox Hello World!","Str","","CDecl") ; start a new thread from file.
While DllCall(dllpath "\ahkReady")
  Sleep 100 ; wait for the thread to exit

The example also illustrates errors in my previous code that I have not yet solved. But I feel it is a syntax problem only. First, I used 'stdcall' instead of 'cdecl', which was probably enough to kill it right there. The library that @hiiamboris pointed me to will probably be an invaluable resource for further DLL calls. Once I am able to translate just one call from either AHK or p/invoke format to red, perhaps I will succeed. @9214, thanks as always for your comments.
Regards, burque505
9214
15:44@burque505 you can study [this](https://github.com/red/code/tree/master/Library) repository to get a better grasp of how to write library bindings. [Red/System specs](https://static.red-lang.org/red-system-specs.html) will also come handy.
nedzadarek
21:46view/draw question: Is there a way to scale things to some dimension (e.g 500x500)? For example I have image with 100x100 size and I want to scale it it to 500x500. At the moment I'm calculating it manually (scale- words):
img-x: 100 
img-y: 100 
base-x: 150  
base-y: 150
scale-x: base-x
scale-y: base-y
i: make image! to-pair reduce [img-x img-y] 
i/rgb: red 
scale-x: (to-float base-x ) / img-x
scale-y: (to-float base-y ) / img-y
view probe compose/deep [
    base blue focus all-over on-over [
        print event/offset
    ] (to-pair reduce [(base-x + 20) (base-y + 20)]) draw [
        scale (scale-x) (scale-y) 
        image i
    ]
]
hiiamboris
22:07
i: make image! reduce [100x100 red]
view [base blue 170x170 draw [image i 0x0 150x150]]
22:07only for an image though
nedzadarek
22:13@hiiamboris right: image <- thank you for this.

Rebol2Red
14:53How to read one byte or integer at a time from a file?
If i do a read or read/binary on a +/- 900 MB file i get:
*** Internal Error: not enough memory
*** Where: read
hiiamboris
15:00read/seek/part (slow if used by byte) or wait until Red 0.7
Rebol2Red
15:04@hiiamboris Thanks!
15:16@hiiamboris This works:
print read/seek/part [filename] 20 1 ; 20 is offset into file
hiiamboris
15:17:+1:
Rebol2Red
15:46@hiiamboris Offset is zero based! Maybe this is meant by source relative.in help read?
hiiamboris
15:49Maybe. To be honest I've no idea what "source relative" means (;
Rebol2Red
15:50Oh Oke. Really appreciate your help. Thanks again.
hiiamboris
15:51looks like the doc-string came from R3 btw
15:56Maybe it means if you read from a port, then seek is relative to port position, like /seek -10 will go back 10 chars before reading.
15:57But we don't have ports yet, so every time I read that doc-string, I'm like "what??"
burque505
19:27[![encoding-prob.GIF](https://files.gitter.im/red/help/xRl7/thumb/encoding-prob.gif)](https://files.gitter.im/red/help/xRl7/encoding-prob.GIF)
19:27Hi, I am getting closer in my quest to run AutoHotkey from red. I have the following code that at least passes an arg to AutoHotkey.dll. I am having what I believe to be an encoding problem, however. This is the code:
Red/System []

#import 
[
        "kernel32.dll" stdcall [
            Sleep: "Sleep" [
                dwMilliseconds    [integer!]
            ]
        ]
        ; New library to load

        "AutoHotkey.dll" cdecl [
			Exec: "ahktextdll" [
			    code             [c-string!]
		   ]
		]
]

str: "Msgbox, Hello World"

Exec str


print {Starting
}

sleep 2000


print "Ending"

AHK reports back with a message that I will try to show (it contains Chinese glyphs, which usually means a Unicode-related problem:

giesse
19:29do you know what encoding AHK is expecting? I'm shooting in the dark again here, but maybe it's expecting UTF-16 and Red generally uses UTF-8.
burque505
19:33@giesse, AHK generally runs with UTF-8 (and I use that). There is an ANSI 32-bit flavor I don't use. As I'm running this with Red/System, I _think_ the string I've passed to 'str' above should be of type c-string!. The code above won't compile unless I use cdecl instead of stdcall, and chokes if I try to pass 'code [string!]' instead of 'code [c-string!].
9214
19:38@burque505 try str: #u16 "Msgbox, Hello World". @giesse is probably correct about UTF-16, since Windows API uses it as internal encoding.
19:42Or maybe you should convert c-string! to UTF-8, but for that Red's runtime is needed.
hiiamboris
19:44UTF-8 and c-string! will have the same byte layout, no?
burque505
19:45Thanks to all of you! Nearly there! @9214's suggestion works. I now get the "Hello World" msgbox from AHK.
19:48I just need one more function call, to 'ahkReady', to make sure everything doesn't exit abruptly. Thank you all! Here's the code I need to finish translating now:
dllpath:=A_ScriptDir "\AutoHotkey.dll"
DllCall("LoadLibrary","Str",dllpath) ; Load the AutoHotkey module.
DllCall(dllpath "\ahktextdll","Str","MsgBox Hello World!","Str","","CDecl") ; start a new thread from file.
While DllCall(dllpath "\ahkReady")
  Sleep 100 ; wait for the thread to exit
endo64
20:11> Could a function know if it has been called recursively without passing any arguments or setting any refinement regarding this ?

@GiuseppeChillemi even though @hiiamboris 's examples are great and teaches about binding, here is an easier approach:
f: func [/local b] [
	b: [0]
	change b 1 + b/1
	print either 1 = probe first b ["initial"] ["inner"]
	if 1 = random 2 [f]
	change b b/1 - 1
]

>> f
1
initial
2
inner
3
inner
burque505
21:05Re: AutoHotkey. Success, thank you guys!
Red/System []

#import 
[
        "kernel32.dll" stdcall [
            Sleep: "Sleep" [
                dwMilliseconds    [integer!]
            ]
        ]
        ; New library to load

        "AutoHotkey.dll" cdecl [
			Exec: "ahktextdll" [
			    code             [c-string!]
		   ]
			Ready: "ahkReady" [ return: [logic!]
		   ]
		]
]

cmdstr: #u16 {
Gui, Add, Button, gClickMe, Click Me!
Gui, Add, Edit, w400 h400 +multi
Gui, show
return
Escape::
GuiClose:
ExitApp

ClickMe:
msgbox just an event handler 
return

}

;str: #u16 "Msgbox, Hello World"
; per @giesse, @9214, #u16 is required.
; THANKS!!!!!!!!!!!!!
Exec cmdstr

while [Ready] 
[
Sleep 100
]

print {Done}

I feel like a kid with a new toy, couldn't have done it without your help. Much appreciated.
Regards,
21:07[![forRED.GIF](https://files.gitter.im/red/help/c1h3/thumb/forRED.gif)](https://files.gitter.im/red/help/c1h3/forRED.GIF)
greggirwin
22:52Congratulations @burque505! Thanks to everyone for helping out.
burque505
22:59@greggirwin, thanks a lot. One of the main reasons I wanted to do this for hotstring and hotkey support. I'm now able to trigger hotkeys and hotstrings loaded via AutoHotkey.dll. Might I ask for some resources regarding incorporating View code and System code in the same script? What I'd like to do now as proof-of-concept is have a script with something like the basic-widgets sample code AND the code (via Red/System) to both run from the same script. I've tested the basic-widgets.red example and text replacement via hotstring works fine.
greggirwin
23:10We need a good sample written for that, showing how to use #system-global, routine, and more. The Red Wallet is probably the most complete example of a real app doing it, but we need something simpler, for learning purposes.

https://github.com/red/wallet/blob/master/wallet.red
23:13I don't know, offhand, if any of the examples in https://github.com/red/code/tree/master/Library integrate GUI elements.
hiiamboris
23:19A tiny yet related example https://gitlab.com/hiiamboris/red-alpha/blob/master/red-alpha.red
burque505
23:20@greggirwin, thanks for that. I'll have a look. @hiiamboris, thanks to you too, I'll check it out.
Regards, burque505
hiiamboris
23:28There was also this game about a goose that couldn't even fly straight. I added it to the showcase some time ago. It was using R/S for playing sound.

NjinN
01:27@hiiamboris What is showcase?
greggirwin
03:29https://github.com/red/code/tree/master/Showcase
03:30Though I don't see any erratic goose in there.
NjinN
03:30Same
GiuseppeChillemi
08:03@burque505 Keep us updated. Windows automation is a good topic. Maybe make some blog on it, publish on github and other users will be attracted on your project and RED as language to achive their goals.
hiiamboris
08:58https://github.com/red/red/wiki/[LINKS]-Projects-showcase-%28links-to-remember%29
08:58https://github.com/NjinN/Recode/tree/master/Red/flappyBird
NjinN
09:04The flappyBird.exe has a problem of picture flashing, and I don't know how to fix it.
hiiamboris
09:15Yeah, flashes sometimes. And the right corner is blinking constantly
09:21@NjinN using offsets is the problem. You can instead keep the faces where they are and offset the image inside the draw block.
NjinN
09:23@hiiamboris I will try it later.
greggirwin
20:02@burque505, I found my old send-keys dialect. It doesn't use AHK, and is Windows only, but still works on Win10.
20:02[send-keys.zip](https://files.gitter.im/red/help/GWji/send-keys.zip)
20:12It's old R2 code, not ported to Red.
burque505
21:14@greggirwin, thanks a lot! as soon as I get time I'm going to work on that and the code from the other recent links provided to me. I really appreciate it.
Regards,
burque505

schwarzbox
02:05Hello. I am continue to work with live coding environment. Make some improvements after last discussion.
![alt](https://raw.githubusercontent.com/schwarzbox/EmptyCore/master/screenshot/screenshot2.png)
[EmptyCore](https://github.com/schwarzbox/EmptyCore)
greggirwin
02:27Cool @schwarzbox! I'll try to make time to check it out.

You have do [ ... and do read a couple places. The former is redundant, as the contents of the block will just be evaluated normally. Your "invisible constants" comment makes me think you hope to hide those vars, but that's not the case. For the latter, you can just do do .
rcqls
05:44@schwarzbox :clap: . I guess you are developping it or macOS. I tested it on linux, everything does not work yet but it looks great. It could inspire my next debugging on Red/GTK.
schwarzbox
07:56@rcqls Thank you. I understand right, that in future this problems gone? And I can run same code in Linux without problem?
rcqls
07:59@schwarzbox It is the goal indeed! It is already not so far… Livecoding already mostly works (as in the example in code and community repos). There is some issue with refreshing on panel and currently the tree is not working very well. The drawing zone works eventhough I did not test everything.
schwarzbox
08:05@greggirwin Useful thoughts. Thank you. I remove some "do" in auxiliary files. My "invisible constants" is just mark that user never have seen them in the Source editor. After your comment I move them to the main file.
NjinN
14:05@hiiamboris I have fixed the flashing problem, thank you.
hiiamboris
15:26:+1:
toomasv
17:41@greggirwin I ported your [send-keys](https://github.com/toomasv/send-keys). At least simple sending of letters seems to work. I haven't tried out other abilities yet. May-be you can show some examples of its usage (if it works of course). To get it working even so far was a major headache for me, as I am total newbe in RS :flushed: Great thanks to @NjinN and @9214 for their help!
[![send-keys.gif](https://toomasv.red/images/Tools/send-keys.gif)](https://toomasv.red/images/Tools/send-keys.gif)
Respectech
17:45@schwarzbox Very exciting!
hiiamboris
19:17Why do we have every actor accepting a face argument instead of referencing it by self? Can't actors object be rebound to the face?
19:23Or like this: view [base with [actors: object compose [face: (self) on-down: func [f e] [? face/type]]]]
endo64
19:29@hiiamboris Binding cost may be?
hiiamboris
19:32can it really justify the seeming redundancy?
pekr
19:40Part of the send-keys were utilities to position, move, bring to top windows. I have already used it with Red to change the name of the window :-)
endo64
19:42> can it really justify the seeming redundancy?

@dockimbel Can anwer that precisely.
9214
19:56@hiiamboris the thing is that you can't rebound object to another object.
nedzadarek
19:56@hiiamboris so without face as argument we have to rebound it on our own?
l: layout [b: base on-down [print 'down]]
b/actors/on-down: func [event] [print 'aaaaeee]

In the above case I had to bind body of the function to the b? Or is there going to be some kind of reactors that does it for me?
9214
20:00Another point is that one actor can be shared by multiple faces, and each one would need to bind actor's body to itself prior to call, which is almost the same as passing arguments on stack, but with one caveat: last face that bounded body won't be freed, since it is referenced by self in actor's body. Something tells me that because of that GC might be unable to reclaim entire virtual tree of faces.
20:03Also, self, as a keyword, exists as a backreference to the enclosing object, and can be instantiated only on object's creation (if I'm not mistaken). With your proposal you'll need something like bind object [self: ].
20:07With [face event] face word gets automagically bound to (any given) face at runtime, during actor's invocation. With just [event] you'll need to do that manually with actor's body, either ahead of time (provided that face already exists) or at runtime (but this is what Red already does for you, so why bother?).
hiiamboris
20:08> one actor can be shared by multiple faces

I thought so too at some point, that maybe actors are meant to be shared, but look:
>> view [style b: base on-created [probe same? b1/actors b2/actors] b1: b b2: b]
false
false
9214
20:12@hiiamboris I rather meant that one function can be used as a prototype for many actors (like in your example). But what if actor's body is already bound to some face? This (static) binding will persist as long as face exists, or until word is rebound to something else.
hiiamboris
20:15I am missing something? If we have actors (like in my example) as different objects, what's the problem of binding each one to a proper face?
9214
20:16actors is an object!, face is an object!, you can't bind one object! to another object!, it just doesn't make any sense.
20:17And body-of returns a fresh block copy, so binding it instead won't work either.
hiiamboris
20:20
>> a: object [x: 1 b: object [f: does [x]]]
>> a/b/f
== 1

Since this magic works, it's not a problem. We can bind actor bodies after actors object is created or smth like that.
20:21And I should clarify - what I find redundant is not that actors get a face argument for free, but that they have to use this face/facet thing every time instead of just facet, and this gets really ugly really fast.
9214
20:22> We can bind actor bodies after actors object is created or smth like that.

...

> And body-of **returns a fresh block copy**, so binding it instead won't work either.
hiiamboris
20:23But not body-of function.
20:26Recently mentioned on-change* limitation comes to mind as a valid explanation. Without face/.. part it probably won't work. Still, I'm not convinced.
20:33Found a way to hack it:
>> system/view/VID/styles/style1: [
  init: [attempt [
    foreach w words-of face/actors [bind body-of select face/actors w face]
  ]]
  template: [type: 'base size: 100x100]]
]
>> view [style1 on-created [probe type]]
base

Surprisingly it even detects facet changes and redraws.
9214
20:34With your approach you'll need to bind each actor's body on face creation - can be done semi-automatically, fine; that way event inside body will point to evaluation stack, and all other facet words will point to face. But then, if you wish to change actor after face is created, you'll need to do it manually. And how would you deal with global event handlers?
20:38Anyhow, sounds like too much overhead just to save a few keystrokes, and you already can do it by yourself if desired.
hiiamboris
20:39> global event handlers

Good argument. Ok, let's not bind global handlers, only those inside face's actors. Why not? It's not like exchanging actors between a face and system/view/handlers is a common practice.
9214
20:41@hiiamboris but then you either need two versions of actors (one with [face event] and another with just [event]) or stick with [face event] and, I don't know, pass something that is not a face as the first argument, just for the sake of it?
hiiamboris
20:42I believe the actor-calling code knows if it's calling a face/actors/something or system/view/handlers/something, no?
9214
20:42It boils down to closures vs. functions, basically.
nedzadarek
20:45> face/facet thing every time instead of just facet, and this gets really ugly really fast.

so you would use set facet instead?
9214
20:46And you can create closures manually (like above) on demand, simply ignoring face argument.
hiiamboris
20:46I rarely call actors from other actors, so even [face event] is okay for me, as long as actor body is bound to that face. Then using face would've been unnecessary from inside the actor, but face would still be here for convenience and if one wants to get the face object itself.
20:47@nedzadarek like this: view [style1 on-created [color: red]] Simple, no?
20:49I'm going to explore this approach more and see if there are any drawbacks to it.
9214
20:51@hiiamboris
view [
    base red "cool" 
        on-create [foreach f values-of face/actors [bind body-of :f face]] 
        on-down [
            print [words-of self]
            print [color text]
        ]
]
hiiamboris
9214
20:54Try to couple it with foreach-face and View's do.
hiiamboris
20:55I will, thanks.
nedzadarek
21:03@hiiamboris very interesting :+1:
ps. it doesn't seems to work with all cases - I don't set color:
view [style1 on-down [color: reduce random/only [red blue]]] ; doesn't work - color is none
view [style1 green on-down [color: reduce random/only [red blue]]] ; work - color is set to some value
9214
21:11@hiiamboris
view [
    base on-down [color: get random/only [red green blue]]
    base red "cool" 
        on-down [
            print [words-of self]
            print [color text]
        ]

    f: field [probe text probe parent/pane/2/text]
    button "click me" [probe text probe f/data]

    do [
        foreach-face self [
            attempt [foreach _ values-of face/actors [bind body-of :_ face]]
        ]
    ]
]
hiiamboris
21:18@nedzadarek it's transparent, on-down isn't triggered
21:20@9214 I wonder if I can leverage system/view/vid/GUI-rules/processors
9214
21:22*shrug*, GUI-rules is most likely related to OS metrics.
21:24Try to override face! somehow, so that it always inserts a custom on-create?
nedzadarek
21:25@hiiamboris
> @nedzadarek it's transparent, on-down isn't triggered

It's weird... is it a bug or a feature?
greggirwin
21:44@toomasv Woohoo! Thanks for porting it. If Notepad isn't running, you get an error, just something to note in the repo.
*** Access Error: invalid UTF-8 encoding: #{B7205265}
*** Where: ctx422~get-wTitle
*** Stack: view do-events do-actor do-safe win-send-keys

I will work up some examples. The old zip file should have had some more things in it. Will start there.
22:00@hiiamboris @9214, great chat on the face/actoor topic. And @9214, *very* clever use of on-create. This is what Red is all about. :^)

The design is Rebol compatible, which we may decide is less important than other things, given that so many other VID/View aspects are different. But another thing to consider is where we put our code. In my larger Rebol apps, I almost always ended up moving logic out of the VID code and into funcs called from it, so you don't gain a lot by having an implicit self binding in that case. This is a general pattern, not a Rebol-specific one. The more tightly you couple code to the UI, the harder it makes a lot of other things.
hiiamboris
22:06Processors way:
do bind [
  processors: make processors [
    hack: function [r][
      foreach-face r [attempt [
        foreach x values-of face/actors [bind body-of :x face]
      ]]
    ]
  ]
  append general 'hack
] system/view/vid/GUI-rules

GiuseppeChillemi
22:12@greggirwin @toomasv @burque505 Are there any other automation methods on Windows that can be used with RED ? VBA and VBS could be used to archive this, is there any solution to use them ?
greggirwin
23:58@GiuseppeChillemi you'll end up with more dependencies in most cases, so the question is what benefit VBS/VBS bring. I like the straight API approach.

I can't post all the places I've used mine, done for clients, but some examples are install helpers apps and sys admin tools that require some interaction, which can be ghosted with it. Easy to configure too. For example, in a config file you have
;pairs of:  Window-title [string!]  keys-to-send [block!]
windows-and-keys: [
    "Assertion Failed:*" [ctrl #"i"]
]

And functions that be used with it.
close-alerts: has [hwnd] [
    foreach [title keys] prefs/windows-and-keys [
        if not zero? hwnd: win-shell/find-window-by-name-ex title [
            win-send-keys/to-window keys hwnd
            alert-closed
        ]
    ]
]

Another interesting thing I found, since installers came up recently, is part of the helper that was config driven, to run various installers.
installers: [
    msi [file %/d/temp/download/NUnit-2.5.3.9345.msi /quiet]
    install-shield [
        /quiet 
        file %"d:\temp\download\XXXX-setup.exe" 
        response-file %silent-install-script.iss
    ]
    bat [%test.bat]
]
23:59Nice hack @hiiamboris/ :^)

giesse
06:48@hiiamboris copying and rebinding all your code is very expensive in terms of memory usage. Not to mention what happens if a new version of Red adds a new facet and suddenly half the programs out there fail (because they were using it as a local variable).
hiiamboris
08:34@giesse local variable where? in a function? it's easily solved by a second bind
And how is binding memory expensive? I don't get it. I'm copying nothing.
08:57Red has this tempting system/view/VID/styles/window but I can't find a way to use it ):
rebolek
08:58You can't :)
hiiamboris
08:58Found one - view make-face 'window ☻ But I wanted it inside a view/layout...
08:59Damm...
rebolek
08:59it's special style , reserved for OS window, there's not much you can do with it.
08:59layou func specificaly check for window style, you can't have it in layout.
09:00That doesn't mean you can't write your own windowing system in Draw for example.
burque505
15:26@toomasv, thanks for that port of send-keys by @greggirwin.
15:43@pekr, I'd love to see examples of what you mentioned: >
Petr Krenzelok
@pekr
Mar 13 13:40
Part of the send-keys were utilities to position, move, bring to top windows. I have already used it with Red to change the name of the window :-)
Thanks!
burque505
toomasv
16:18@burque505 You are welcome!
burque505
16:26@hiiamboris, I just ran your red-alpha.red, nice! I just downloaded the first saturn-transparent.png I found (I guess I shouldn't be surprised there are so many of them). Thanks.
hiiamboris
16:55it's in the repo actually :) not important though
giesse
18:59@hiiamboris bind modifies the block, so, if you have 10 faces with the same actor, you need 10 copies of that block each bound to each face.
burque505
19:44[![pad-bug.GIF](https://files.gitter.im/red/help/Ihdu/thumb/pad-bug.gif)](https://files.gitter.im/red/help/Ihdu/pad-bug.GIF)
19:44Is this a bug? If I pad a string and then pad/left it, all is well. If I pad/left it first, all is not well :)
19:58Using Autohotkey.dll and red to automate MS-Word - simple example [here](https://gist.github.com/burque505/b1df40a200727e8aaf1cf4b66627a827)
hiiamboris
20:03@giesse I believe have these copies anyway, just putting them to some use :)
9214
20:07@burque505 study pad's docstring and source code (? pad and source pad). Specifically, note that pad's second argument is a desired length of resulting string, and that length of both resulting strings in your example is 20, which is a maximum of 10 and 20.
toomasv
20:44@burque505 Nice! It works. But some remarks: In my case your AHK example compiled but MsgBox reported error. It worked without error if I compiled it without #u16 before both strings. Then MsgBox worked as expected but Word object was not created if I strictly followed instuctions on MsgBox. But if I first clicked "OK", then Word object was opened with message, and only then Alt-Esc should be pressed. It wasn't clear for me at once in which order to do these things. According to instructions I thought Alt-Esc will open Word and close MsgBox/AHK.

Thanks for the example!
burque505
21:20@toomasv, thanks for catching that. Might I ask what Windows version you're using, and whether you used Autohotkey.dll 64-bit or 32-bit? I'll try to make the Msgbox instructions clearer.
21:22@9214, got it! Thanks for clearing that up.

toomasv
05:43@burque505 I use 64-bit W10 Pro with 32-bit AutoHotkey.dll from AHK catalog Win32a, which I put in Windows/SysWOW64 catalog.
endo64
06:58You can't use 64bit dlls in Red yet, as Red is 32bit executable.
burque505
12:56@toomasv, thanks a lot. I'm using 64-bit Win7 Pro, but my AutoHotkey.dll is Win64U. By the way, in general I'd advise using the Unicode version of AutoHotkey.dll, either 32-bit or 64-bit, for general compatibility with many existing scripts. I'm going to try my code with the 32-bit Ansi version, based on your experiences, to see if that occasions the need to remove #u16. Best regards, burque505
toomasv
13:09@burque505 With Win32w/AutoHotkey.dll it needs #u16.
ne1uno
14:30windows may be translating dll name, unlikely you can link 64bit dll from 32bit app
burque505
16:07I'm not positive what's happening, but on my system I can compile using the 32-bit AutoHotkey dll, but I get Runtime Error 1: access violation at 10026D1h. Recompiling with the 64-bit AutoHotkey dll, it works again. AutoHotkey has a built-in variable that reports pointer size, A_PtrSize. For 32-bit of course this is 4, and for 64-bit it is 8. When running the red code in question - 64-bit dll - a Msgbox, %A_PtrSize% nonetheless reports a pointer size of 4. As a sanity check, if I run any of my other scripts where I use the AHK module, and query that variable, it's a pointer size of 8. So, it appears red is capable of loading my 64-bit dll, but not the 32-bit! But it's reporting a 32-bit pointer size back to red. This, however, only increases my confusion. @endo64, that issue gets reported in the AHK forums with some frequency, but it does in fact appear there is some degree of interoperability between 64-bit and 32-bit. My experience (including here) tends to bear that out. But @toomas reports using the Win32 version of the dll (both ANSI and Unicode) with success. Given the 32-bitness of both red and the dll, that makes perfect sense. What doesn't make sense to me is why I'm getting the access violation with the 32-bit dll.
endo64
21:57@burque505 You access violation issue might not related to 32/64 bit, does it crash during the DLL load or happens when calling a function after loading it?
Here MS says (https://docs.microsoft.com/en-us/windows/desktop/winprog64/process-interoperability) On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL). Additionally, a 32-bit process cannot load a 64-bit DLL.
And also https://stackoverflow.com/questions/15396897/using-a-64bit-dll-in-a-32bit-application
So the weird part is Recompiling with the 64-bit AutoHotkey dll, it works again. are you sure your DLL is 64bit?
burque505
23:28[dumpbin-headers.txt](https://files.gitter.im/red/help/0u1t/dumpbin-headers.txt)
23:28@endo64, I've seen those links before. It's 64 bit: FILE HEADER VALUES 8664 machine (x64)
dumpbin /headers output attached.

GiuseppeChillemi
12:15REBOL question: do you confirm that the best way to start a REBOL script which is independent from the current one is to use CALL in VIEW.EXE with arguments or is there another way ?
(I need to make Scheduler.r from both Greg and Doc independent from VID Extension Kit as Scheduler seems to crash using it (have not tried VID itself)).
hiiamboris
12:22there's async-call.r script
GiuseppeChillemi
15:36I whish to READ emails in RED and REBOL, I need a POP port 110 connection for both. On REBOL have tried with:

mail: read pop://user_name:pass@mail.mysite.com
probe length? mail


But I get an error on authentication.

How could I do on both language ? Also, could both access POP3/SSL or IMAP/SSL Mails ?

greggirwin
16:16@GiuseppeChillemi with changes to protocols over time, R2's support has had issues. Graham Chiu did a lot of work on ESMTP support, and Gabriele did IMAP work for Qtask/Prolific. If POP won't auth, not sure there's much you can do without deep digging.
GiuseppeChillemi
17:24@greggirwin
1) Are Gabriele and Graham works avaliable online ?
2) Is there a way to read emails in RED ?
burque505
18:29@endo64, it appears I have a 32-bit AutoHotkey.dll in SysWOW64, and a 64-bit AutoHotkey.dll in System32. That explains everything: the pointer size, the recompiling, et cetera. Apparently red looks in the path first, and finds the proper dll in SysWOW64. Sorry, much ado about nothing.
Regards, burque505
Oldes
21:06@GiuseppeChillemi Graham's work is here: https://github.com/gchiu/Rebol3/tree/master/protocols
endo64
21:43@burque505 At least a mystery solved :)
GiuseppeChillemi
21:45@Oldes Being used to ASYNC-PROTOCOL I have not read ACALL. So I have found this on the web about async one: [async differences](https://s3-ap-southeast-1.amazonaws.com/antonrolls/rebol/doc/ASYNC-The-available-implementations.txt)
endo64
21:45@GiuseppeChillemi Gabriele ( @giesse ) is also online here on gitter from time to time, you can reach him here.

> Is there a way to read emails in RED ?

As we do not have ports in Red yet, you cannot read emails in Red.
21:51You can also see the details about the error by trace/net on if you are on R2.
Most of the servers refuses R2 to connect them as R2 uses unsafe SSL version.
GiuseppeChillemi
22:51@endo64 what a terrible news ! This is the reason why I hate to use closed source software.
Actually there is no way to automate one of the most importan functions I use for work.
nedzadarek
22:52@burque505 I read it somewhere (citation needed) that Windows 64 bit store 64x bit stuffs in the System32 and 32x bit stuffs in the SysWOW64.
endo64
22:53@GiuseppeChillemi I agree, you need to use call to curl on R2.
22:53@nedzadarek That is correct.
nedzadarek
22:56More info [here](https://www.howtogeek.com/326509/whats-the-difference-between-the-system32-and-syswow64-folders-in-windows/).

ne1uno
18:43view compose/deep [rich-text 600x300 draw [text 10x10 (rtd-layout [red "hello to the " green "world, but" blue " why does text wrap?"])]]
hiiamboris
18:59@ne1uno workaround is to set the size of the newly created rtd-layout to none (unlimited width) or to your 600x300
ne1uno
19:07@hiiamboris thanks. it worked
burque505
20:12@nedzadarek, thanks.
GiuseppeChillemi
22:17@hiiamboris I have finally managed the async-call.r script to work . Included examples have problems and hangs REBOL. Maybe 15 years are too many !
22:24I have only a problem:

do %async-call.r
cmd-port: 'a-port-name
set cmd-port  open call://
append system/ports/wait-list cmd-port
cmd-port/locals/on-input: func [port data][
    prin data
]
insert cmd-port "tracert www.rebol.com"


I get

** Script Error: Cannot use path on word! value
** Near: cmd-port/locals/on-input: func [port data] [
    prin data
]
insert


How could I express this path ? Maybe it is too late for me and I do not remember how to do.
22:25Also I think that the last line is not correct too
hiiamboris
22:51@GiuseppeChillemi ...wait-list GET cmd-port
22:52same for insert

GiuseppeChillemi
08:25
do %async-call.r
cmd-port: 'a-port-name
set cmd-port  open call://
append system/ports/wait-list get cmd-port
(cmd-port)/locals/on-input: func [port data][
    prin data
]
insert cmd-port "tracert www.rebol.com"


Thanks, also (cmd-port)\ did the remaining magic but I did not expect it to work as it being the first word.
08:28I remember trying to use parents in the first word in RED and not working but maybe I do not remember correctly
hiiamboris
08:36Yeah. Red doesn't support paren as first path item, and likely intentionally.
GiuseppeChillemi
08:43@hiiamboris
How would you express that line in RED ?
hiiamboris
08:51port: get cmd-port port/locals/on-input: ...is the easiest way
08:54or do bind [locals/on-input: ..] get cmd-port
GiuseppeChillemi
09:51I'm trying to imagine why in Red the syntax (word) as first elements of the path is not possible but I can't find an answer. It seems so handy
hiiamboris
10:11@9214 may be qualified to answer that
nedzadarek
10:21@hiiamboris you can use to-path to make such path:
>> to-path compose/only [(to-paren [a]) b c]
== (a)/b/c

However evaluation fails:
reduce to-path compose/only [(to-paren [a]) b c]
*** Script Error: path must start with a word: (a)/b/c

I'm not sure if this will be changed... but I don't find this problematic.
10:23ps. there were a conversation about (...)/... syntax but I haven't added it to the bookmarks. Maybe someone has the link?
toomasv
11:02@nedzadarek Such paths can be made for incremental path composition, e.g.
>> b: [[1 2 [b [0 c 42]]]]
== [[1 2 [b [0 c 42]]]]
>> path: append 'b/1 to-path compose/only [(to-paren [a]) b c]
== b/1/(a)/b/c
;path: append 'b/1 [(a) b c]
>> a: does [42 - 39]
== func [][42 - 39]
>> get path
== 42
meijeru
13:03Current analysis of such a form is as follows:
>> load "(a)/b/c"
== [(a) /b /c]

nedzadarek
14:34@toomasv I mean () at the first position (using to-path).
ps. yes, path! is almost like normal container so we can append, insert, change etc it.
toomasv
14:38@nedzadarek I understand, but what I meant was, that while you can generate pieces of path starting with parens, you can use these only as sub-paths inside fuller path somewhere after root element. Not as full path itself. You cannot even quote such "path".
rebolek
14:40Hm, there's even error for that:
*** Script Error: path must start with a word: (a)/b
*** Where: do
*** Stack:
nedzadarek
14:40@toomasv @rebolek
14:41Yes I see. I mentioned this
GiuseppeChillemi
18:53My question comes because I find really handy to express the first element as result of evaluation of parens and I am curious about the reason Red kept out such syntax.

nedzadarek
10:54@GiuseppeChillemi as no one have answered let me put my guesses:
- it's easier to parse/evaluate word/... than (something)/... (as in [here](https://gitter.im/red/help?at=5c8f972e6a3d2e230de4450a))
- in my opinion word/... is cleaner syntax
- as fair I know you can do this with intermediate word

ps. I remember talk about keeping () inside path (as a second or greater element) because get-word! is allowed



I want to write a simple application with non-ascii characters. Should I assume that it will run correctly with all maintained operation systems? I remember that on the Windows XP (not maintained) you had to install some sort CJK (Chinese, Japanese and Korean) language package to be able to type and display that characters. I have tried view [base 150x150 font-size 24 "ひらがな"] and it works on Win 8.1 (The Red 0.6.4, the MS word and the Firefox).
rcqls
13:42Please, what is the syntax in VID to activate password flag in a field?
rebolek
13:43I don't think it has been implemented already.
endo64
14:03@rebolek @rcqls It is supported but not via VID: view layout [fld: field do [fld/flags: 'password]]
Search for password in here https://www.red-lang.org/2018/12/064-simple-gc-and-pure-red-gui-console.html
rebolek
14:04@endo64 So I was wrong, that's good!
14:04It should be added to https://doc.red-lang.org/en/vid.html
endo64
14:05[![image.png](https://files.gitter.im/red/help/E3lf/thumb/image.png)](https://files.gitter.im/red/help/E3lf/image.png)
14:06Yes we should add it somewhere as a note, and if there is no already better to raise a ticket as well to not forget to add VID support.
14:13May be add also to https://doc.red-lang.org/en/view.html#_field
14:13I've added as a comment (don't know if it is visible to anyone or just the admins)
rebolek
14:13That makes more sense, as it's not in VID yet.
14:15@endo64 I can see the comment when I click on + sign.
rcqls
14:23@endo64 @rebolek Thanks! @rebolek I know it is implemented since I am in the way to implement it on linux… :smile:
rebolek
14:23great :)
GiuseppeChillemi
17:27@nedzadarek I have just used it in REBOL and believe me, it is cleaner and easier to use (root)/subpath/subpath than a more convoluted multi words code.
nedzadarek
17:37@GiuseppeChillemi I do not find (get-some foo baz)/ind-b/ind-b but:
1) I have not used this construct in the Rebol (or any other languages)
2) It is my opinion which you can agree or disagree.

How have you used it in the Rebol? This does not work:
arr: [b [c 42]]
arr/b/c
; == 42
('arr)
; == arr
('arr)/b/c
; == /c
GiuseppeChillemi
18:16@nedzadarek As Always, someone else opinion is to respect

Here is a piace of code:

init-port: does [
	cmd-port: 'a-port-name
	set cmd-port  open call://
	append system/ports/wait-list get cmd-port
	(cmd-port)/locals/on-input: func [port data][
	    prin data
	]
]


Here I have extracted the line I have used

(cmd-port)/locals/on-input

nedzadarek
20:53 @GiuseppeChillemi that line is parsed as 3 elements (you can check it by ?? init-port):(cmd-port) /locals /on-input: func [port data].
ps. /on-input: 'value is valid syntax for some reasons.
fergus4
23:12Any reason why the print does not show in console? I see the window scroll bar is getting shorter as if there is something in the buffer.
forever [wait 1 q2: query %play.red print q2]
9214
23:24@fergus4 at the moment console's output is not async, so forever [wait 1 ...] just buffers print output indefinitely. That is, everything will be printed out at once as soon as loop is finished (in your case that will never happen, since loop is infinite).
nedzadarek
23:29@9214 are there any plans for an "asynchronous way"?
9214
23:43@fergus4 to be precise, this affects only GUI console, AFAIK.

fergus4
00:21Thanks. How about timers in gui? How can I set up a query on a gui timer? Is it the same as rebol?
00:26Found an example...thanks.
view [
    canvas: base 200x200   white rate 1 
        on-time [canvas-tick]
]
endo64
08:19@fergus4 Yes it is same.
08:19[![image.png](https://files.gitter.im/red/help/j1at/thumb/image.png)](https://files.gitter.im/red/help/j1at/image.png)
08:20It will work on GUI console as well as it doesn't block the events.
dsgeyser
08:55@rebolek I want to play with your 'values' editor. How do I run it?
rebolek
08:56@dsgeyser
1) clone the repo
2) cdto it and run Red
3) do %values.red and then ve
08:59Then it's bit less intuitive :) I'm working on interactive help system, but that's not finished yet.
To load script, use :l followed by script name. Whitespaces and % sign is optional, so you can use :lscript.red, :l script.red or :l %script.red
dsgeyser
08:59@rebolek Many thanks. Quick reply! I see this as alternative to Smalltalk/Pharo environment. with constant feedback. (Possibilities are endless).
rebolek
08:59then you can use vsto **v**iew **s**tructure
09:00to see function, use vffunc-name
09:03see %led.r for list of all supported commands.
fergus4
13:48Any examples of dynamic gui stuff. Nothing fancy. Just some face size changes to window resizing. I know some have played with it but I can't find anything.
9214
13:50@toomasv :point_up:
nedzadarek
13:57@fergus4 around this message https://gitter.im/red/help?at=5bab9c4141177e0bc7ad6082
toomasv
14:02@fergus4 [Layout demo](https://gist.github.com/toomasv/295c92b28c024ae1e9e430397fa4ecd7)
fergus4
14:04Perfect! Thanks
toomasv
14:15@fergus4 Simpler:
view/flags [
    on-resizing [
        face/pane/1/size: face/size - 20x55 
        face/pane/2/offset/y: face/size/y - 35
    ] below box 100x100 gold button "Quit" [unview]
] 'resize
moliad
16:23are there any internal ways to convert/decode windows-1252 data into a Red string? I can't find any source code or online examples.
Phryxe
16:26Maybe this - https://gist.github.com/kermitaner/1d024d1e74e599fe876a3dbab8feebd5
fergus4
16:28@toomasv More Perfect!
9214
16:42@moliad isn't CP1252 an alias for [Latin1](https://github.com/red/red/blob/master/runtime/unicode.reds#L849)?
16:43> The windows 1252 codepage, also called Latin 1, is used by the windows operating system to display a number of latin based languages. This characterset mimics the ISO 8859-1 character set, except varies with the characters in positions in the range of 128-159.
rebolek
16:44@moliad see https://github.com/rebolek/red-tools/blob/f2e4cba2d2c2a19caa4b952054d1e88c1d6cdb01/http-tools.red#L379
moliad
16:46@rebolek so basically the first 256 codepoints of unicode are the same as latin1 (windows 1252)
16:47@9214 sometimes I've seen latin 1 as the name for ISO 8859-1
16:47people tend to get these mixed up so I don't use the more ambiguous latin-1 label
rebolek
16:50@moliad it's a hack to be able to load things like google.com, proper version would need conversion tables
moliad
16:54> like google.com

what do you mean?
9214
16:56Everything except 80h - 9Fh range maps directly to Unicode codepoints.
rebolek
17:23@moliad try read https://www.google.com and you will see.
moliad
18:18hmm is the error on the google side or is it in Red? I have seen, just this week, some utf-8 converted files which I get encoding errors in Red.
18:33@Phryxe used your code as a basis for load-1252 and it works.. thanks. will also look at suggestion of @9214 to see if they are equivalent.
rebolek
18:44@moliad it's nobody's fault. Red expects UTF-8 only and Google sends data in obsolete formats to save few bytes.
Oldes
19:23I expect that Google is using some _module_ which don't care about valid UTF-8. I consider it to be a Google's bug.
19:29In my case it is sending czech word "Otevři", which is not correctly encoded:
19:29[![image.png](https://files.gitter.im/red/help/wQ8O/thumb/image.png)](https://files.gitter.im/red/help/wQ8O/image.png)
19:30(in above screen is missing line: p: find x #{ED72E16E})
19:34Where are these days when Google's title page was less than 1024 bytes :-(
rebolek
19:41Oldes they are using Win-1250 I believe, that's why it's not valid UTF-8.
19:41or some other 8bit encoding, you can check the headers.
Oldes
19:42Interesting is, that when I read the page in browser and or Rebol3, I don't see this piece of code
19:43But maybe it's because Red is sending info to get page in czech while my system is set to be using english.
rebolek
19:43that's possible
GiuseppeChillemi
23:36 @hiiamboris
I have discovered native REBOL call has "/wait" parameter. It seems call is now partially async. You can run it but I don't know ho to interrogate if the calling program has ended.
23:39Also, it would be useful to quit a rebol script and not open the consolle in case of error but I do not why. Do you have a solution ?
23:45*if the called program has ended...
dander
23:58@Oldes @rebolek for me, the header lists the content as ISO-8859-1 (around 13k)

endo64
05:52@GiuseppeChillemi if you are call to rebol.exe with script argument, then you may give --no-window or --cgi parameters to not open a window. And if the called script is in your control you can cover the whole script with attempt so no error opens a console.
05:52* calling to. rebol.exe
05:53Sorry I'm on mobile
GiuseppeChillemi
05:55@endo64 Ah, OK. If the called script ha ATTEMPT then an error inside it won't open the consolle with the error
endo64
05:58Yes, unless the script file is loadable. If it is not loadable (syntax errors) then it might open a console. Just keep that in mind.
GiuseppeChillemi
06:06@endo64 With async-call I also had a strange issue. It takes a few seconds more to release the port. I do not know the reason.
endo64
06:58Sorry, I don't have much experience with async-call.
GiuseppeChillemi
08:42@endo64 Actually the only information I miss is whether "call" without wait is equivalent to async-call and so a fully developement of later rebol versions.
Oldes
08:57@dander looks that Google is serving content according _I don't know which_ rules.. check this:
08:58[![image.png](https://files.gitter.im/red/help/Ip91/thumb/image.png)](https://files.gitter.im/red/help/Ip91/image.png)
rebolek
08:59rules don't apply to them
Oldes
09:00I bet it must be content of the request header, but hard to say what is Red using.
rebolek
09:01that's not so hard, you can construct your own header
Oldes
09:16I was not able to find it how.
endo64
09:17@Oldes can you also test with /binary in Red, for me it is:
>> length? x: read/binary http://google.cz
== 40759
>> length? x: read http://google.cz
*** Access Error: invalid UTF-8 encoding: #{E7262333}
*** Where: read
*** Stack:

Oldes
09:18I was using it with /binary in Red as it is the only way how to get the result at this moment.
endo64
09:19Ah ok, so you got 13017 by using Rebol?
Oldes
09:19Yes.
rebolek
09:21@Oldes write/info link [method [headers] content], see https://github.com/rebolek/red-tools/blob/f2e4cba2d2c2a19caa4b952054d1e88c1d6cdb01/http-tools.red#L223
endo64
09:27@Oldes I saved both binary outputs to files and compared them, there are some scripts and HTML parts that is included in one (Red) but not included in the other (R2)
So it probably about the request headers as @rebolek mentioned.
Oldes
09:28That was me who mentioned it :-)
hiiamboris
09:28@GiuseppeChillemi async-call gives you the info on whether program has ended or not at any time, call to my knowledge doesn't
endo64
09:28@Oldes :)
rebolek
09:35@Oldes what headers are you sending in R3?
Oldes
09:39Will have to figure it out... @giesse made the R3's HTTP scheme years ago :-)
rebolek
09:40ok, you can check it with wireshark
Oldes
09:42
GET / HTTP/1.0^M
Accept: */*^M
Accept-Charset: utf-8^M
Host: www.google.cz^M
User-Agent: REBOL^M
09:43@rebolek you can check what is sending Red. I would say it has HTTP/1.1 and missing the Accept-Charset part.
rebolek
09:43when I use same headers, I got 13089 bytes
09:44and the winner is... User-Agent
Oldes
09:44I think Red should be always using Accept-Charset: utf-8 if not specified as it really needs it.
rebolek
09:45
>> length? third write/info/binary http://google.com [GET [] ""]
== 47536
>> length? third write/info/binary http://google.com [GET [User-Agent: "None-of-your-business"] ""]
== 13215
09:45You can use it, if you think Google cares about it... :P
09:46
>> to string! third write/info/binary http://google.com [GET [Accept-Charset: "utf-8"] ""]
*** Access Error: invalid UTF-8 encoding: #{ED6EE16D}
*** Where: to
*** Stack:
Oldes
09:47Hm... so the difference is as I said initially, they are using some stupid module which is adding the javascripts, which are not properly encoded.
rebolek
09:49the reason is they are Google and they don't give a sh*t about standards
Oldes
09:54I guess there is no chance to get valid string directly from Google... it just looks that Rebol does not care if the input is not valid UTF-8
09:56I wonder how browsers deal with such a scenario.
rebolek
09:57browsers are very fault-tolerant, there's probably some autodetection
Oldes
09:59[![image.png](https://files.gitter.im/red/help/9BH4/thumb/image.png)](https://files.gitter.im/red/help/9BH4/image.png)
PeterWAWood
09:59@Oldes I believe that browser will replace invalid utf-8 sequences with the Unicode Replacement character - 0xFFFD (utf-8 0xEF 0xBF 0xBD).
10:01I did suggest this to @dockimbel but he wasn't keen on this approach. (I can't remember his reasoning.)
Oldes
10:04@PeterWAWood But than you would see the question mark as it is in Rebol, no? Browsers must give some try and convert the character into valid UTF-8 character.
rebolek
10:05they probably check for UTF-8 validity and if it's not valid, they will try system codepage
Oldes
10:06The thing is, that the page from google is UTF-8 encoded, just there are pieces which are not.
10:08[![image.png](https://files.gitter.im/red/help/oJif/thumb/image.png)](https://files.gitter.im/red/help/oJif/image.png)
10:09828KB of *compressed* data transferred btw, when one load the title Google page :-(
10:23I take it back... looks like although google claims that result is UTF-8, even in the html header, it is not... at least for us who are not living in US/UK
10:25It is really piece of crap.. sad thing is, that this company is one of the technology leaders.
rebolek
11:05That's the reason, they're so big that don't have to care about standards.
11:10look at their Chrome abomination of browser, IE6 of this century
nedzadarek
11:58@Oldes google.pl is not simply search engine. As for today, you can "compose" simple music.

@rebolek a lot of things are huge and slow. I wonder how the Red will deal with *web-thingy stuffs* in the future (at 1.0 version).
rebolek
12:00@nedzadarek one thing is it's huge and slow (I don't remember claiming that), other thing is to ignore standards. If it says in header that it returns data in utf-8, it should return data in utf-8, not in mix of different encodings and it doesn't matter, if it's 1 kB or 1 GB of data
Oldes
12:00@nedzadarek I know.... but the todays music composition is another 5MB
12:02@rebolek the true situation is, that the html header says the content is utf-8, the http response is claiming, it is ISO-8859-1. At least in my current Rebol session.
rebolek
12:03so...what should I make of it?
Oldes
12:04I wonder how will Red handle it.. as more important is the http information.
rebolek
12:04it's utf-8859-1SO or what?
nedzadarek
12:04@rebolek about utf8: couldn't it be just a mistake?
rebolek
12:05@nedzadarek Google having mistake on its main page? I've noticed it ~year ago.
nedzadarek
12:05@rebolek ok... but have anyone send them a message (issue) or something?
Oldes
12:06@nedzadarek haha.... I'm really interested how you will find **them**.
rebolek
12:07it's probably like trying to shout in vacuum
nedzadarek
12:08@Oldes I don't know if they're using some sort of issue tracker or not.
12:09and 5MB isn't big.
Oldes
12:16I don't care about Google... I think that Red will have to deal with the returned Content-Type. Returning just binary is not a solution, because in my test, I get ISO-8859-1 for www.google.com and ISO-8859-2 for www.google.cz.
12:17 So if read url should be user friendly, it should convert the content into utf-8 if it wants to return string as a result.
rebolek
12:18then it would need to handle the code page conversion
Oldes
12:18Solution is using port, where header content would be available and one could convert it accordingly.
12:18But using port is not user friendly.
rebolek
12:19on Linux, it can be handled using iconv(), so it wouldn't add much to code size, not sure about macOS and Windows
hiiamboris
12:22isn't iconv a huge dependency?
Oldes
12:24Windows have [MultiByteToWideChar](https://docs.microsoft.com/en-us/windows/desktop/api/stringapiset/nf-stringapiset-multibytetowidechar)
hiiamboris
12:29..which only works with a single system-defined locale
GiuseppeChillemi
15:24@hiiamboris I have further investigated on CALL:
/info returns the process information object. There is an interesting "ID" and return code. Wondered whether ID could be used to query for process status but I do not know how to use it.
hiiamboris
15:28it's the PID
GiuseppeChillemi
15:28The other interesting option /show which let the called REBOL process open the rebol consolle.
15:29@hiiamboris do you think there is a wait to have informations about the running status from the program ID ?
hiiamboris
15:29In plain rebol? no idea... You can use it in WinAPI calls though or with taskkill command
GiuseppeChillemi
15:34I don't know why but I feel like there is some internal REBOL port to query for process status. I can't believe there is an async call withour a way to interrogate the process execution status.
Oldes
15:42What do you mean with _process status_? The process may be any application running. If you want to communicate with it, you must implement some communication protocol first.
GiuseppeChillemi
15:46@Oldes I mean basic status: running/not running/ended
Oldes
15:49Than it depends on current os... there is many info on this topic on net, like [this](https://askubuntu.com/questions/831513/how-to-see-detailed-information-about-a-given-pid) on Linux, or [this](https://jpsoft.com/help/tasklist.htm) on Windows.
GiuseppeChillemi
15:54@Oldes Hoping native call had this feature as it let yous start an async call. Wondering if it is an hidden one.
Oldes
15:55I don't think there is anything hidden. And I even don't know about which Rebol version you are talking btw. :)
GiuseppeChillemi
16:01R2 View 2.7.8.3.1
dsgeyser
16:01@rebolek I tried to run ' values' in red gui console as per your instruction. Seeing following: [2J[1;0H... and on second line: [1m[36mtack
16:02etc... Not making sense. What am I doung wrong?
rebolek
16:04@dsgeyser oh. GUI console doesn't support ANSI sequences. I've yet to add support for GUI console's colors (but that probably would require console plugins, that are not available yet).
dsgeyser
16:05Oh ok. In what console should I run 'values' then?
16:08Recent Defcon demo - couldn't follow on screen, because of lighting.
rebolek
16:25@dsgeyser it's tested on Linux. IIRC there is support for ANSI sequences on latest Windows version, let me find it...
16:26It should work on macOS too, but I haven't tried it yet.
16:27https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
Oldes
16:30ANSI sequence should be working in Red CLI console version on Windows
nedzadarek
16:36@Oldes can you show some examples?
Oldes
16:39[![image.png](https://files.gitter.im/red/help/1Kzw/thumb/image.png)](https://files.gitter.im/red/help/1Kzw/image.png)
16:39The colors are not exactly correct, but it is working somehow.
nedzadarek
16:40print "^[[1;33mHello^[[0m"
rebolek
16:40What exciting times live we in! Microsoft finally supports 70s technology!
nedzadarek
16:41@Oldes I thought we have to use ^(...) syntax, thank you.
dsgeyser
16:42Forgot how to get into Red CLI console. ....
16:43Never used it.
nedzadarek
16:43@dsgeyser red.exe --cli
Oldes
16:43Actually it does not have anything to do with Microsoft, it is emulated... here is the source: https://github.com/red/red/blob/master/runtime/platform/win32-ansi.reds
16:44But as I say... it is not perfect... but as there was no interest from Nenad's side and no support in GUI version, I halted it where it is.
nedzadarek
16:45@Oldes do we really need it? I mean you can make better and cleaner job inside the gui.
Oldes
16:46It should be enough to run what @rebolek is using... for example this clears the screen:
print "^[[2J"
rebolek
16:46@Oldes if you look at the article I posted, it should be supported natively by Windows now.
Oldes
16:47I know the documentation.. but you should know that it works only on Windows10
16:47And you must first set up the console properly.
16:51@nedzadarek yes... I believe it is needed.... you may not like the syntax, but is industry standard for many years and you may see that even Windows now support it natively.
16:52And at least the cursor positioning was supported also in old R2
rebolek
16:52@Oldes IIRC the reasoning was that it should be implemented as console plugin...once we get them.
16:53It makes sense, if it would be plugin that would be shipped natively, it could work as nice learning example also.
dsgeyser
16:58Same output in Red CLI console as in Red GUI console. Windows why why why... -(
nedzadarek
16:58@Oldes syntax aside (we can build simple DSL for it) does industry needs OS' consoles when you have gui consoles? As fair I know, a gui console is supported on Windows and MacOs, not sure about Linux (with the Wine it might work but I don't have a Linux).
rebolek
16:59It doesn'ŧ work with Wine.
17:01I haven't tried it on GTK build yet, but TBH GUI console still needs work to be as usable as urxvt, iterm2, or something similar.
nedzadarek
17:10@rebolek Yes it needs some work but I have seen it in an action (e.g. live coding). So it shows potentials.
rebolek
17:14It definitely has potential, but it has bugs (autoscrolling) also. I've extended it to have inbuild editor and it was really easy to do.
hiiamboris
17:14can't you run CLI console from mintty (Cygwin)?
nedzadarek
17:17@rebolek editor? That what I was missing from other repls (multiline pasting/editing).
rebolek
17:20@nedzadarek yes, it was an experiment with very early version of GUI console, it probably won't run with current version, but it was easy to do and worked well. Once we get console plugins I may to reimplement it. It was nothing fancy but good enough for editing snippets.
nedzadarek
17:21@rebolek :+1: Well, then I will be waiting for it.
rebolek
17:23It will be part of Values anyway. Even if it's value-oriented editor, it would need some classic mode for text editing for documentation and other text-oriented stuff.
nedzadarek
17:25@rebolek the Values?
rebolek
17:26Values, my editor that started this ANSI sequences conversation.
17:32https://asciinema.org/a/3P7uwSV4E4rxFWinh8obwj1uW
nedzadarek
17:42@rebolek looks like Vim. Will it have a mouse support?
rebolek
17:44@nedzadarek the editor core is dialect-driven, so multiple front-ends can be implemented. I work on Linux mainly, so console based UI was obvious choice.
nedzadarek
17:46@rebolek I see. I might try to implement some front-end then. Well, thank you for the information.
rebolek
17:47The dialect based editor makes it very very very easy to implement things like macros and replay.
nedzadarek
17:50Well, then, I'll wait till console plugins.
rebolek
17:52@nedzadarek if you want to implement mouse-based front-end, I would be very glad! It just would be mouse and keyboard that would generate the dialect, that's certainly possible and it's something I would like to implement anyway (but not a priority for me).
nedzadarek
18:01@rebolek I guess generating your dialect based on some mouse/keyboard events won't be hard but detecting events and build whole gui might be problematic for me. I'm not an expert on this (gui) topic.
moliad
19:42@Oldes @rebolek Rebol2 has become obsolete for anything related to google. it doens't support the http redirections required by google because its ssl layer is not able to handle the minimal encryption required by all google services.
19:44so I'm not surprised if the actual page you got from Rebol isn't the actual search page but some other alternate page which tells you to upgrade your browser. I got this for many sites related near or far to google.
19:47@nedzadarek

> @Oldes do we really need it? I mean you can make better and cleaner job inside the gui.

the gui is highly intrusive while running other view code. I've had application just core dump when the gui console is live and run perfectly if using system console. it also seems to cause some interference with performance. my graph application is now 100% stable since I'm not using the gui console .
19:49@Phryxe btw, I was successful in using you windows1252 code (adapted it a bit) ... am now loading R2 code right in red yay :thumbsup:
GiuseppeChillemi
20:07I have 2 questions: it is possible to have an object/function inside a block ? Also, it is possible to have it defined without running a code than "insert/append" it to the block ?
20:10Another questiom:

a: [b c [d 1] e f]

a/b = c

a/c = [d 1]

Is there a path notation to have

a/c???d = 1 ?

Obviusly

a/c/d -> wrong


greggirwin
20:11Blocks are just containers. You can put anything in them. Then it's a question of evaluation.
20:12
>> a: [b c [d 1] e f]
== [b c [d 1] e f]
>> a/c/d
== 1

Works fine
rebolek
20:19@moliad I believe that's certainly possible, I haven't used R2 for web stuff for years, it's really outdated software.
GiuseppeChillemi
20:40@greggirwin maybe I have confused something. The terrible part is that I do not know where I have confused things.
20:40I have always used that path syntax but this evening I forgot about it !
20:43@greggirwin

> Blocks are just containers. You can put anything in them. Then it's a question of evaluation.

So, blocks defined inside main script code are evaluated at code loading and data inside block is evaulated under code request ?
greggirwin
21:11Blocks are only evaluated on request, e.g., by do or reduce.
nedzadarek
21:15@moliad
> I've had application just core dump when the gui console is live and run perfectly if using system console.

I don't understand this completely. What you mean by saying "core dump"?

> it also seems to cause some interference with performance.

That's the good point.

> my graph application is now 100% stable since I'm not using the gui console .

So gui-console would cause some minor or major performance loss? If it's some bigger loss then I would consider using cli before I compile one of my project.
21:20@GiuseppeChillemi so, you do not want to use append/insert/etc on a block, like: append [] func [] []? You still need to somehow change 3 values (length? [func [] [42]] ; 3) into one value. You can use reduce/compose (depending on your needs): compose [ (func [] [42]) ];
21:23ps. has [] & does [] are treated as 2 values when they are in a block.
21:25a/c/d -> works for me too.
21:30I wonder if we could somehow use #[] syntax for inserting function to a block (e.g. like this (not working obvioiusly): [#[func [] [42]]])
dander
21:38@nedzadarek you could maybe do it with a macro, but why do you want to do that instead of using the existing methods, like compose, reduce, insert? I think having a consistent behavior of blocks not having auto-evaluated contents is pretty desirable
GiuseppeChillemi
21:45@nedzadarek
a/c/d -> works for me too.

I am to tired. My mind has gone messy for a while.
nedzadarek
22:04@dander
> why do you want to do that instead of using the existing methods, like compose, reduce, insert?

Every methods has some "limitations".
- reduce -> you have to quote or put ' before a word, e.g reduce [quote (2 + 3) "is equal" (2 + 3)]
- compose -> you cannot use paren! (or escape it like in the above case)
- insert/append - makes code longer

> I think having a consistent behavior of blocks not having auto-evaluated contents is pretty desirable

Sometimes you want to change a block. You make a block just to change it next second.
And such thing like [ #[something to evaluate] ] would not change the behaviour too much.
Like string interpolation in the Ruby:
name = "Ada"
puts "Hello, #{name}!"

You see #[] - evaluate thing inside.

ps. I am not advocating on such change - I am just curious if it is possible with #[] syntax. There is planned some kind of *Template system* (there are no details available) and it is easy to roll your own e.g foo [ change-this [] 42].
dander
22:36@nedzadarek it is an interesting idea. I have struggled with properly composing things together, so I do see that there is an appeal for some situations. The thing I like about compose is that it signals a change in the normal behavior, so you know some manipulation will be occurring down inside the block, where it wouldn't otherwise. I'm not really familiar with macros enough to know how practical that would be, but it seems like a plausible use case perhaps.
Oldes
22:38@nedzadarek #[] is already used for _serialized form_. It is not yet fully implemented in Red, but for example in R3 it looks like:
>> x: mold/all next "ab"
== {#[string! "ab" 2]}
>> y: load x
== "b"
>> index? y
== 2
>> head y
== "ab"
22:43Also in R3 is reword function which works like:
>> name: "Ned"  reword "Hello $name" self
== "Hello Ned"
>> reword "Hello $name" [name: "Oldes"]
== "Hello Oldes"
22:45It is a mezzanine function, so may be ported to Red easily. (although it is quite complex function) And it is only for string/binary of course.
dander
22:51@Oldes That's interesting. It seems like it could be complicated figuring out where the word ends, or which word... maybe the longest word that matches?
Oldes
22:53
>> reword/escape "Hello XnameY" [name: "Oldes"] [#"X" #"Y"]
== "Hello Oldes"
22:54I'm not advocating for it. I never used it in real life. Just the Ruby example reminded it to me.
22:56
>> reword/escape "Hello #{name}" [name: "Oldes"] ["#{" "}"]
== "Hello Oldes"
hiiamboris
22:57Gregg has almost the same thing for strings already.
nedzadarek
23:52@dander
> it signals a change in the normal behavior, so you know some manipulation will be occurring down inside the block, where it wouldn't otherwise

that is why I like languages like the Red and Ruby - you can "make a syntax" without problems. So it could be interpolate [], interpolate[], i[], interpolate([])... etc.

@Oldes good info - thank you.

@hiiamboris

> Gregg has almost the same thing for strings already.

Yes. It was easy to make it look like Ruby's syntax (I don't have gist of it thought).

greggirwin
02:53https://gist.github.com/greggirwin/d40a0e3b4c8de31a7d3b82695b9b4b03
moliad
04:33@nedzadarek core dump is an old expression from my sgi years... hehe ... its a more advanced version of a segfaut, which dumps all kinds of status info on what caused the crash.
04:35wrt the evaluated block discussion... I might have some insight to add.
04:36in Rebol 2 I have a much more advanced version of compose which allows for compose to ignore SOME parens easily by adding a # in front... (the same syntax used for vectors in Red).
04:42my R&D team is working on various improvements to the concept of LIT data. we are doing some research on adding a COUNTER to the lit-word type so it can be lit more than once and each evaluation will remove one... so you could do this:
>> a: ''blah
>> b: a
>> ?? b
== 'a
>> blah: 666
>> reduce [ ''blah 'blah blah]
== ['blah blah 666]


04:44we are looking into adding a LIT-PAREN! type which would be a "dead" paren but which evolves to a normal, live paren when evaluated... this would allow us to store parens which are ignored through reduce and compose. something EXTREMELY useful in my experience with my improved compose function.
04:45(the lit counter would also be added to paren, so it could go through multiple compose or reduce transformations before finally being evaluated)
05:12@nedzadarek when using the gui console a lot (heavy tracing), in a view app, we quickly discovered that it leads to random crashes and some strange side-effects which I don't remember. so I just added the needs: 'view to the shell based console and my app seems faster while tracing and is 100% stable now.
giesse
06:50@nedzadarek evaluating on load is a terrible idea, then just using load on a configuration or data file would create a security vulnerability. The #[...] syntax is never meant to evaluate, only be a literal representation for any type to allow mold/all to work.
GiuseppeChillemi
08:36@moliad
> wrt the evaluated block discussion... I might have some insight to add.

Have you published it ?
08:37
my R&D team is working on various improvements to the concept of LIT data. we are doing some research on adding a COUNTER to the lit-word type so it can be lit more than once and each evaluation will remove one... so you could do this:

Also, I ask, will you publish it ?>
nedzadarek
10:13@moliad core dump - I see.
advanced compose - interesting addition
lit-paren -> nice
*heavy tracing* -> then I will keep it in mind
> adding a COUNTER to the lit-word type so it can be lit more than once and each evaluation will remove one

Sounds interesting. I want to learn more about this. What is the real world usage?

@giesse Right, I have forgotten about this aspect. Thank you for reminding me of this.
dockimbel
12:14@moliad Please open a ticket for that, and give us a simple way to reproduce it. We need to make the GUI console rock-solid.
moliad
13:33@GiuseppeChillemi yes We will propose all the lit data experiments as Red enhancements with examples of why/how to use them.
13:35@nedzadarek the lit word counter allows you to double the word evaluation delay when you build block datasets for further evaluaion (we will allow up to 4 to begin with).
13:39my team does a lot of PARSE compilers and we do our own custom dialects, remote networked processing services, all kinds of crazy S**t and lit-words and parens are the single most annoying aspect of that work.

we often know while building a dataset that it will be evaluated 2 or 3 times more before being the actual end-result (composed when building, then before xfer and again at destination, for example) .

currently, that work is very complex because we need to add a lot of extra code to track what should not be evaluated by the current call to compose (or reduce or whatever)
13:44@dockimbel I would really like to provide something like this but I have no clue what was causing the interference. its a pretty large app we're building (a node graph editor using draw extensively). the project is currently a bit on the side-burner while we work on another aspect of the project, but when we get back to it, I can promise I'll turn the gui console on again and try to find what part of the code is being interfered with.
One important improvement to Red has been the garbage collector, so new tests will most probably alter the previous observations.
greggirwin
18:19On a more advanced compose, years ago Ladislav wrote a function called build for just that purpose, and I've played with the idea for Red over time: https://gist.github.com/greggirwin/29836d25de0c68eaba0e6dbd268a20f5
hiiamboris
21:10Shouldn't pick support a datatype as its argument?
>> select [1 a "b"] word!
== "b"
>> find [1 a "b"] word!
== [a "b"]
>> pick [1 a "b"] word!
*** Script Error: pick does not allow datatype! for its index argument
*** Where: pick
*** Stack:

(I want the word item fetched)
9214
21:16@hiiamboris
>> first find [1 a "b"] word! 
== a
hiiamboris
21:24sure, although I need it as a single expression, so it becomes attempt [first find ...] (otherwise first none would error out on failure)
21:24and then you know how bad attempt is... you refactor something, forget that you renamed a word and go bug hunting :)
greggirwin
21:42Given the doc string of "Returns the series value at a given index. ", what does a datatype mean as an index? Though I'm also not clear on why some other types are included as index options.
9214
21:50@greggirwin https://github.com/red/red/issues/3665
greggirwin
23:05Ah yes! Thanks @9214 .

giesse
06:05@hiiamboris if you don't want to use attempt,

>> first any [find [1 a "b"] word! []]
== a
06:07though... there's a reason why this is not that simple as using something like pick. If you try to generalize the above, what should the following do?
>> first any [find [1 a "b"] none! []]
== none

06:08did it find it or not? maybe you don't care, but if you do, then you need to check the result of find.
06:10Of note, in Topaz:

>> first find [1 2 3] 1
== 1
>> first find [1 2 3] 2
== 2
>> first find [1 2 3] 3
== 3
>> first find [1 2 3] 4
== none
>> find [1 2 3] 4
== []


find returs the tail of the series when the value is not found, which does not lose generality and makes the above common case easier.
hiiamboris
09:38@giesse Yes, interesting idea with find returning tail... ☻ Not so elegant inside if condition expressions but has got it's advantages...
nedzadarek
15:39@hiiamboris such thing could work with python-like if.
giesse
18:48@hiiamboris in Topaz found? is defined as not tail? :) so, it's not a big deal in practice.

dsgeyser
07:38@rebolek What Linux flavor as you using to dev 'values' in ?
rebolek
07:46@dsgeyser I've got few Linux boxes and each runs different distro, I'm mostly using Manjaro and Ubuntu. But Values need console only right now, so any distro should be fine.

abdllhygt
18:07hey!
rebolek
18:08Hi @abdllhygt !
18:08What’s new?
abdllhygt
18:12I try to develop a subtitled stories platform. Now, developing story(text) to subtitled story(bootstrap/popovers) translator in Red.
18:12What about you?
rebolek
18:14Nothing so ambitious, just usual stuff. Improving my scripts.
18:14Do you have any new examples of your translator?
abdllhygt
18:15for results?
18:16i started new. but before i maked by hand. i want to make automatic by my Red script.
18:28![nyoku.com](https://media.giphy.com/media/8wfu3OHvvJmVdi6Upx/source.gif)
rebolek
18:35@abdllhygt this is in Red?
abdllhygt
18:39No, i wrote it by bootstrap css. Now i try to make a program by Red, for it automatic translate text to story(like this gif).
moliad
18:41how are you doing the actual translation?

abdllhygt
19:01
<a tabindex="0" class="btn btn-light" data-toggle="popover"
 data-trigger="focus" title=""
 data-content="<table>
      <tr><td><b>diğer</b></td><td>other</td></tr>
      <tr><td><b>oda</b></td><td>room</td></tr>
      <tr><td><b>+da</b></td><td>in/on/at</td></tr>
    </table>"
  data-original-title="at other room">
  diğer odada
</a>

i wrote by hand

GiuseppeChillemi
07:33Hi, having:

my-obj: context [
   f: func [an-arg] [
          B: 10
    ]
]


Is it possible to read the vaule of B from the outside ?
rebolek
07:46
>> my-obj: context [
[       f: func [an-arg] [
[              B: 10
[        ]
[    ]
== make object! [
    f: func [an-arg][B: 10]
]
>> my-obj/f "blabla"
== 10
>> b
== 10
nedzadarek
10:23@GiuseppeChillemi in your case b is not *local to the my-obj* so after you set it (call my-obj/f '...) it will be available outside my-obj (details omitted).
greggirwin
18:27@GiuseppeChillemi Red is very flexible in how you can control the visibility of values. As the others said, in this case you just didn't make it a local to the func, and the object itself doesn't localize values in funcs, though I'll show you how below, so b is set in the global context.
my-obj: context [
        b: none  ; this makes the object capture the non-local func word b
        f: func [an-arg] [
              B: 10
        ]
 ]
my-obj/f "catch me if you can!"
;== 10
b
;*** Script Error: b has no value
;*** Where: catch
;*** Stack:  
my-obj/b
;== 10
9214
18:36
text
>> o: object [f: func [a][b: 1]] ()
>> select body-of last body-of o 'b
== 1
greggirwin
18:36Too advanced. ;^)
toomasv
19:04
>> my-obj: context [f: func [an-arg][B: 10]] ()
>> x: body-of :my-obj/f x/B        ; select body-of :my-obj/f 'B
== 10
GiuseppeChillemi
19:18You are right, I was in hurry and I have written FUNC instead of FUNCTION
19:23
o: object [f: func [a][b: 1]] () <-------------------- ????
19:25I do not understand parens use
toomasv
19:26
>> o: object [f: func [a][b: 1]]
== make object! [         ; <------ Just to 
    f: func [a][b: 1]     ; <------ avoid 
]                         ; <------ this
GiuseppeChillemi
19:31@toomasv I think I have understood: the console returns the last evaluation so () returns nothing and console avoid printing anything.
toomasv
19:31@GiuseppeChillemi Yes. And with function it's the same. Any of
>> my-obj: context [f: function [an-arg][B: 10]] ()
>> select body-of last body-of my-obj 'b ; Positional; depends where `f`is defined (if there were more members)
== 10
>> x: body-of :my-obj/f x/B
== 10 
>> select body-of :my-obj/f 'b
== 10

GiuseppeChillemi
19:34
>> body-of my-obj 'b
== b
>> last body-of my-obj 'b
== b
>>

19:35I have been trying just it.
toomasv
19:35
>> body-of my-obj
== [f: func [an-arg /local B][B: 10]]
GiuseppeChillemi
19:36Umm....
toomasv
19:36In your case just the last single b is returned
GiuseppeChillemi
19:36I have made wrong word copy
19:36Yes, I just ack this fact
19:44This has been one of my greatest problem with REDBOL:

>> body-of my-obj
== [f: func [an-arg /local B][B: 10]]


I see 4 elements_
f:
func
[an-arg /local B]
[B: 10]
all surrounded from []

But now I know

>> length? body-of my-obj
== 2


Functions could be inside a block and the their visual aspect is the same of four different block elements.
I have always visually counted elements with the rules I have read in the rebol/core manual for blocks
19:54@greggirwin

I am now able to decode it, I am more skilled:

This is my proof: a modified version so in case of object modification I always get f

>> select body-of select body-of my-obj 'f 'b
== 10




19:54Thank you all !
19:56The only difficult thing was () because my mind started thinking to some kind of code injection into (). Instead it is a simple REPL trick !
19:56When you do know not about something you start "great"
toomasv
20:51@GiuseppeChillemi :+1: Bravissimo!
nedzadarek
21:03@GiuseppeChillemi of course @9214 solution assume that you only set b once. For example:
o: object [f: func [a][b: 1 b: "The answer"]]
select body-of last body-of o 'b
; == 1
select/last body-of last body-of o 'b
; == "The answer"

greggirwin
21:28We should start a fun REPL tricks wiki page, with () and @Respectech's >>: :none trick. :^)
hiiamboris
21:38what is >>: :none supposed to do?
Respectech
21:40If you paste example code in the REPL, the >> is ignored.
hiiamboris
21:40Ah! Great! ☻
GiuseppeChillemi
21:48@toomasv GRAZIE !
dander
22:40when working in a .red file, my favorite is re: does [do system/options/script]to make it easy to *re*load the script you are working on
hiiamboris
22:42@dander what is your use case for it?
Oldes
22:42@hiiamboris it re-run the script.
hiiamboris
22:43I mean why do you need to re-run the script from itself?
Oldes
22:43Because the script was modified:)
22:44I use this quite often: drc: does [do read-clipboard]
dander
22:44@hiiamboris I might want to experiment with a function, but I can't write it correctly the first time. VSCode will launch the current file in a new REPL window, but each time you do it, you lose any state you changed. Maybe I need to manipulate some of the sample inputs or whatever, but I don't want to have to restart the REPL each time. So after making some edits, I just run re and get the updated function definitions of anything I changed in the editor
22:45@Oldes Ooh, I'll have to remember that one :)
greggirwin
22:45Nice @dander. I have old clipboard shortcuts as well @Oldes. Do-clip, load-clip, read-clip. And cc to write to the clipboard.
dander
22:49Of course, what I *really* want is more like a smalltalk environment where I can edit the running state of things and save them back into the source files. Man, those would be great things to add with a plugin system, and assign to keyboard shortcuts.
hiiamboris
22:51And how is do read-clipboard better than ^V ?
dander
22:52one difference - it doesn't fill up your screen buffer with text
hiiamboris
22:53Right... Interesting tricks! ☻
Oldes
23:17and console's command history

greggirwin
00:19Another old trick I used in R2 was to manually add things to the console history when a script would start. Very handy for admin scripts. Red remembers past session commands, but it's not the same as having custom commands just an up-arrow away.
nedzadarek
01:15@Respectech
> If you paste example code in the REPL, the >> is ignored.

Sadly we have to manually comment output code. I have tried to make it automatic but the code is far from perfect (no multiline support). Example:
>> example-mode
; func [src][if any [
    find src "prin*" 
    find src "print*" 
...
  2 + 3
; 5
  print* 'foo
; foo
  print 'foo
foo
  "fff"
; "fff"
  {sdf
{    dsf
{    df
{    }
; {sdf^/dsf^/df^/}
17:37Can we detect changes on the gui-console-ctx/terminal/lines?
greggirwin
17:42No. Not in a reactive way.
17:43You could, of course, hack vprin et al in %core.red, but I wouldn't recommend that. What are you trying to accomplish?
nedzadarek
17:46@greggirwin I'm trying to delete (or insert ; to comment line) {/[ at the beginning of the like in the:
>> {
{    sdf
{    }

greggirwin
17:46Ah. May be possible with plugins in the future, but not today.
nedzadarek
17:47@greggirwin I see, thank you.

GiuseppeChillemi
14:01How could I write to disk a block of values (others blocks inside) and retrieve it with their original REDBOL format ?

toomasv
14:15@GiuseppeChillemi For simple things you can use write:
>> write %tmp.data [a b [c [1 2]]]
>> load %tmp.data
== [a b [c [1 2]]]

It doesn't preserve everything. You might need write/binary. I haven't used it, so can't advise here.
hiiamboris
14:32@GiuseppeChillemi save/all then load it back. See https://github.com/red/REP/issues/44 about the quirks of it.
GiuseppeChillemi
15:50@hiiamboris @toomasv
Thanks, actually I have simple needs and your is a good solution. I have tried and write/append cycle for each element of the block with a LOAD counterpart and it works to.
toomasv
16:33@hiiamboris Why save/all?
hiiamboris
16:55@toomasv
>> x: none
== none
>> type? x
== none!
>> save %1 x
>> x: load %1
== none
>> type? x
== word!
toomasv
17:06@hiiamboris So ? is not updated? (Or, may-be I have old help?)
hiiamboris
17:10@toomasv sorry I tend to speak Red instead of English sometimes ;)
The point is, save does not preserve value type (none! vs word! in my example).
17:11It's not implemented but save/all will also preserve blocks and strings head index in the future.
toomasv
17:12Ah, yes, in the future was the part I was afraid I have missed.
GiuseppeChillemi
17:15> It's not implemented but save/all will also preserve blocks and strings head index in the future.

it is needed to state saving, isn't it ?
hiiamboris
17:19It'll be a step in that direction ☻
GiuseppeChillemi
17:47Does anyone know if REBOL.ORG source is available ? I need some resource storing and search routines and to output the result on a web site where REBOL wiil be hosted.
greggirwin
19:24@dsunanda or @peterwawood may be able to speak to that. I don't remember if it was made available.
GiuseppeChillemi
21:08@greggirwin I rember there were a REBOL search engine too. It would be nice to have access to its code.

GiuseppeChillemi
16:26On REBOL:

I have written a function to convert strings inside a block to block of strings.
I don't undestand why should I use the second version of the function as append/only should be ok.

a-text: copy [{one} {two} {more words}]
	
	
	lines-to-block: func [the-arg] [
		out-block: copy []
		foreach [line] the-arg [
			append/only out-block line
		]
		out-block
	]
	
probe lines-to-block a-text

	
	lines-to-block2: func [the-arg] [
		out-block: copy []
		foreach [line] the-arg [
			temp-block: copy []
			append temp-block line
			append/only out-block temp-block
		]
		out-block
	]
	
probe lines-to-block2 a-text


["one" "two" "more words"]
[["one"] ["two"] ["more words"]]
>>


toomasv
17:42@GiuseppeChillemi line is just string. /only does not convert it into block. But /only keeps the block with line inside (temp-block) intact in second func. (PS You don't need to enclose line in brackets after foreach. Brackets are needed there in case you have several words.)
GiuseppeChillemi
18:08@toomasv Thanks, understood.
18:39Also I have another problem on REBOL: how to I start it with relaxed security ? If I lower it from the inside the script I have a security warning.
hiiamboris
19:52-s option
GiuseppeChillemi
22:39@hiiamboris I run the script double clicking on it, where should I set this option ?
hiiamboris
23:09google for methods to set file associations, there are at least 3 in Windows
23:09and use a batch with command rebol -s %*
virtualAlan
23:26I've updated some things here: http://www.mycode4fun.co.uk/red-beginners-reference-guide there's some more new stuff on the other pages of my site - please take a look.

greggirwin
23:44@virtualAlan, no need to cross post in groups. Just post in red/red when you have updates. Thanks.
virtualAlan
23:54@greggirwin yeah - apologies - had a connection problem - so double posted ....

greggirwin
01:08Not to worry Alan. :^)
dsunanda
06:52 @GiuseppeChillemi Does anyone know if REBOL.ORG source is available

Peter Wood and I probably have a copy of most of it. It was all written for a very old version of R2 Core - it is unlikely to run with quite a few changes in modern versions of Core - let alone Red.

The search engine is build on skimp.r - which is available in the rebol.org script library. That does not currently work in Red - but I think the changes needed are fairly minor (parse vs parse/all, red not having JOIN -- simply stuff like that).
06:53it is unlikely to run WITHOUT quite a few changes -- ie conversion will be a big issue.
GiuseppeChillemi
09:36@dsunanda I have tried to login into the library with my account. It does not seem to exist enymore.
09:39I will try to understand and use skimp before any other request.
dsunanda
09:59@GiuseppeChillemi I have tried to login into the library with my account

If my memory is right, inactive accounts are removed after a couple of years - you can probably rejoin with the same user name, or a new one.

Skimp.r also uses Peter Wood's make-word-list.r - this is the main resourse that splits a script (or mailing list post etc) into words that skimp can then index.

A more modern design might be to use make-word-list.r to find the words to index in a script, and then simply store the data in an SQLite database.
GiuseppeChillemi
10:31@dsunanda thanks for the clarifications.
nedzadarek
13:04I managed to implement multi-line support easy to copy/paste code from/to repl. The code is [here](https://github.com/nedzadarek/red-example-mode). Check it out and please give me your opinions.
GiuseppeChillemi
21:22so, a path reduces the selected element while all the other methods don't reduce it.

>> f: does [4]
== func [][4]
>> f
== 4
>> b: copy []
== []
>> insert b :f
== []
>> probe b
[func [][4]]
== [func [][4]]
>> probe b/1
4
== 4
>> first b
== func [][4]
>> pick b 1
== func [][4]
>>


Or there are other methods capable of this "magic" ?
gltewalt
21:46In your case it reduces because of does I think
21:49
>> z: [func [][4]]
== [func [] [4]]
>> z/1
== func

9214
21:58@gltewalt paths are active and will evaluate a stored function. pick and select, on the other hand, are passive.
>> foo: reduce ['a does ['b]]
== [a func []['b]]
>> foo/a
== b
>> foo/2
== b
>> select foo 'a
== func []['b]
>> pick foo 2
== func []['b]

This was discussed, like, 3 times in the past 2 months. Maybe it's time to add a note to path! datatype doc?
gltewalt
22:15Added
22:26Maybe it's time for the crow of judgement?
22:38![alt](https://i.imgur.com/pAWCEYH.jpg)
GiuseppeChillemi
22:45😁
22:48It is nice but.... I don't like it is unexpected and not homogenous access pattern. It is not consistent with the standard working and user could go really confused.
22:49That's my humble opinion.
22:50Just asking if there where other active way of accessing block elements.
22:50I repeat, I like it a lot, it is a great idea but I'd like something like...
gltewalt
22:51There’s probably a good reason that I don’t remember
GiuseppeChillemi
22:51(b/1) or something similar
hiiamboris
22:52@GiuseppeChillemi see :point_up: [February 28, 2019 11:53 PM](https://gitter.im/red/red?at=5c784a64e1446a6ebe5fe02b)
GiuseppeChillemi
22:56@hiiamboris I have read. Your observation has deeper arguments. We generally agree on the dangers of it but I like the working.
22:56It should implemented in some way
22:57Where you clearly express the intention of picking + evaluating
hiiamboris
23:02The problem is that there has to be consistency (with object words and just words). You can't change the block access semantics and not destroy the beauty of the rest of the language. If you can we'll all be in your debt ☺
nedzadarek
23:08@hiiamboris
> You can't change the block access semantics and not destroy the beauty of the rest of the language.

Why you cannot change it?
hiiamboris
23:10@nedzadarek I'm speaking for myself, alright ☻ Fork it and change if you will.
23:14@nedzadarek tried your script btw. Works for me. Best if you assign it to some hotkeys of the GUI console window though.
nedzadarek
23:15@hiiamboris You're forgetting about something. I'm not good at low-level Red.
Joking aside, block!, map! and object! are slightly different. For example block/key: 'something won't work with non-existent key. On the other hand map/key: 'something would work.
So I don't understand why it's not possible.

Hotkeys? I haven't tried it... yet. I have to look for it in the website. Nice idea - thank you.

giesse
01:58Why should blocks be an exception? Words are active everywhere else. That's why we have get-word! and get-path!.
01:59Don't write b/1, write :b/1 if you don't know the type of the first element and you are not intentionally trying to evaluate a function.

Get in the habit of always using a get-word! if unsure. It will save you from a ton of security vulnerabilities.
GiuseppeChillemi
07:57@giesse I have not read anywhere the concept of active/passive elements in a block. I have lived without knowing it for years because the usage pattern of blocks let you infer that all of its elements are passive and the accessors are get passive results too.
Things like this happen when there is a lack of documentation and you need to use the inference, or the prior knowledge mechanism.
I won't oppose having it, I like and I hate it at the same time but I think the latter for a different reason: it has not been documented and so mine and other knoledge has been built on the base of everything is passive in blocks until explicitly REDUCED.
08:03So lets go on adding it to the documentation.
Also, please invent a semantic to have the result of an active element used in a path as lock up element for the continuation of the path itself.

f: does ['a-word]
insert b :f
append tail b 5
probe b/1<a-word
5
>>

08:08Ok, I admit I do not know the exact thing to ask, but things will be brighter in the future and so I'll come back on it
08:08There are many combinations of working still battling in me.
hiiamboris
08:11☺ It's where the most of the fun lies
GiuseppeChillemi
08:13
f: does ['a-word]
insert b :f
insert tail b 'a-word
insert tail b 5
probe b/<1
5
>>


Ok, it's an idea: get the result of the X element of the block ad use it to continue the path.


08:15@hiiamboris
> ☺ It's where the most of the fun lies

Yes, it's funny for people like us.
nedzadarek
08:31@GiuseppeChillemi I think you should use [red/docs](https://gitter.im/red/docs) for suggesting changes in the documentation(s).
08:38@GiuseppeChillemi
> Also, please invent a semantic to have the result of an active element used in a path as lock up element for the continuation of the path itself.
> Ok, it's an idea: get the result of the X element of the block ad use it to continue the path.

I don't understand this. Could you rephrase it?
Maybe you mean something like this:
bl: [a 1 2 c 3 4]
; [a 1 2 c 3 4]
  bl/a
; 1
  bl/a/3: 1
; *** Script Error: path bl/a/3: is not valid for integer! type
; *** Where: set-path
; *** Stack:

which could be done by:
f: find bl 'a
; [a 1 2 c 3 4]
  f/3
; 2
  f/3: 22
; 22
  bl
; [a 1 22 c 3 4]
10:33@hiiamboris
> @nedzadarek tried your script btw. Works for me. Best if you assign it to some hotkeys of the GUI console window though.

By inspecting gui-console-ctx (with ?? so it's huge) I have found out that shortcuts are with menu elements. Do I have somehow add menu element(s) to the gui-console with shortcut? Or there is another way?
hiiamboris
10:36How about going from do bind [actors: make actors [on-key-down: func [f e] [if e/ctrl? [probe e/key]]]] system/view/screens/1/pane/-1?
nedzadarek
15:12@hiiamboris so system/view/screens/1/pane/-1is the gui-console object/context, right?
hiiamboris
15:13Correct (it's a face! precisely). Hidden in plain sight ☺
nedzadarek
15:17@hiiamboris indeed.
ps. I guess your code will override on-key-down (if present) of the console?
hiiamboris
15:29Yes.
draegtun
16:09@moliad - This LIT data is already present in the Ren/C branch of Rebol3. Might be worth your R&D team banging heads together with Hostfilefork :)
16:09
>> reduce [''blah 'blah blah (blah) '(blah) ''(blah)]
== ['blah blah 666 666 (blah) '(blah)
rebolek
16:22That's a very dangerous path thru dark forest that's always changing.
nd9600
16:47Should you be able to use operators that are defined inside an object, from outside the object?
like
h: context [
    m0: make op! :multiply
    m: 2 m0 3
]
2 h/m0 3 ; h/m0 does nothing, so this returns 3
h/m; == 6

I have to do
m1: h/m0
2 m1 3

for it to work
9214
16:51@nd9600 no, paths don't evaluate operators at the moment. https://github.com/red/red/issues/3482
nd9600
16:51ah, thanks a lot
16:56I suppose, because Red's homoiconic, there's no way of including an object inside another object without including the entire thing?
as in, you can't make a word!point to an object! with a pointer of some kind
I was wondering if it was possible to make a circular or doubly linked list
16:57
o1: context [
    next: none
    data: "a"
]
o2: context [
    next: none
    data: "b"
]
o1/next: o2
o2/next: o1
o1/next/next/data ; === "a"

actually, it does work, nevermind
9214
16:58https://www.youtube.com/watch?v=maO7h9PIKQk
>> block: [we need to go deeper!]
== [we need to go deeper!]
>> append/only insert/only block block block
== [[...] we need to go deeper! [...]]
>> first block
== [[...] we need to go deeper! [...]]
>> last block
== [[...] we need to go deeper! [...]]
>> block/1/7/1/7/1/7/1/7/1/7
== [[...] we need to go deeper! [...]]
17:02> I suppose, because Red's homoiconic, there's no way of including an object inside another object without including the entire thing?

I'm not sure why you think homoiconicity has anything to do with it. "Entire thing" is always a one value slot, which, in case of object!, already contains an implicit pointer to the bulk of data.
17:03> as in, you can't make a word! point to an object! with a pointer of some kind

You can, it's called *binding*.
giesse
18:28@GiuseppeChillemi this has been documented and discussed for at least two decades. I don't agree that that's the problem.
GiuseppeChillemi
19:13@giesse Think about a newcomer in REBOL, where in the CORE documentation is the chapter talking about paths ending on function evaluates it ? Also, I don't remember being there a chapter about binding of words inside blocks or inserting a function in them.
Newcomers have not been in the REDBOL for decades and we need to help them extending the documentation when we discover some topics have not been covered.
nd9600
21:43@9214 I think I got confused with homoiconicity because I thought it was allowed you to mold and then load something back into Red, and how a value molded is essentially the original thing with quotes around it, like load mold [1 2 3] == load "[1 2 3] == [1 2 3]", but molding o1 from earlier gives you
make object! [
next: make object! [
next: make object! [...]
data: "b"
]
data: "a"
]
instead, which I can't do` without an error.
21:47> > as in, you can't make a word! point to an object! with a pointer of some kind
>
> You can, it's called *binding*.

... I really need to write something up about binding, I always struggle to get my head around it enough to use bind properly, even after reading http://www.rebol.com/docs/words/wbind.html a lot - https://github.com/nd9600/framework/blob/master/base/helpers.r#L98 is an _ok_ usage, I think, but https://github.com/nd9600/framework/blob/072e57d7302ce6fd92ca03c48bac6dbf1942eaed/base/helpers.r#L91 was terrible and really didn't work.
I guess I thought if I wanted to pass a pointer (e.g. to a big object!) from one function to another, it would be allocating loads of space for some reason? Seems quite silly now, really :)
nedzadarek
23:33@nd9600
> it would be allocating loads of space for some reason?

no big change
stats
; 2899396
  arr: repeat i 1000000 [append [] i]
; [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27...
  stats
; 54078300
  f: func [g arr] [g arr] g: func [arr] [arr/42]
; func [arr][arr/42]
  f :g arr
; 42
  stats
; 54167332

9214
08:07> I thought it was allowed you to mold and then load something back into Red

This is called serialization (mold) and deserialization (load), not homoiconicity. Homoiconicity is a property such that the primary representation of programs is also a data structure which program can manipulate, in case of Red it's a concrete syntax tree (i.e. a block of nested blocks and other values).

> which I can't do without an error.

Because of ... which mold uses to indicate cyclic structure. Once you load it back, ... is just a word with no value. Serializing cyclic structures can get messy pretty quickly, I'm not sure it's even possible in Rebol without some kind of extra table and funky construction syntax.

> I guess I thought if I wanted to pass a pointer (e.g. to a big object!) from one function to another, it would be allocating loads of space for some reason?

How's that? You seems to be confused about how data is represented internally in Red.
Oldes
08:26@nedzadarek I don't know what is your chat about, but when I see you last message, I must say, that you *should* preallocate the block like:
>> stats
== 2508908
>> arr: make block! n: 1000000 repeat i n [append arr i]
== [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ...
>> stats
== 18556280
08:26Notice that the memory usage is much less than in your case!
08:29And if you would just want to hold numbers, there is a vector! type:
>> stats
== 2509260
>> arr: make vector! n: 1000000 repeat i n [arr/:i: i] arr
== make vector! [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29...
>> stats
== 6525924
9214
08:36@Oldes he used microbenchmark to prove that there's some minor heap allocation during argument passing (don't look at me, I know how that sounds) if said argument is a block of 1M cells.
nedzadarek
09:59@Oldes Yes, I should pre-allocate it however it seems that in both cases (with and without pre-allocating) the results are the same. I'll keep that in mind (as it might destroy benchmark) if I want to prove something.
Oldes
10:50don't know what kind of results... you should use recycle before stats btw.
10:57@hiiamboris you consider this to be wrong?
>>   recycle stats
== 28584772
>> loop 100 [f :g arr]
== 42
>>   recycle stats
== 28591740
>> 28591740 -  28584772
== 6968

The difference is because of the console code which must display the results and process user input.
11:00
>> s: (recycle stats) loop 1000 [f :g arr] (recycle stats) - s
== 0
11:05@nedzadarek btw... Rebol3 has useful function evoke, which can help to understand, why one should preallocate:
>> evoke '?
Evoke values:
[stack-size n] crash-dump delect
watch-recycle watch-obj-copy crash
1: watch expand
2: check memory pools
3: check bind table

>> evoke 1
>> arr: repeat i 1000000 [append [] i]
Expand #0338B4F0 wide: 32 tail: 0 delta: 1
Expand #0338B4F0 wide: 32 tail: 1 delta: 1
Expand #0338B4F0 wide: 32 tail: 4 delta: 1
Expand #0338B4F0 wide: 32 tail: 10 delta: 1
Expand #0338B4F0 wide: 32 tail: 23 delta: 1
Expand #0338B4F0 wide: 32 tail: 63 delta: 1
Expand #0338B4F0 wide: 32 tail: 255 delta: 1
Expand #0338B4F0 wide: 32 tail: 1023 delta: 1
Expand #0338B4F0 wide: 32 tail: 4095 delta: 1
Expand #0338B4F0 wide: 32 tail: 16383 delta: 1
Expand #0338B4F0 wide: 32 tail: 65535 delta: 1
Expand #0338B4F0 wide: 32 tail: 262143 delta: 1
== ...
Rebol2Red
11:15Need some help with parsing.
string: {

	<s>
        <d>
			<h1><textA></h1>
        </d>
        <dc>1</dc>		
        <dc>2</dc>		
	</s>

	<s>
        <d>
			<h1><textB></h1>
        </d>
        <dc>3</dc>		
        <dc>4</dc>		
	</s>

After parsing the string i need to get:

A block containing 2 blocks like this:
[["textA" "1" "2]["textB" "3" "4"]]

Or a blok containing 2 blocks with 3 subblocks like this:
[[["textA"]["1"]["2"]][["textB"]["3"]["4"]]]

I came up with this, which (to me) seems logically correct.
But this appears not the way parse works.
parse string [
	collect set result [
		any [
			thru {<s>}
				any [
					thru {<d>}
						thru <h1>
						keep to </h1>
					to </d>
				]	
				any [
					thru {<dc>}
					keep to {/dc>}
				]
			to {</s>}
		]
	]
]
probe result

I got this:
[
	"<textA>" 
	"<textB>" 
	"3<" 
	"4<"
]

Note:
Until now i did things like this with a first parse and then a second parse on the first parse. I really like to know how to parse this with just one parse (if possible).
9214
11:22@nedzadarek
And just to end this show once and for all: it doesn't matter if block's buffer has a hundred, a million or a godzillion elements in it - this buffer is referenced by one block! value slot. When block is passed to a function, it is block! cell that gets pushed on a stack. Same for any other value, be it a function! or an object! or an integer! - they are always packed in a single cell, which may or may not has references to extra buffers.

Some functions will check only content of this cell (e.g. type? will check type ID in cell's header), others will use pointer in payload to access buffer (e.g. append or insert). But there are zero extra allocations required for argument passing (minus console overhead for reading / printing), which means that all that your "benchmark" "proves" is that you have no idea what you're doing.

When function calls another function and passes it its argument it's no different - argument is still passed as a cell on data stack, and callee leaves activation frame on call stack so that called function can know where to return and resume computation. But after function call is finished both call and data stack are empty (except maybe for root frame of evaluator), so, again, there's no memory overhead.
11:34@Rebol2Red
data: load {
    <s>
        <d>
            <h1> <textA> </h1>
        </d>
        <dc> 1 </dc>        
        <dc> 2 </dc>        
    </s>

    <s>
        <d>
            <h1> <textB> </h1>
        </d>
        <dc> 3 </dc>        
        <dc> 4 </dc>        
    </s>
}

probe parse data [
    collect [
        2 collect [
            thru <h1> keep to </h1> skip
            2 [thru <dc> keep to </dc> skip]
        ]
    ]
]
Rebol2Red
12:49@9214 Just what i needed, many thanks. Maybe you can explain a little. I suppose 2 is a repetition of what is following?
9214
12:56@Rebol2Red yes, integer values specify how many times to match a rule. Top-level collect creates a block, the other nested collect is matched 2 times to extract the data.
nedzadarek
12:56@9214 yes, you probably know everything about the Red but I know, more or less, what you said.
> he used microbenchmark to prove that there's some minor heap allocation during argument passing (don't look at me, I know how that sounds) if said argument is a block of 1M cells.

I guess this was about me. It's wrong. As you can read a first line (quote) [here](https://gitter.im/red/help?at=5ca3f13cb34ccd69e7558eb4) it was to prove that passing something big (I used a block but s/he mentioned an object!) would allocate lots of space (I assume s/he meant *lots* not *loads*). By "lots of spaces" I understand either:
- 100% -> full copy
- 10+% -> some kind of cache or something

My code proved that there is no such big change.
13:05@Oldes evoke seems interesting.
btw. is there a way to display stats without *internal* (e.g. gui-console's prints) allocations?
Oldes
13:06no. not possible.
nedzadarek
13:06I see, thank you
BuilderGuy1
15:15I have a few noob questions about component based programming and Red.
I'm just learning about components (and Red) and am curious about how they might be approached with Red.
Would Red require an additional layer similar to OLE or OpenDoc?
Or could the prototype objects be used using a object convention like JavaBeans?
Or is Functional programming a sufficient replacement for components?
Or something else???
Rebol2Red
15:15@9214 Can you tell me where you get that information from. I hav'nt seen it anywhere. Maybe you came up with this yourself? ps i read about repetition but nested collect?
9214
15:17@Rebol2Red it is described at length in various Parse docs and tutorials. See [here](https://github.com/red/red/wiki/%5BDOC%5D-Parse), for example.
15:18Or do you mean nested collects? I don't think it's covered in detail anywhere, but the rules are easy to learn: collect makes a block, keep collects matched input in this block. collect nested in another collect will just create another block.
Rebol2Red
15:21@9214 Yep. Will look into the mentioned tutorials. Thanx
9214
15:32@BuilderGuy1 COP puts emphasis on separation of concerns and code reuse. In Red this is typically tackled with dialects, but nothing really stops you from using functional programming or OOP - this is all just the means to an end.
BuilderGuy1
15:35OK, i thought that might be the case but I didn't consider dialects, thank you :-)
nd9600
20:29> > I guess I thought if I wanted to pass a pointer (e.g. to a big object!) from one function to another, it would be allocating loads of space for some reason?
>
> How's that? You seems to be confused about how data is represented internally in Red.

@9214 you're right, I was confused - I think I thought that the internal representation was the same as how the code was written (because of it being homoiconic?).. It sounds very stupid written out like that, I know :)
Rebol2Red
23:12@9214 How to parse this?
data: {
    <s>
        <d>
            <h1><textA></h1>
        </d>
        <dc>A1</dc>        
        <dc>A2</dc>  
              
    </s>

    <s>
        <d>
            <h1><textB></h1>
        </d>
        <dc>B1</dc>        
        <dc>B2</dc> 
        
        <d>
            <h1><textC></h1>
        </d>
        <dc>C1</dc>        
        <dc>C2</dc> 
		
    </s> 
}

parse data [
    collect set test [
        2 collect [ ; this is known
            thru <h1> keep to </h1> skip
            2 [thru <dc> keep to </dc> skip] ; <--- can not use this!
        ]
    ]
]
probe test

And what about when i do not know how much <s> ... </s> there are
Is it still possible to use collect and keep the data inside one block?
23:36@9214 To be clear, the amount of items between <s> </s> can be 1 or more otherwise i could ofcourse use: 3 [thru <dc> .... skip]
gltewalt
23:38You might get more feedback in red/parse
Rebol2Red
23:40I'll keep that in mind. I did'nt know there was a room for parse. btw. I can not see it when i select: all conversation?!

nedzadarek
00:52@Rebol2Red because it's your previous conversations (in room or private) and some suggestions. Check "globe icon" on the right top corner ("More red rooms").
toomasv
03:17@Rebol2Red You can use some instead of 2. (Some [docs](https://github.com/red/red/wiki/%5BDOC%5D-Parse))
giesse
06:34@toomasv I don't think it's going to work given they're using thru and the given input...
Rebol2Red
06:36@toomasv do you mean this
parse data [
    collect set test [
        3 collect [ ; this is known
            thru <h1> keep to </h1> skip
            some collect [
             thru <dc> keep to </dc>
			]
        ]
    ]
]
probe test

The result is not what i want
[["<textA>" ["A1"] ["A2"] ["B1"] ["B2"] ["C1"] ["C2"] []
] []]

I want to get this
[["<textA>" "A1" "A2" ]["textB" "B1" "B2"] ["textC" "C1" "C2"]]

I have tried putting some at many places but to no avail
I think the problem with any or some is that it is 'greedy'. It will parse as much as it can when false or true.
rebolek
06:48Don't use to and thru, use skip. It's faster and safer.
toomasv
06:59@giesse Right. @Rebol2Red One (convoluted) way that works:
parse data [
    collect set test [
		to <h1>
		some [1 [
			<h1> [
				collect [
					keep to </h1>
					some [
						 <dc> keep to </dc>
					|	ahead <h1> break
					|	skip
					] break 
				]
			]
		]]
    ]
]
probe test ()

[[
    "<textA>" 
    "A1" 
    "A2"
] [
    "<textB>" 
    "B1" 
    "B2"
] [
    "<textC>" 
    "C1" 
    "C2"
]]
dsgeyser
07:58Redlangserver. How must I activate it in VSCode editor? Can't find previous discussion.
9214
10:44@Rebol2Red
data: {
    <s>
        <d>
            <h1><textA></h1>
        </d>
        <dc>A1</dc>        
        <dc>A2</dc>  

    </s>

    <s>
        <d>
            <h1><textB></h1>
        </d>
        <dc>B1</dc>        
        <dc>B2</dc> 

        <d>
            <h1><textC></h1>
        </d>
        <dc>C1</dc>        
        <dc>C2</dc> 

    </s> 
}

s:  [thru <s> some [to <d> collect [d 2 dc]] thru </s>]
d:  [thru <d> h1 thru </d>]
h1: [thru <h1> keep to </h1> thru </h1>]
dc: [thru <dc> keep to </dc> thru </dc>]

probe load trim/lines mold parse data [collect some s]

[["<textA>" "A1" "A2"] ["<textB>" "B1" "B2"] ["<textC>" "C1" "C2"]]
10:48@giesse @rebolek @hiiamboris do you think making an idiom for to X thru X would be a good idea?
rebolek
10:49@9214 IIRC you're not first asking this question.
9214
10:49Like "match to token but then jump over it anyway".
rebolek
10:50The problem is that X could be something much more complicated than
10:51And the source can even change before the thru part.
9214
10:51@rebolek yes, so, say over X will match to X and then immidiately thru it, in one atomic action.
rebolek
10:51I am certainly not against it.
9214
10:51I don't mean to and thru as Parse rules but as actions on input series.
hiiamboris
11:03to [X p:] :p is enough
rebolek
11:03if only we had rules with args...
9214
11:04@hiiamboris that's smart! Although you need to unset 'p after parsing.
11:04@rebolek exact same thought.
hiiamboris
11:05If p bothers me then yes. On a positive side, no double matching.
11:42If however this idiom will be considered worthy of implementing, I think the name to thru X (it doesn't do anything useful anyway right now) is more clearly expressing it's intent than over, esp. together with keep or copy. keep over X reads the same as keep thru X to me.
nedzadarek
11:58@hiiamboris for me keep over X reads as *keep something after X* (e.g. thru X keep any-type!).
9214
12:01@hiiamboris well, that's just the naming, not really important at this point.
hiiamboris
12:01Right.. But it's the hardest thing ☻
9214
12:02Although I agree that making this idiom as some kind of extra flag for to makes more sense and dovetails nicely to collect set or keep pick.
Rebol2Red
15:23@9214 Thanks, Your last example is the one i'm gone use after looking closer at the webpage i want to parse. I had to adjusted it but this was easy to do. I certainly can use this for future parsing.
giesse
19:29@9214 re: load trim/lines mold - mold/flat perhaps?
19:30I've wanted rule arguments for well over a decade. In fact, https://giesse.github.io/rebol-power-mezz/parsers/rule-arguments.html
9214
19:30@giesse thanks, totally forgot about /flat.
giesse
19:33I've been debating for a long time whether topaz-parse should use function! values for that purpose. Or, have a special dialect to define rules.
9214
19:35@giesse I second your idea about function! values - whatever such function returns is treated as a Parse rule.
giesse
19:36@9214 regarding over or to thru, in general I'm not a fan of to and thru and prefer to define a complete grammar instead. (BTW you don't really need to X thru X, just to X X or even to X n skip depending on the case.)
19:38I was going for the body of the function itself being a parse rule.
9214
19:39> I was going for the body of the function itself being a parse rule.

But then you can't create dynamic rules at runtime? e.g. foo can return [thru keep to ].
giesse
19:39foo: func [x] [thru x keep to x x] etc.
19:42In Topaz it would have automatically dealt with locals and recursion... which solves another problem with parse (easier in topaz-parse because I use set-word! instead of the set keyword)
nedzadarek
19:46@giesse so, given foo from the above message. if I use it like topaz-parse [...] [foo 'c] it would translate to something like topaz-parse [...] [[thru x keep to x x]] (where xs are bound to some context - or another way)?
giesse
19:55In Topaz itself, parse would "call" the function (thus dealing with collecting the arguments, pushing context on the stack, all that stuff that happens before the function body block is do-ne anyway), but instead of using do on the function body it would just use it as a rule.

With topaz-parse, since it's now a compiler, I can just replace the function call with the block right there, just as you describe.
19:56The problem I have with this is the confusion of seeing foo: func [x] [keep to x x] and not knowing that it's a parse rule and not a regular function. (And if you accidentally call it outside of parse ...)
19:56We could just have parse-func: :func or something like that, but, it's still a hack at best.
nedzadarek
20:28@giesse
> The problem I have with this is the confusion of seeing foo: func [x] [keep to x x] and not knowing that it's a parse rule and not a regular function.

Can you name parse related function like topaz-func, topaz-function etc? They will be separated functions...

> And if you accidentally call it outside of parse ...

... and they will modify spec/body like this:
body: [2 + 2]
topaz-func: func [spec body] [
    append spec /topaz
    insert body [
        unless topaz [do make error! "not in parse/topaz"]
    ]
    func spec body
]
f: topaz-func [] [
    2 + 2
]

this way, your topaz-parse can just call f/topaz if they see f. Outside topaz-parse everyone would call just f hence an error.
ps. nobody stops you from calling a function with refinement (f/topaz) but it is the same with /local refinement.
giesse
20:32@nedzadarek right, there are a number of ways around, it's just a hack at best :) but, I do want this capability in some form or another, so I'll figure out a way eventually. (Ideally Red and parse themselves could support this, either with a different type like parse-rule! or parse-function!, or with a function flag, to minimize the confusion.)
rebolek
20:32Well I guess that a function to make rules could be named...

...let me think...


...this one's really hard...


rule?
9214
20:34@rebolek think harder! You can do better than that.
giesse
20:37I think I should have moved this conversation to the parse room...

@rebolek yeah, but, should it be of type function!, or something else entirely?
rebolek
20:39@giesse function! is fine IMO.
20:39@9214 right, what about :book: ?
20:42@giesse I don't think rules with args needs some special functionality that deserves their own type. It's something that's possible today with simple rules compiler, but it would be nice to have it directly in the language so you won't have to write your own rules compiler.
9214
20:43@rebolek func - function. rule - ..?
rebolek
20:44ru - rule?
nedzadarek
20:44@rebolek if rule would be nice enough not to mess things outside parse block.
9214
20:44> ru - rule?

:bear: :ru:
20:46Sorry for the offtop though. Let's move to /parse room.
rebolek
20:46@9214 @nedzadarek While I understand your concerns, I would not want to get lost in details of function that does not exist yet.
20:46@9214 right

nedzadarek
14:45How do you count a number of characters that can fit in the console without splitting?
moliad
14:50count the number of times you can press space before it wraps? :stuck_out_tongue: :wink:
rebolek
14:58There's ANSI sequence on normal systems that returns console size, but Red doesn'ŧ support it yet.
meijeru
15:17That number depends on the horizontal size and the font, normally. The former is system/view/screens/1/pane/-1/size/x. With a variable width font one can only determine an average, I would say.
greggirwin
18:18@nedzadarek system/console/size/x
meijeru
18:36I don't know why, but the two are different:
>> system/console/size
== 239x58
>> system/view/screens/1/pane/-1/size
== 1920x997

The last one seems correct, because I did this with a maximized console, on a 1920x1080 display. So what is the other one denoting?
greggirwin
18:37Columns and rows (characters).
18:37That is, it's already done the hard work for you. :^)
meijeru
18:44Enlightening! But this is assuming a fixed width font, isn't it? Can one give the console an arbitrary font, e.g. a variable width one??
greggirwin
19:08The consoles only support monospaced fonts.
19:08I haven't tried to hack around that, but you might be able to, in which case those numbers won't be accurate.
GaryMiller
19:30Shouldn't the consoles just have a word wrap property that when set to true does word wrap automatically adjusting for whatever font size? Seems like if the goal is to make the GUI a feature attraction for new programmers these kind of niceties will be expected. And to handle variable length fonts you may have to add the pixel width of each character as it is typed or do collision detection with the right border of the frame as the characters are being displayed. Pretty impressive already with the amount of GUI you can get with so little code.
nedzadarek
19:43@greggirwin
> @nedzadarek system/console/size/x

That what I was looking for. Thank you.
ps. it seems that it's system/console/size/x + 4 (console's prompt >> + 1 extra character). So I guess it calculated based on standard system/console/prompt's length.

@moliad I was going to do something like this.
hiiamboris
19:59I have system/console/size/x off by 7-8% of it's real char capacity. 14 chars when it's fullscreen.
nedzadarek
20:00@hiiamboris what resolution do you have?
hiiamboris
20:011920x1080
greggirwin
20:01@GaryMiller the consoles already handle line wrapping. My question, in return, is what is the reference standard console/REPL as far as features, and what important features are we missing. Plugins will help with that, of course, but what is the target.

As far as variable pitch fonts, how many programmers use them, and why? This would be good to know. My editor supports a separate column-mode font, but I found it quite jarring (and error prone) when trying variable pitched fonts for non-column-mode in the past.
hiiamboris
20:01Minus scrollbar (~20px) - 205 chars do fit, while it counts 219
greggirwin
20:02You'll see that help has a right margin value, as I had issues when working on it @hiiamboris.
20:03But I get an exact match on count and chars right now in the GUI console.
nedzadarek
20:03@hiiamboris
> 205 chars do fit, while it counts 219

system/console/size/x is 205, right?
greggirwin
20:03DPI issues perhaps?
hiiamboris
20:04@nedzadarek No. Console/size says 219x39.
@greggirwin More likely the rounding error of size-text (although, yeah, DPI-affected). Can't say for sure☺
greggirwin
20:05Off by a couple chars in the CLI console.
hiiamboris
20:06How can one miscalculate the CLI console width is beyond me...
20:11> You'll see that help has a right margin value

@greggirwin what do you mean?
nedzadarek
20:14@hiiamboris when I resize windows to the smaller size I got similar results:
system/console/size/x
; == 50
01234567890123456789012345678901234567890123456 ; <<< can type this
system/view/screens/1/pane/-1/size
; == 409x463
greggirwin
20:16CLI rows is correct, so something in get-window-size in %console/cli/win32.reds that uses the GetConsoleScreenBufferInfo API result. @qtxie would have to say what the extra calcs are for, when setting the size, rather than just using the result as is. No comments to say why.
20:18@hiiamboris in help we want to show as much as possible without wrapping and creating empty lines in the output, but if I didn't have some extra space in there, some values would form too long and cause that problem.
hiiamboris
20:20Well, extra lines is exactly what I have. There's even an issue about it.
GiuseppeChillemi
22:21If I have uderstood correctly, when I use LOAD the argument content is bound to the global context but I have not understood what happen when I use DO ? Is another context created ?
22:43So Do is a Load with evaluation?
nedzadarek
22:59@GiuseppeChillemi It seems that do + string = binding to the global context by default.
greggirwin
23:06Yes. @GiuseppeChillemi, it can be helpful to play around in the console, and with small scripts, experimenting with combinations. There are just a few in this case, so it's not hard. By doing the experiments yourself, and seeing concrete results, you learn a lot, and in a different way than in talking about abstract concepts like contexts and binding. You see the behavior first hand.

vazub
14:55Is there a way to print or otherwise present the number in different bases? For example, let's say I want to see binary (ones and zeroes, NOT hex) representation of some integer. How can I output it? So far, I could find only a way to set a literal 2-base binary number, but nothing to print any other number in 2-base form. Is there any facility for this?
toomasv
15:04May-be you’ll find some idea from here https://gist.github.com/toomasv/a6d15d1c71a60fdd25b7c62b6a75f91d
9214
15:15@vazub see enbase and debase; also check extended binary notation n#{...} where n is base and ... are valid digits.
15:29
text
>> base: func [number base][enbase/base to binary! number base]
== func [number base][enbase/base to binary! number base]
>> foreach n [2 16 64][probe base 1337 n]
"00000000000000000000010100111001"
"00000539"
"AAAFOQ=="
== "AAAFOQ=="
>> 2#{00000000000000000000010100111001}
== #{00000539}
>> to integer! 2#{00000000000000000000010100111001}
== 1337
>> to integer! 64#{AAAFOQ==}
== 1337
vazub
16:05@9214 enbase-debase work with string conversions. What I am looking for is to represent integer in base-2 directly. Like in this imaginary example:
print/base 5 2
== 2#{0000000000000101}
9214
16:20@vazub that's not possible. The way to go is to convert your value to binary! and enbase/base it.
16:20If I get this right you want print/base to return binary! value with specific formatting?
16:34integer! value 5 represents integer number 5, so as binary! value #{05} and string! value "00000000000000000000000000000101". So I don't understand why you have trouble with string! that enbase returns. If we'd have roman! datatype, V would represent number 5 too.

Or do you want Red to print out integer! value differently based on some kind of internal flag?
GiuseppeChillemi
16:55@greggirwin
> By doing the experiments yourself, and seeing concrete results, you learn a lot, and in a different way than in talking about abstract concepts like contexts and binding. You see the behavior first hand.

Greg, I agree but when you lack some theory and base mechanism you can easly misunderstand what you see. And in REDBOL what you see is not always what it is.
Don't forget I come from years having interpreted things in the wrong investigating by myself, and now thanks to your help some deeps concepts have been undestood.


vazub
18:26@9214 I come from Go, where the [fmt](https://golang.org/pkg/fmt/) package from standard library has a notion of "verbs", essentially allowing to format the output. So, for example, you would use %b verb to print the integer in base 2, %d for base 10 (default), %o for base 8 and so on. Now in Red, there seems to be no facility to do the same, which you confirmed in one of your previous posts. Going through string conversion back and forth is a way around, but not necessarily the same.

By the way, on the side note, it feels strange, that Red's binary! datatype is presented in hexadecimal by default. Convenience reasoning aside, it is a bit confusing, as the semantic meaning for "binary" is a number in base 2, not 16. Again, newcomers will probably adjust, but this doesn't necessarily come as an intuitive representation, in my opinion.
greggirwin
18:31@vazub Go has to do the same string conversions. It's just built into the fmt package.

Binary! doesn't mean 1s and 0s in Red, it means "raw". Hexadecimal is a much more useful default in that context. We also have the bitset! type, but its purpose is not unlimited binary data representation.
9214
18:31@vazub

> there seems to be no facility to do the same, which you confirmed in one of your previous posts

Wrong. I explicitly told you that you should use debase to format integers the way you want, but you cannot ovveride mold action! for a given datatype so that it prints out differenly each time you poke at it.

> Going through string conversion back and forth is a way around, but not necessarily the same.

It *is* the same, and Go does that internally.

I/O string formatting has nothing to do with the way values are serialized - Red is a homoiconic language, unlike Go, so you can't really compare the two.
greggirwin
18:37@vazub, does this do what you want?
print-base: func [int base][
    print enbase/base to binary! int base
]
18:38
>> print-base 1 2
00000000000000000000000000000001
>> print-base 5 2
00000000000000000000000000000101
>> print-base 5 16
00000005
>> print-base 55 16
00000037
>> print-base 55 64
AAAANw==
9214
18:38@greggirwin this is essentially what I've posted in my first example (see base [here](https://gitter.im/red/help?at=5ca8c5ca8148e555b25c83d5)).
vazub
18:38@greggirwin If that is the case for fmt, then this makes a lot more sense now, thanks for clarifying! Then my question would be, are/were there any plans to provide something similar for print, or is it considered, that enbase, debase are sufficient for these kind of transformations?
And yes, your example does exactly what I was talking about!!! That is fantastic!
greggirwin
18:39@9214, indeed, I missed that somehow. Thanks.
9214
18:39> And yes, your example does exactly what I was talking about!!! That is fantastic!

Are you kidding me? I posted the same function and you said that it's not what you're looking for.
greggirwin
18:39Cool down @9214.
18:40@vazub, print will not add this functionality, but there's a format lib in the design stage which could.
vazub
18:41@9214 I believe I misunderstood your message originally, sorry about that. It's just that Gregg's example was more understandable to me.
9214
18:44@vazub so you actually want this?
>> print-base: func [number base][print rejoin [base "#{" enbase/base to binary! number base "}"]]
== func [number base][print rejoin [base "#{" enbase/base to binary! number 2 "}"]]
>> print-base 5 2
2#{00000000000000000000000000000101}
>> print-base 5 16
16#{00000005}
vazub
18:45@9214 Correct! :)
9214
18:46@vazub okay then. I thought you want something like:
>> system/base: 2
>> 5
== 2#{00000000000000000000000000000101}
vazub
18:47Sorry if my way of explaining the problem might have been a bit vague)
9214
18:49@vazub FYI, it will work with any value that can be converted to binary!, not just integers.
vazub
18:55@9214 just out of curiosity - in your last example, did you actually change the whole Red's environment to represent integers in base 2 instead of base 10?
9214
18:56@vazub no, that was just an artificial example.
GiuseppeChillemi
18:56Do you confirm that CONTEXT? is a RED only function. It seems there is no way to getting back a word context in REBOL2 .
9214
18:57@vazub to make it really work that way you'd need to change mold action for integer! datatype at runtime. I don't think that's possible without JIT compiler, and it also opens up a lot of design questions.
18:59:point_up: that's what my "not possible" really meant, not that you can't print integers in different bases.
vazub
19:01@9214 Yes, that is probablyy where my misunderstanding or your statement came from) And as for system-change example, I would be interested to learn about any intended use cases for such thing - it seems powerful, but not something I personally would be able to find immediate use for.
9214
19:04@vazub IIRC Forth uses that a lot, for integer formatting / parsing. Can't tell about other languages.
giesse
19:20@GiuseppeChillemi try bound?
GiuseppeChillemi
19:28@giesse any other good functions to explore the deep of contexts, words/bindings? and system structures? (Even rebol.org ones)

meijeru
09:15@GiuseppeChillemi In Rebol, both 2 and 3, it is also called bind?.
GiuseppeChillemi
09:57@toomasv
Continuing [this](https://gitter.im/red/red?at=5ca9bbf53ebbdc55b376c0e5)
However, a question arise: is the a wait to have B linked to A and having B reflect any change to A ?
toomasv
09:59@GiuseppeChillemi
The reference is kept in case of series:
a: "1"
b: a
;== "1"
a/1: #"2"
b
;== "2"

a: [1]
b: a
;== [1]
a/1: 2
b
;== [2]
10:06> You change it differently.

It is changed according to its value type:
>> blk: load "func [a b][a + b] 4 5"
== [func [a b] [a + b] 4 5]
>> blk2: reduce blk
== [func [a b][a + b] 4 5]
>> do blk2
== 9
>> change next body-of first blk2 '*
== [b]
>> do blk2
== 20
GiuseppeChillemi
10:06@toomasv
>> The reference is kept in case of series

Series inner content change, not for assignment operation:

>> a: ["some"]
== ["some"]
>> b: a
== ["some"]
>> a: ["thing"]
== ["thing"]
>> b
== ["some"]
>> 
>> a: "some"
== "some"
>> b: a
== "some"
>> a: "thing"
== "thing"
>> b
== "some"
toomasv
10:07Yes.
GiuseppeChillemi
10:21Please answer to my question after having read this code:

>> blk: load "func [a b][a + b] 4 5"; 
== [func [a b] [a + b] 4 5] ;<-----------------------------------
>> length? blk
== 5

>> blk2: reduce blk
== [func [a b][a + b] 4 5]

>> length? blk2
== 3

>> probe blk2
[func [a b][a + b] 4 5] ;<------------------------------------


If you are a newcomer, and you have not read that reduce line and lenght? blk2 = 3...would you think that the arrowed parts are a both a 5 elements block ?
toomasv
10:27Nope, it's a common pitfall for newcomers. It was for me too.
GiuseppeChillemi
10:32So it's not nope, it's yes 😉
toomasv
10:33Ah, sorry, you are right. :)
GiuseppeChillemi
10:35As we all fell in the same hole, what about covering it?
10:35*fall
rcqls
10:38@GiuseppeChillemi Thanks for this comment! BTW, for a newcomer I would say that length? blk2 would return 4 (not 5) since there is no space between [a b] and [a + b] after reducing blk. And since [a b][a + b] does not make sense as an element of block I would consider that 3 is the good answer….
toomasv
10:43@GiuseppeChillemi But how would you do it without having "read about reduce and length?" (sloppy quoting)
GiuseppeChillemi
10:45@rcqls I haven't seen it. You are introducing a new topic belonging to visual decoding: if the difference too small you continue to see things in the same way as before without spotting it is a new thing.
10:47Probe should return the function part of the block with additional symbols markers or, thanks to the new consolle code, in a different color.
10:48This is the only possible way.
rcqls
11:13@GiuseppeChillemi Syntaxhightling in console is for sure an awesome and useful tool.
toomasv
11:13Doc said it is planned.
rcqls
11:16I tried to compile gui-console on linux but it fails. Not sure it is linux/GTK related….
9214
11:19@toomasv it's already present, just not enabled by default.
toomasv
11:20@9214 Good! I haven't used it.
9214
11:20> You can turn syntax highlighting on with the following command: gui-console-ctx/terminal/color?: yes
> It is not dynamic, so you may find the colors don't work well with the colors you've selected in the Settings dialog for the console. There is no support for customizing themes yet. If you want to experiment with changing colors, you have to manually set values in gui-console-ctx/terminal/theme.
toomasv
11:21Thanks!
loziniak
11:58Hi! I've noticed a strange thing. When running this code: a: function [return: [integer!] "test comment"] [1] from console, I get an error *"invalid function definition: return:"*, but when I compile it with "-c" option, it compiles and works without errors.
9214
12:03@loziniak https://github.com/red/red/issues/3595
loziniak
12:32thanks!
GiuseppeChillemi
13:25@9214 Tried activating the coloring but I see no difference between a block with a reduced function ad a not reduced one
nedzadarek
14:50@GiuseppeChillemi for a simple test (I don't remember the post) it seems that colouring is not implemented for complex datatypes (e.g. images).
toomasv
15:35@9214 @GiuseppeChillemi It doesn't seem to work for function!:
15:36[![image.png](https://files.gitter.im/red/help/EGQ7/thumb/image.png)](https://files.gitter.im/red/help/EGQ7/image.png)
word! is orange
function! should be brick
greggirwin
19:34@GiuseppeChillemi serialized syntax for all types does not exist yet. Until it does, there will be ambiguity in the textual representation of some molded values.
gltewalt
19:36No color value seems to work for function! on my end, no matter how you create a function
greggirwin
19:39@gltewalt that's because the highlighter is parsing the source textually, not at the block/type level.
nedzadarek
20:36@greggirwin so... is it possible to highlight a specific word, e.g. print?
greggirwin
20:40Not currently.
GiuseppeChillemi
20:46@greggirwin in Italy we say: we are on the good road. I don't know if it is undestandable.
greggirwin
20:47"On the right track" is probably the American phrase.
GiuseppeChillemi
20:49Just waiting for to world to start going beyond of keyboard symbols and start using emoticons like symbols for programming.
20:53Yes they have the same meaning even if they are not equal :-)
nedzadarek
22:26@GiuseppeChillemi I think ASCII is the best choice for programming. Sure you can use
- natural language or
- mathematical symbols

in some group that understand it but if you want to "be international" I think you should use symbols that most people recognize and type without problems.
GiuseppeChillemi
23:23@nedzadarek you can include graphic symbols with script, so exporting and using them beside code blocks is like having a full word. Pic is a word itself
23:24(it could also be an animation !)

nedzadarek
00:21@GiuseppeChillemi oh, sure, so most people (programmers) can see a difference between things like :wink: and :smirk: , type it with reasonable speed, they don't need special software/hardware etc. Do you have any examples with things that could work somewhere?
GiuseppeChillemi
00:31I'll try to assemble my ideas and show you something.
laturk
04:17Has pgsql-protocol.r been ported to red yet?
greggirwin
04:36@laturk no, not yet. It will come after 0.7.0, which adds full I/O. Nobody on the core team is assigned to it though, so someone who needs postgres support will need to lead the charge.
nedzadarek
09:31@GiuseppeChillemi great!
loziniak
09:57Hi! I have an issue with preprocessor directives in included files. They behave strangely, differently for compilation, and differently when interpreted. Below code works ok when interpreted, but in compilation I get *** Preprocessor Error in #either^/ *** Script Error : a has no value.
Red [File: %prep-incl.red]
#either a [print "a"] [print "not a"]

Red [File: %prep-main.red]
#do [a: true]
#include %prep-incl.red

Seems like preprocessor context is not preserved between included files, when compiling. But most probably I'm missing something.
9214
10:49> context is not preserved between included files

During compilation it explicitly gets reseted after preprocessor's pass. Interpreter supports macros only for compatibility, and doesn't work as one might imagine - try, for example:
Red [File: %prep-main.red]
a: true
do %prep-incl.red
10:50That is, in interpreter "preprocessing" always happens at run-time, hence using macros makes little to no sense.
loziniak
10:52Ok, so in interpreter preprocessor directives are like just another context?
9214
10:54I'm not sure I understand what you mean by "another context".
loziniak
10:55Hmm I've run your example and I get *** Script Error: a has no value
10:56ups, sorry, I forgot about do instead of #include
9214
10:57In interpreter all directives are expaned by do if it's applied to a file!, so macros get mixed with runtime values (in the example above #either "knows" about a).
loziniak
10:57(forget that about "another context", I feel it won't get us to a solution)
10:59> macros get mixed with runtime values

:-o woah, is this intentional, or just another Red's quirk to-be-done-after-1.0 ?
9214
11:00... like I already said, macros exist in interpreter just for compatibility. Actually using them in interpreter makes no sense, because cost for expansion gets paid at runtime. It's actually as if you've parsed block manually and substituted some issue! values by expressions that follow them.
loziniak
11:05A little surprising behaviour for me. Couldn't it be at least somehow separated out of main context? In docs there's preprocessor/exec mentioned. Shouldn't it be the only thing preprocessor code sees? As usual, there are probably a reason for this, just not very obvious.
9214
11:07With compilation there are disctinct phases: preprocessor -> compiler -> linker. Say, if you ask preprocessor to expand a loop
collect [repeat i 100 [keep i]]

It will inlines 100 integers as-is, and the will be compiled that way. When you launch a compiled binary, these 100 integers will be in there.

With interpreter, on the other hand, there are no phases - interpreter just takes a string, loads it, and, well, interprets it. If it sees
collect [repeat i 100 [keep i]]

It will unroll it at run-time, which takes time and resources. If it sees it the second time - it will do the same. So "preprocessing" gets mixed with runtime, which is totally expected.
loziniak
11:13Perhaps it should be stronger outlined in documentation.
9214
11:13You can, for example, inline trigonometric tables that way, and preprocessor may take hours to calculate all of them, but, in exchange, your compiled app will do blazingly fast calculations at runtime (albeit it will be a bit bloated with all the inlined tables) - because all it has to do is a table lookup. Interpreter, OTOH, doesn't work that way. You give it a string, it loads it, and then starts to "walk" what it loaded - this is where runtime starts. If you wish to "expand" any directives at this point - the prices will still be paid at runtime.
loziniak
11:14I see.
11:17Apart of running preprocessor code along with main code – don't you think it should be better separated (have it's own environment), as when compiling?
9214
11:17> Perhaps it should be stronger outlined in documentation.

I believe documentation already covers that.

> Macros allow an efficient form of metaprogramming, where the execution cost is paid at compile-time, rather than run-time. Red already has strong metaprogramming abilities at run-time, but, _for the sake of enabling Red source code to be run equally well by the compiler and interpreter, macros can also be resolved at run-time_.
loziniak
11:18It says nothing about mixing runtime values with macro ones.
9214
11:19There's "resolved at _run-time_" bit right at the end.
loziniak
11:19It also says a little earlier:
> All the expressions used in directives are bound to a dedicated context to avoid leaking words in global context
11:20That misled me
11:21But, when you think about it a little more, indeed nested context sees values from its parent.
11:28Ok, leave it for now. Maybe you could suggest me a solution to a problem I wanted to solve with preprocessor – I have couple of files in my app. I want to do conditional #includes in couple places, depending on some value defined in main file.
11:29And I want it to work the same on compilation and when interpreted.
9214
11:31> All the expressions used in directives are bound to a dedicated context to avoid leaking words in global context

Well, yes, all macros are hygenic and don't leak anything.
>> :foo
>> expand [#do [foo: 1]]
[]
== []
>> :foo
>> preprocessor/exec/foo
== 1
loziniak
11:36Now I see. I made wrong assumption that main context is also not visible from macros. But that's not my main problem. What bothers me is what you said:
> During compilation it [preprocessor context] explicitly gets reseted after preprocessor's pass.
9214
11:36When you compile, expression in #either ... is evaluated by Rebol2 interpreter, when you interpret, it is evaluated by Red interpreter.
loziniak
11:38Yes! That was easy to deduct from docs :-)
So, is it like macros in one file cannot see values from other file, when it's #included?
11:39* macros in one file cannot see values FROM MACROS in other file
11:51I mean something like:
Red [File: %prep-main.red]

#do [a: true]

#include %prep-incl.red
#include %prep-incl2.red

Red [File: %prep-incl.red]

#either a [
	#include %prep-A.red
] [
	#include %prep-B.red
]

Red [File: %prep-incl2.red]

#either a [
	#include %prep-C.red
] [
	#include %prep-D.red
]
11:53If anybody had any idea, I'd be thankful.
9214
12:17@loziniak I'd rather prepared a little Make-like script that feeds off some config, processes all specified files and creates one big blob which you then compile, without any nested inclusions (I'm not entirely sure that current preprocessor can handle that correctly).
loziniak
13:06Do you think it's better to file a bug about preprocessor not persisting values between includes, or to make a PR to the documentation with info about it?
9214
13:17@loziniak prior to doing any of the above it needs to be discussed with the core team. Let's wait for @greggirwin to catch up.
loziniak
greggirwin
18:38Nenad would have to say if this is completely by design, or an implementation limitation. We should definitely clarify the docs on this, and a PR would be most welcome @loziniak.

How to get around it is easy. Compile using Encap mode, or do what @9214 suggests and have a build script the controls everything. I've done that with R2 for many years, using Ladislav's include, and it works well.

My suggestion to use Encap mode may lead to "but I don't want the unnecessary files in the resulting EXE at all.", which will lead me to ask "Why?" :^) From there we can get into more details and talk about architecture, structuring Red apps, and all the fun that goes with that (really, it's a lot of fun :^).

Ultimately, think of Red as a very dynamic language, and the conditional compilation model we know from C as suited for Red/System, but not so much for Red.
9214
18:44> Compile using Encap mode

Nuh-uh, probably ain't gonna work. See https://github.com/red/red/issues/3464
greggirwin
19:10Hmmmm. Shoot. Let's fix that first then.

OneITI37
04:26@OneITI37
Hello.
I am creating a software that loads local images to display on it.
Nevertheless, I am constantly getting this error, when I try to open it by clicking the app icon.
*** Access Error: cannot open: %InitializationScreen.png
*** Where: decode
*** Stack: layout load
The weird thing about this error is that I do not get the error message, if I run it via Terminal.
greggirwin
04:27I responded in /welcome, but this is a better room for it. :^)
OneITI37
04:27Red [
needs: view
]
view/flags/tight [
title "Initializing..."
size 400x300
backdrop 73.73.73.0
below
UpperScreen: image %InitializationScreen.png 400x225
TerminateButton: image %TerminateButton.png 400x75 on-down [
quit
]
]
[no-buttons]
write %hello.txt "Hello, world!"
04:27This is my source code.
04:28Not to mention that two images files mentioned above are in the same directory with the source code itself.
greggirwin
04:29I don't have MacOS up here, but someone who does should see this before too long.
04:30Does the app icon launching set a different base dir?
04:31You can use what-dir in your Red code to see what the active directory is.
OneITI37
04:32Oops...
04:33Just found the cause of the error.
04:33Red has a default directory of /Users/<User Name>/
04:33In order to call the file at the same directory,
04:36what prefix should I have on the directory location?
07:01I actually found out that, on macOS, removing the slash from the file path does not make it a relative path.
nd9600
14:42I'm looking into https://github.com/red/red/issues/3482 now, but I can't compile Red on Linux by following the instructions at https://github.com/red/red/#running-red-from-the-sources-for-contributors, though I can get all the tests to pass - I get this error:
Compiling /home/nathan/repos/nd9600/red/tests/hello.red ...
...using libRedRT built on 9-Apr-2019/14:05:40+1:00
...compilation time : 19 ms

Target: Linux 

Compiling to native code...
*** Compilation Error: unknown path root variable: red/object/path-parent 
*** in file: %/home/nathan/repos/nd9600/red/tests/hello.red 
*** at line: 332 
*** near: [
    set-path* eval-path _context/get ~system as cell! ~script as
]
14:42Am I doing something wrong by just running do/args %red.r "%tests/hello.red" in rebol?
9214
14:45@nd9600 you should compile in release mode.
nd9600
14:47Yep that was it - how did you know that was the issue?
Should that be in the readme somewhere?
14:47thanks
loziniak
17:20@greggirwin compilation in *encap* mode is not a solution for me, because I have Red/System code and routines. That's why I wanted conditional inclusion – I externalized Red/System code to separate files, and wrote "adapters" that can be compiled and executed by call function, passing arguments into *stdin* and getting results from *stdout*. Files with calls should be then #inluded instead of original files with Red/System routines. That speeds up development of pure Red part of the project, as there is no need to recompile entire project (has to be done with costly -r option) everytime I want to run my code.
hiiamboris
17:41-e option works with -c as well, why do you need -r during development?
loziniak
18:04Some things don't work with just -c.
18:06Especially when combining Red/System code with Red.
BeardPower
18:11@loziniak The Red compiler is limited in it's current form.

nedzadarek
12:09I can see point! datatype but I cannot create it (make point! []). Is it not fully implemented yet? I can see few place that mention it (e.g. [this](https://github.com/red/red/blob/ca2e254f8c5f8f3702f0390a4508acaddba9df18/runtime/datatypes/structures.reds#L207) and [this](https://github.com/red/red/blob/6a5efd7470a4c77440d6913160d53dc569c1c8ee/environment/system.red#L67)).
As for the links it seems it will be similar to pair! but with a 3rd value.
meijeru
14:23Indeed, some preparation has been done for point! but it is not yet fully implemented.
9214
14:38@meijeru it is used extensively in Parse engine, as a representation of series' positions on internal stack (see [here](https://github.com/red/red/blob/master/runtime/parse.reds#L907) for example).
>> parse/trace [a b c] [some skip] func [e m r i s][probe s yes]
[none make point! [-1 0 3] [some skip]]
[none make point! [-1 0 3] [some skip]]
[none make point! [-1 0 3] [some skip] make point! [1 -1 1] make point! [0 0 3] -1]
[none make point! [-1 0 3] [some skip] make point! [1 -1 1] make point! [0 0 3] -1]
[none make point! [-1 0 3] [some skip] make point! [1 -1 2] make point! [0 0 3] -1]
[none make point! [-1 0 3] [some skip] make point! [1 -1 2] make point! [0 0 3] -1]
[none make point! [-1 0 3] [some skip] make point! [1 -1 2] make point! [0 0 3] -1]
[none make point! [-1 0 3] [some skip] make point! [1 -1 3] make point! [0 0 3] -1]
[none make point! [-1 0 3] [some skip] make point! [1 -1 3] make point! [0 0 3] -1]
[none make point! [-1 0 3] [some skip] make point! [1 -1 3] make point! [0 0 3] -1]
[none make point! [-1 0 3] [some skip] make point! [1 -1 3] make point! [0 0 3] -1]
[none make point! [-1 0 -1] [some skip]]
[none make point! [-1 0 -1] [some skip]]
meijeru
15:36Interesting, because this is a usage of triplets which might as well have been replaced by tuples or vectors, I suppose. It is not at all a "geometric" usage as one might think to be the main application.
9214
15:44@meijeru tuples are limited to 0 - 255 range, vectors are a bit more costly memory-wise.
nedzadarek
15:44^^ I was going to say this
9214
15:47@meijeru in fact, point! datatype ID is used to mark triple!, positions! and input! "cells" ([here](https://github.com/red/red/blob/master/runtime/parse.reds#L142)), so it's not really a dedicated datatype per se, just an ad-hoc way to make these 3 structs moldable.
loziniak
17:30Hi! Is there a better way to check if preprocessor code is run by interpreter or compiler, than checking if it's run by Red or REBOL: to logic! (in system 'product)?
meijeru
17:37Would system/state/interpreted? do?
hiiamboris
17:42No system/state in REBOL.
loziniak
17:45Moreover, If I understand well, preprocessor code is not compiled during compilation, but interpreted, and result of this interpretation is compiled.
ne1uno
17:47also system/state/interpreted? not valid w/-e exactly
loziniak
17:54Now, when I think about it more, it seems clear that there can be no better way, while compilation macros are run by REBOL. And solutions are limited to REBOL's environment. REBOL certainly does not know whether it was called by Red compiler.
9214
18:13@loziniak FYI, in Red, word rebol is set to false, in R2 it's a system object.
18:15So:
print quote #either rebol [Rebol][Red]
GiuseppeChillemi
18:33I wish to pass an object from the main VID window to a child window when it is opened and have another data object as result when it is closed (something like functions). Is there a standard way to pass data structure between VID windows ?
loziniak
19:03@9214 it seems a lot better than checking system/product. Thanks.
toomasv
19:56@GiuseppeChillemi I have no idea which is standard way, but at least this is one possible way:
context [
	obj1: ar1: lay: none
	win: func [obj /local obj2 ar2][
		view/options [
			ar2: area with [text: mold body-of obj] 
			button "Back" [obj2: object load ar2/text unview] 
		][offset: lay/offset + as-pair lay/size/x -25]
		obj2
	]
	view lay: layout [
		ar1: area "[a: 1 b: 2]"
		button "Win" [
			obj1: win object load ar1/text 
			ar1/text: mold body-of obj1
		]
	]
]
GiuseppeChillemi
20:24So you are wrapping inside a function, passing data as arguments(objects) and using function return value to give back the result. Also, you auto execute code at context setup.
20:24Thanks
20:25@toomasv just a note: if I close the child window via upper left X button I get this error

*** Script Error: reflect does not allow none! for its value argument
*** Where: reflect
*** Stack: do-file context view do-events do-actor do-safe body-of
20:29*upper right

toomasv
03:12@GiuseppeChillemi Just add on-close actor to layout in win:
...
        view/options [
            on-close [obj2: object load ar2/text]
            ar2: area...

if you want to keep last edit from secondary view, or use attempt in button of primary window if you don't want.
ralfwenske
06:35Could someone please help me understand what’s happening in this (simplified) function:
Red []
f: function [val width][
  either none? val [v: "*"][v: val]
  either (width < 0) [
    return pad/left v (0 - width)
  ][
    return pad v width
  ]
]
x: none
print [f 12345.678 12 "-"]
print [f 12345.6789 -12 "-"]
print [f "*" -12 "-"]
print [f "*" 12 "-"]
print [f x 12 "-"]
print [f x -12 "-"]
print [f x 12 "-"]

results in:
12345.678    -
  12345.6789 -
           * -
*            -
*            -
*            -
*            -

shouldn’t print [f none -12 "-"] also result as
* -

?
06:41btw. if I do
06:42
x: none
print [f 12345.678 12 "-"]
print [f 12345.6789 -12 "-"]
print [f "*" -12 "-"]
print [f "*" 12 "-"]
print [f x -12 "-"]
print [f x 12 "-"]
print [f x -12 "-"]

I get :
12345.678    -
  12345.6789 -
           * -
*            -
           * -
           * -
           * -
toomasv
07:02@ralfwenske
either none? val [v: copy "*"][v: val]

Or use v: #"*" instead of v: "*".
ralfwenske
07:15Thanks @toomasv that was it. Still a bit puzzled: why don’t I need v: copy valalso?
toomasv
07:16@ralfwenske Because scalars can't be copied:
>> copy 1
*** Script Error: copy does not allow integer! for its value argument
*** Where: copy
ralfwenske
07:22I guess for me the tricky bit is to keep a sharp eye on what it is that I am assigning (reread the docu) :)
toomasv
07:30:smile: You can also debug your code, e.g.:
f: function [val width][
  either none? val [v: "*"][v: val]
  probe mold v   ;<--------------------- debug
  either (width < 0) [
    return pad/left v (0 - width)
  ][
    return pad v width
  ]
]
x: none

That's what did :wink:
ralfwenske
07:36@toomasv Great help! Thank you. I keep forgetting about mould - hopefully now not any more...
toomasv
07:42@ralfwenske You are welcome!
nedzadarek
08:25@toomasv @ralfwenske
You can just prin/print molded value.
PS. as fair I remember some values might not be converted by mold if that is your case - just use probe **without** molding it first.

rebolek
08:48@nedzadarek probe is just print mold, see source
nedzadarek
09:40@rebolek yes, you are right. Silly error.
However it may change in the future. I mean there is /all not yet implemented and I heard about /binary (It was long time ago so take it with a grain of salt).
lepinekong_twitter
16:31@greggirwin I didn't ignore you I hadn't come to red, I have stopped to touch it until I see evolution on web, async, parallelism and scalability :)
greggirwin
18:37Thanks for letting me know @lepinekong_twitter.
18:45@GiuseppeChillemi there is no standard pattern in place for this. @rgchris and I developed some for R2 and Rebol/IOS many years ago, and we can draft some notes about different ways to do it. Once you get into nested objects, and a mix of modal and modeless dialogs or interactions, as well as possible async updates from network calls or IPC, you want a good general purpose wrapper over a pattern in place, and we'll provide one at some point.
GiuseppeChillemi
20:03@greggirwin Go for it. I am working on creating a gui which open a table and give back the row data you have selected. Actually it works with offline tables but later I'll need to look up directly in a database table and then check for if the data is still valid when the user will save the data. Not an easy task. everything is aggravated from the fact the GUI is build dinamically on the destination table name and (later) specs. So, the GUI builds up on this data and any table you provide could be viewed or modified without touching the code.
20:05I am to the point were the table build up from any columns name you provide and you can edit them in a separate window but no look up possible.
I am working on REBOL and VID Extension Kit but later I'll port it on RED.
20:06I admit it is not an easy task but it is very funny and engaging.
20:08The most difficult part is building it dynamically so you have to think to the destination code while editing the one that will generate it without first trying !
20:08I could define it ... very formative.
20:23I admit also I would have had access to REbol/Ios to study it. It attracts me a lot. Hope one day I could !

GiuseppeChillemi
23:19Is there a way to express a path with horizontal searches ? I mean:

data-sources: [source-id "SERVER01" [
	table-name "NAMES" ["John Doe" "Sarah Ferguson"] 
	table-name "LOCATIONS" ["Pasadena" "San Francisco"]]
]


data-sources/source-id="server01"/table-name="LOCATIONS"/1
23:24It would also be nice to express:

data-sources/source-id=(server-name)/table-name=(table-name)/1


rebolek
04:40If you leave source-id and table-name out, you can easily write it.
toomasv
05:03@GiuseppeChillemi @rebolek There seems to be a problem (at least on W10) -- it seems that two consecutive strings do not work as expected in path:
data-sources: ["SERVER01" [
    "NAMES" ["John Doe" "Sarah Ferguson"] 
    "LOCATIONS" ["Pasadena" "San Francisco"]]
]
data-sources/("SERVER01")/("LOCATIONS")/1
;*** Script Error: path data-sources/("SERVER01")/("LOCATIONS")/1 is not valid for none! type

data-sources/("SERVER01")/("LOCATIONS")
;== none

data-sources: ["SERVER01" [
    NAMES ["John Doe" "Sarah Ferguson"] 
    LOCATIONS ["Pasadena" "San Francisco"]]
]
data-sources/("SERVER01")/LOCATIONS/1
;== "Pasadena"

But when strings are not consecutive, there can be more:
a: ["b" [c ["d" 1]]]
a/("b")/c/("d")
;== 1
GiuseppeChillemi
05:33@toomasv @rebolek I already make heavy use of data-sources/("SERVER01")/("LOCATIONS")/1 syntax. I wrote about it on purpose.
05:34@toomasv Interesting discovery, I suppose it is a bug.
nedzadarek
08:35@toomasv only with the parens - get-syntax works fine
hiiamboris
08:46Same on W7
nedzadarek
08:48so w7 + w8.1 (mine) + w10
toomasv
09:46https://github.com/red/red/issues/3845
09:50@nedzadarek What did you mean with "get-syntax works fine"?
09:52@GiuseppeChillemi

>> I already make heavy use of data-sources/("SERVER01")/("LOCATIONS")/1 syntax

So it works for you? On which platform?
GiuseppeChillemi
10:41@toomasv , I meant I make heavy use of the notation KEY/(KEY)/(KEY)/ITEM...
toomasv
nedzadarek
11:06@toomasv
data-sources: ["SERVER01" [
        "NAMES" ["John Doe" "Sarah Ferguson"] 
        "LOCATIONS" ["Pasadena" "San Francisco"]]
    ]
  data-sources/("SERVER01")/("LOCATIONS")/1
; *** Script Error: path data-sources/("SERVER01")/("LOCATIONS")/1 is not valid for none! type
; *** Where: catch
; *** Stack:  

  s1: "SERVER01"  s2: "LOCATIONS"
  data-sources/("SERVER01")/:s2/1
; "Pasadena"
  data-sources/:s1/:s2/1
; "Pasadena"

It seems that is more complicated:
data-sources/:s1/("LOCATIONS")/1
; *** Script Error: path data-sources/:s1/("LOCATIONS")/1 is not valid for none! type
; *** Where: catch
; *** Stack:
meijeru
11:26Definitely a bug.
9214
11:32...
>> /: make op! func [data key][do compose [(pick [pick select] integer? key) data key]]
== make op! [[data key]]
>> ["a" ["b" [c d] "e" [f g]]] / "a" / "b" / 1
== c
meijeru
13:33So you lose division ?!
endo64
13:39~ or -> could be used.
nedzadarek
13:45@meijeru op! division, but yes
14:40@endo64 I'm using | character instead of /.
giesse
18:09Why not ., it's what most languages use anyway.
rebolek
18:11The problem with . is that I'm not sure if it's dot or some dust.

nedzadarek
08:56What's the difference between action! and native!?
meijeru
09:47@nedzadarek From the spec document:
native! pre-defined functions with built-in evaluation according to special rules

action! pre-defined polymorphic functions of one or more arguments with built-in evaluation

Natives are not polymorphic, and their arguments may be selectively evaluated (think of either). Actions are polymorphic, i.e. they are in general defined for several types of arguments, and they always evaluate their arguments before being applied.
mikeparr
15:28I'm trying to convert a binary! to a string! Should I expect it to work?
>> b: #{AABB}
== #{AABB}
>> to string! b
*** Access Error: invalid UTF-8 encoding: #{AABB0000}
*** Where: to
*** Stack:

9214
15:41@mikeparr no, and error message indicates why. Perhaps what you want to use is form.
toomasv
16:05@mikeparr
form will include #{..} like mold. You may want enbase:
enbase/base #{AABB} 16
== "AABB"
mikeparr
16:10Thanks @9214 , @toomasv re binary.
giesse
18:31@nedzadarek it's mostly an implementation detail; basically actions are dispatched on the type of the first argument, while natives are just functions written in native code. Ie. from your point of view there's no difference.

If you had custom datatypes, then you would probably care about the difference.

nedzadarek
11:01@meijeru isn't native! like lesser?polymorphic? I mean you can compare any-type! e.g. a float! and an integer! or two string! s. As for [wiki](https://en.wikipedia.org/wiki/Polymorphism_(computer_science)):

> polymorphism is the provision of a single interface to entities of different types[1] or the use of a single symbol to represent multiple different types

in particular case of subtyping:

> Subtyping (also called subtype polymorphism or inclusion polymorphism): when a name denotes instances of many different classes related by some common superclass

or is it implementation detail (like @giesse said) that we cannot easily see/understand?

> and their arguments may be selectively evaluated (think of either)

So it's not possible to make an action! with selective evaluations or is just by convention (I guess 2nd one)?

> Actions ... they always evaluate their arguments before being applied.

What do you mean by "evaluation"? Can you show me some examples?

@giesse I see. Thank you.
11:02So I guess lots of people would not care about this distinction in a documentation. However it is still important for some. It is good to know.
rebolek
11:02 @nedzadarek
a: 1
a + 2 ;  <-- a is evaluated to 1 here
nedzadarek
11:06@rebolek so, in other words, action!s does not use (they cannot or it is prohibited) get-/lit- syntax in a specification of a function(:a in f: func [:a][] is a get-syntax)?
rebolek
11:11Why? Just try it:
>> f: func [:a :b][print [a b]]
== func [:a :b][print [a b]]
>> o: make op! :f
== make op! [[:a :b]]
>> 3 o 2
3 2
>> o o f
o f
meijeru
11:18@nedzadarek None of the currently defined action!s have lit- or get-word arguments, and the user cannot make new action!s -- only op!s.
nedzadarek
11:23@rebolek I don't mean op! but native! vs action! - I cannot easily try it (not enough knowledge).
meijeru
11:25@nedzadarek I stand corrected, some native!s are polymorphic. It is perhaps somewhat arbitrary to classify some built-ins as native! and some as action! but there are several characteristics: all action!s evaluate their arguments, whereas some native!s do selective evaluation. Also, some native!s have lit-word arguments (e.g. foreach) whereas, as stated above, no actions!s have that.
11:28Perhaps @dockimbel can shine some light on the design choices involved here.
rebolek
11:29@nedzadarek I see, sorry.
9214
11:46native!s are functions written in R/S for performance, simplicity or feasibility reasons. action!s are a a standardized set of native!s that each datatype implements (or inherits) as its "method". action!s typically dispatch on their first argument.
>> append [1] "2"
== [1 "2"]
>> append "1" [2]
== "12"
>> 1% + 2
== 201%
>> 2 + 1%
== 2.01

Obviously, datatype doesn't implement or inherits all action!s - this is where difference between scalar! and series! arises, for example.
meijeru
17:02Internally, there is a table for dispatching actions based on the combination "action number" and "datatype number (of first argument)". There are the notions of "parent type" and "inheritance" involved. From the spec document:
4.2.6. Parent types
The notion of parent type arises in the implementation of actions, i.e. pre-defined polymorphic functions of up to two arguments with built-in evaluation, e.g. add, subtract, copy, find, etc. The implementation uses a dispatch table which contains a pointer to a specific run-time function for each allowed combination of action and type of first argument. These functions are grouped by the type to which they apply. Now for any action/type combination, such function may be designated as inherited from the parent type, and in this way two or more types may share the same implementation for that action.
giesse
18:00@nedzadarek lesser? might dispatch on *both* arguments (though, I suspect it's simply a big switch kind of thing - I haven't looked); action! is a standardized mechanism to dispatch on the first argument; or, perhaps, at the highest level the best description is what @9214 said, they are what you would call "datatype methods".

Said another way, each datatype defines actions that supports; so the actions come from the datatype; natives are logically separate from datatypes; so, if you add new datatypes, you will implement their actions like mold or insert and so on.
18:01insert series value would be written series.insert(value) in many other languages. So the difference between action! and native! is the same difference between method and function in other languages.
9214
18:02And the minimum set of required action!s to implement is mold with make IIRC.
greggirwin
20:41The action! design and choice is a balance, and one that informs the structure of the code. For efficiency, actions use a fixed dispatch table. That means the set of actions is locked and not easily extended. So actions were chosen carefully, and based on what we learned from Rebol. What @meijeru said also applies, as actions can be inherited in the type hierarchy. It also means that adding new datatypes lets authors focus on just their type, and not have to worry about all the native functions. If natives or mezzanines need to be updated to support new types, that's a separate step. But adding new types should never break them. It doesn't mean a typeset or behavior problem is impossible to create. Just that it's harder to make those mistakes.
phillvancejr
20:52Hi all, I am compiling my first small test programs with Red. I notice on my machine MacOS High Sierra, compilation is somewhat slow. Context, I'm comparing it to C & C++ compilation speed. Is there something I can do to speed up the compilation, or is this just how fast Red's compiler works?
greggirwin
20:54If you don't use -r for release compilation, the runtime won't be recompiled each time, and builds should be fast. Red's compiler is written in Rebol, and is not optimized for speed.
20:55We also don't have modular compilation yet, which will make things faster in general, once we do.
phillvancejr
20:55ok, thank you very much @greggirwin for your help
schwarzbox
21:48I am still very exiting to play with Red live-coding features. Now I can paint images (save, rotate, use picker tool, fill surface, undo with 64 steps) and put them in the project :-)
I prepare small example (basic "asteroids" game)
![alt](https://raw.githubusercontent.com/schwarzbox/EmptyCore/master/screenshot/screenshot1.png)
[EmptyCore v0.39](https://github.com/schwarzbox/EmptyCore)


greggirwin
22:31Nice @schwarzbox !
gltewalt
22:33Like actions are interfaces and datatypes are classes?

GalenIvanov
06:22@schwarzbox Very nice!
nedzadarek
08:52@schwarzbox I cannot make it work. It shows the window but I do not see preview. Do I have to click something? I click Code/Run and nothing happens.
It looks like some kind of 2D game engine.
ps. make it resizeable.
08:59@meijeru @9214 @giesse @greggirwin Thank you for the informations.
@rebolek No problem.
schwarzbox
09:54@nedzadarek It is live-coding IDE (toy-version) and first you select file to run or type your own code. As default program run code when you type something in Code window or you can press Code/Run or (Cmd-B in Mac).
After you can see result in View window or in console part of Code window.
09:55@GalenIvanov @greggirwin :-) Next time show when reach v1.0. Thank you.
10:00How can I sent a bug report?
rebolek
10:00@schwarzbox press [New Issue] button [here](https://github.com/red/red/issues)
nedzadarek
12:32@schwarzbox I can copy-paste code (e.g. from ship.red) and it shows something but I cannot move (code without the IDE is the same). However when I click ship.red on the left list nothing happens.
loziniak
15:58Hi! Is there a possibility to embed resources (images, fonts) to use in application?
15:59Also - is there a possibility to load font from file, instead being limited to fonts installed in operating system?
9214
16:01@loziniak images (and any other values) - yes, fonts - no.
rebolek
20:34Well, it *can* be done, but not in user friendly way.
loziniak
22:12@rebolek, you mean embedding fonts or loading them from file?

rebolek
05:11You need to write your own font displaying engine, that's what's not friendly. It's not that hard with bitmap font, but still much harder than using standard text.
loziniak
07:01Or perhaps use some external library. So, probably this is not going to be a feature of Red with it's 100% library independency. Thanks for clarifying!
phillvancejr
15:48has anyone had success with the view modal flag on MacOS? It doesn't seem to affect my window. Or maybe I don't understand it, I was hoping it would make my window always topmost
dockimbel
18:42@phillvancejr Please fill a ticket if it's not working on macOS (after confirmation by a Mac user, my macOS is upgrading to 10.14 right now, so can't test it).
greggirwin
19:50Modality should be application modal, not system modal, and is different than a topmost setting. We don't have a flag for that yet (HWND_TOPMOST for use with the SetWindowPos API on Windows). I don't know the equivalent on MacOS, but it's easy to do on Windows.

dockimbel
10:45@hiiamboris
> Why do we have every actor accepting a face argument instead of referencing it by self? Can't actors object be rebound to the face?

So you can share same actors for similar faces.
hiiamboris
10:47But they seem to be copied during face creation, @dockimbel
dockimbel
10:52@meijeru
> @nedzadarek I stand corrected, some native!s are polymorphic. It is perhaps somewhat arbitrary to classify some built-ins as native! and some as action! but there are several characteristics: all action!s evaluate their arguments, whereas some native!s do selective evaluation. Also, some native!s have lit-word arguments (e.g. foreach) whereas, as stated above, no actions!s have that.

Actions are datatypes "methods", in the internal OO model. They define datatypes behaviors. Natives are external functions implemented in low-level, for sake of performance or convenience (e.g. when accessing OS API). The frontier can be very thin sometimes, so some natives could be eligible to become actions, though, that comes with a price (memory overhead for the internal virtual tables).
10:54@Oldes
> And second issue is, that if there is not standard output open (as in case of GUI console and other view only apps), the application should not crash when its red/system code calls some of print* functions.

Is there a ticket opened for that?
GiuseppeChillemi
12:48
It is meant for recursive calling the window itself and passing and receiving an argument text.
The very first round has no paramaters, so the reason for wrapping an empty function around a second one.
On the second round, the layout AR1 label is not set and I do not undestand the reason

window1: func [/local start-gui] [
		start-gui: func [area-text /local ar1 lay obj1]
		[
			prin ["Area text "] probe area-text probe type? area-text
    	lay: layout [
      	ar1: area area-text ;<--- AR1 is UNSET starting from second round
       	button "close" [unview]
		  	button "Child" [
		  		probe obj1-type: type?
		  		print ["AR1: "] probe ar1/text 
		  		either ar1/text = none! [obj1: ar1/text] [obj1: "a: {nix}"] 

		  		start-gui obj1
		  	]
    	]
    	view lay
  	]

	  start-gui "a: 1 b: 2"
]

window1

>
12:56(note: I have just modified the code removing the outher context)
hiiamboris
13:10@GiuseppeChillemi you're outputting type? print ... (which is unset!) and comparing a none value to none! type (which is always false)
gurzgri
13:12@hiiamboris At least actors can be reused w/o copying, too:
action: func [f e] [print f/text]
view [
    a: button "a" on-click :action
    b: button "b" on-click :action
    c: button "check" [probe same? get in a/actors 'on-click get in b/actors 'on-click]
]

toomasv
13:15@GiuseppeChillemi Also, not sure what do you think this line should do:
either ar1/text = none! [obj1: ar1/text] [obj1: "a: {nix}"]

May be you meant empty? ar1/text as a condition.

In current form the condition will never be true, but with empty? it will be true when you empty the line. But I'm not sure you meant this.
GiuseppeChillemi
13:28@gurzgri @hiiamboris Thanks, working on it, be back soon
13:59I was trying to pass some data back on forth in a recursive window having set-words and faces names isolated between windows (I do not know if it is the default working)

This is the current final form.

What you think about it ?

window1: func [/local start-gui] [
			idx: 0

			start-gui: func [area-text /local ar1 lay obj1 return-value]
			[
				idx: idx + 1
				
		  	lay: layout [
		    	AR1: area area-text
		     	button "close" [unview]
			  	button "Child" [
;			  		print ["AR1: ------------->>>>>>> "] probe ar1/text 
			  		either not empty? ar1/text [obj1: ar1/text] [obj1: "a: {nix}"]
				  	print ["current level: " idx]
				  	print ["passing: " {"} obj1 {"} "to level: " idx + 1]
			  		return-value: start-gui obj1
			  		idx: idx - 1
						Print ["data returned from level: " idx + 1 {"} return-value {"} "current level: " idx]			  		
			  	]
		  	]
		  	view lay
		  	ar1/text
			]
  probe start-gui "Some content"
]

window1

14:00Do you see any problem from you expert view ?
toomasv
14:36Seems to do what you want.
GiuseppeChillemi
15:05@toomasv I am building from the startup-code you have kindly created.
I suppose AR1: area area-textis globally visible if not defined as local in start-gui: func [area-text /local ar1 lay obj1 return-value]. I inferred it from the way you used AR1 in your code. Have I interpreted it correctly ?
toomasv
17:33@GiuseppeChillemi Only idx is globally visible of the words you provide. All others are locally bound in functions. But yes, if you don't define it as local, it will be global (unless you change func into function).
GiuseppeChillemi
19:17@toomasv so, could I affirm that any word definition inside a layout is bound to the global context until you define it inside a function or declare it /local in a func ?
greggirwin
19:32@GiuseppeChillemi, yes, which you can try for yourself.
view [button [a: 1]] ; click the button
a
;== 1
GiuseppeChillemi
20:36@greggirwin Thanks Gregg. I have tried:

view [btn: button "click me" [a: 1 unview]] probe a probe btn

btn is set on unview too. I thougth it would become unset.
20:38So the tecnique to avoid VID words going to the global context is wrapping them with a function/context... a usual.
20:39Preoviously I thought they where LOCAL to the VID view for isolation reason.
20:44@greggirwin Please note that my questions are aimed to find the general rules, the exceptions and the inner workings which only pros/language authors know.
Writing "could I affirm that **any** word definition" means: "is there **ANY** exception or specifing working that changes the general rules ?"
20:46(Just like paths with numeric selector REDUCES the picked item too...)
toomasv
22:40@GiuseppeChillemi As you might guess, Red is not a straight-jacket, there is usually a way to twist things. In current case, take bind into account.
endo64
22:54> So the tecnique to avoid VID words going to the global context is wrapping them with a function/context.

@GiuseppeChillemi I use use function I define as below for keeping words local . It exists in R2 and R3 but not in Red yet.
use: func [locals blk] [do reduce [func compose [/local (locals)] blk]]
use [a b] [a: 1 view [b: button]]
; a == ** Script Error: a has no value
; b == ** Script Error: b has no value
22:59Another similar function I use, to keep all words local:
localize: func [blk] [do reduce [function [] blk]]

>> localize [x: 1] x
*** Script Error: x has no value
22:59I know it's a terrible name localize.

GiuseppeChillemi
08:11@endo64 I like it a lot
08:11I have added those functions to my library of tools
08:22Your example had also a side effect. It confirmed my theory that visual aspect of something could you take to a wrong path when this aspect belongs to another othe you use and recall very often...

func [a b] [... some code]
use [a b] [a: 1 view [b: button]]

Doesn't the second appear to be a function definition to you ? Instead they are 2 arguments.
At first I had a problem undertanding your code because the aspect interferred activating the concept of "function definition". This lead to having 2 mind paths active and when I try to think on your code the other concept kicks in !
Oldes
10:11> @Oldes
> > And second issue is, that if there is not standard output open (as in case of GUI console and other view only apps), the application should not crash when its red/system code calls some of print* functions.
>
> Is there a ticket opened for that?

@dockimbel I just tried it with the current sources and it looks the print works now (at least from routine)
10:13I will try it with red/system
10:28Still crashes.. it is possible to reproduce on the SQLite binding from the red-code repository... when including the %sqlite.red file in gui-console and calling sqlite/init
10:29The reason is, that there is internal print-line call in the sqlite.reds
10:30I don't know if there is ticket for it.
11:11@dockimbel Ok... so the problem is, when the print-line is used with block! as an argument. One can test including this piece of code inside gui-console.red file and compile it in release mode:
test: context [
	foo: routine[][
		print-line "hello" ;<--- this one is always fine
		print-line ["--> " 1] ;<--- this crashes in GUI console but not with CLI
	]
]
11:16here is the ticket: https://github.com/red/red/issues/3857
rcqls
12:14@Oldes Never see print-line with a block in Red/System. In such a case, lf is used inside a block.
Oldes
12:22@rcqls I don't know what you mean... apparently I was using print-line with a block in my bindings quite a lot mostly for debug messages (as I prefer CLI version, where it's fine). But if you want, you can reproduce the issue with simple print as well.
rcqls
12:27@Oldes Sorry, I should do grep -R ‘print-line \[‘ red/* before answering and indeed print-line followed by a block exist in the red repo for red/system files… But I naturally never use print-line [….] since I always use print […. lf] instead.

phillvancejr
14:05Hi all. I'm having trouble with drop-down. selected is always returning none even when I have something selected.
14:09I got around it just using drop-down/text. But I thought selected would return the index of the selected item
9214
14:09@phillvancejr does this work for you?
view [drop-down data ["a" "b" "c"] on-change [probe face/selected]]
phillvancejr
14:36The above solution works to get the data. I'm having a problem using two drop-downs. For some reason when I update drop-down2, drop-down1 is being updated and supplied with the data from drop-down2, they are connected for some reason
9214
14:38@phillvancejr can you give me a minimal example?
14:41
text
view [style d: drop-down data ["a" "b" "c"] on-change [probe face/selected] below d d]
phillvancejr
14:53@9214 thanks a alot for your help! turns out it was a very silly mistake. I used the variables year and short-year ( "2019" and "19") as my default for the drop-downs. However I had foolishly defined short-year like this. short-year: skip tail year -2 ...linking it to the year variable.
14:54Silly mistake, thanks a lot for helping!
9214
14:54@phillvancejr no problem. Looks like you have some [additional reading](https://github.com/red/red/wiki/%5BDOC%5D-Why-you-have-to-copy-series-values) to do :wink:
gltewalt
21:12Is this an issue? I expected #{2A} to change.

Expected.
>> loop 10 [print random #{2A000000}]
#{0000002A}
#{00002A00}
#{002A0000}
#{00002A00}
#{00002A00}
#{00002A00}
#{0000002A}
#{00002A00}
#{0000002A}
#{00002A00}


Unexpected.
>> loop 10 [print random #{2A}]
#{2A}
#{2A}
#{2A}
#{2A}
#{2A}
#{2A}
#{2A}
#{2A}
#{2A}
#{2A}
9214
21:19@gltewalt to change to what? Shuffling 1-element series will give you the same series no matter how hard you try.
gltewalt
21:23lol, oh that's right, length is 1
21:25Shuffling series, not returning random value of the same type
21:31Is this literally pick?
/only => Pick a random value from a series.

nedzadarek
11:41@gltewalt like this:
arr: [a b c d e f]
; [a b c d e f]
  pick arr (random length? arr)
; a
  pick arr (random length? arr)
; e

?
> I expected #{2A} to change.

I guess the name is little misleading. However it is noted in the [documentation](https://doc.red-lang.org/en/datatypes/binary.html#_abstract):

> A binary! value represents a series of bytes.
9214
12:15@gltewalt not literally, but the idea is the same: pick [adds offset](https://github.com/red/red/blob/master/runtime/datatypes/series.reds#L333) that you gave it to head pointer, random/only [calculates](https://github.com/red/red/blob/master/runtime/datatypes/series.reds#L121) it using RNG and sizes of series and its unit.

gltewalt
14:20I see. And the other difference is Binary falls under the default clause for random/only, returning char. It has a specific clause for pick
14:21Returns integer
9214
14:33@gltewalt returning char! looks like a bug, Rebol returns integer! in 0 - 255 range, as expected.
gltewalt
14:35Wasn’t sure because I hadn’t checked Rebol yet, or asked if it was a design decision
9214
14:35Yeah, it just [falls down to default clause](https://github.com/red/red/blob/master/runtime/datatypes/series.reds#L122) without checking for binary! type.
phillvancejr
15:58Hi guys. Is there a way to execute some binary that is included in a Red file? For example if I use a macro to load in an executable at compile time, can I somehow call this code from within Red? Can this code be put into a function or something to run?
9214
16:20@phillvancejr that depends on how machine code in your embedded executable is organized. Much more simple (and safer) approach is to use dynamic libraries or call executable at runtime.
phillvancejr
16:33Ah I see, thank you
19:59Hello....sorry for all of my questions. I'm trying to copy the libRed test shown on the red website. I built libRed but when I try to compile my C file, i'm getting the error that the file was built for i1386 which is not the architecture being linked. I'm on MacOs
9214
20:09@phillvancejr can you show me how you build libRed and how you link to it?
phillvancejr
20:14I built with red build libRed
20:14to link i did g++ test.c -lRed -L.
greggirwin
20:35@gltewalt or @9214 please open a ticket on the binary/char/random bug.
9214
20:36@phillvancejr bear in mind that libRed is 32-bit, and that you should supply additional flags to compiler / linker (-m32 IIRC) on 64-bit system.
20:55@greggirwin https://github.com/red/red/issues/3859

phillvancejr
10:13@9214 that worked, I got it to compile. But when I run I get "Runtime Error 1: access violation"
9214
10:14@phillvancejr hard to say anything without seeing the code.
phillvancejr
10:17#include "libRed/red.h" int main() { redOpen(); redDo("view [text {Hello World!}]"); redClose(); return 0; }
10:17Here is the code I tried
10:17compile with g++ red.c -lRed -L. -m32
rebolek
10:18what OS are you on?
phillvancejr
10:18Before I was using -w to ignore warnings but this time I turned that off and got this warning: 'ld: warnign: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)'
10:18MacOs High Sierra
9214
10:30I cannot reproduce the crash on Mint, although I used redDo("print 1 + 2").
phillvancejr
15:02could it be that red build is just not building for the appropriate architecture? Maybe I just need to try on another OS
rcqls
15:05@phillvancejr Did you first try the minimal example redDo("print 1 + 2 ") as mentionned by @9214 ?
9214
15:23@phillvancejr you can check it with otool or objdump.
$ objdump -f ./libRed.so

./libRed.so:     file format elf32-i386
architecture: i386, flags 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
start address 0x00000000
rcqls
16:14@phillvancejr @9214 I give a try on macOS and *** Runtime Error 1: access violation from now on any example.
9214
16:15@rcqls thanks, worth a ticket I guess.
rcqls
16:16@9214 I’ll try later some further tests… this one is really quick...
phillvancejr
18:08@rcqls yes, I got the same error

Palaing
07:34Can't understand why this works:
>> word! = type? 'truc
== true

but not this:
>> switch type? 'truc [word! [print "ok"]]
== none
dander
08:01@Palaing type? 'truc returns a datatype, but word! (unevaluated) is word which refers to that type
>> switch type?/word 'truc [word! [print "ok"]]
ok
>> switch type? 'truc reduce [word! [print "ok"]]
ok
Palaing
10:05@dander Thank you! I wish I was clever enough to find that :)
greggirwin
17:18@Palaing it's an artifact of some types having a molded form (their textual representation) that doesn't provide internal details about a value.
17:20Also part of understanding and learning when evaluation occurs, which is one of the big differences people need to get used to when moving to Red.
17:21Ironically, as I read my prosaic answers, they are less helpful than @dander's. :^)
dander
18:21@Palaing @greggirwin I wish I could say it was cleverness. I had an inkling about it from a previous discussion about it from before, but I had to find the actual discussion to get the answer right, and just summarized it as best I could.
Gregg, your comment also brings up a question about the molded form... I thought all Red values are anonymous. So how does mold know that the word word! refers to the word! datatype?
9214
18:24@dander by datatype ID. Each datatype implements its own mold action.
dander
18:29@9214 That seems sensible. Thanks!
GiuseppeChillemi
18:36@9214 ... and the datatype ID is assigned during the load phase, isn't it ?
phillvancejr
18:49how does one declare the data type for a variable. For example how can I set "num" to none but also have its type be integer, just for sake of readability in my code?
9214
18:52@phillvancejr I'm not even sure if what you ask for is possible in other mainstream languages, because it goes against the very definition of variable, which has three components: an identifier, a type, and an address where its value resides.
18:53Let's just say that in Red datatype of a "variable" is uniquely determined by value to which it refers.
phillvancejr
18:54I don't need it be the actual none type. But in C languages I can declare a variable and its type without initializing it like int num; But if I use num: [integer!] num is of course of type datatype rather than of type integer
18:56actually in this case it would be of type block, if i use the raw datatype like num: integer! it is of type data type. I can just use a comment if that is all we have. But It would be nice if I could just declare it so that when I type help myobject I can get the correct datatype even if it has no initial value
9214
18:56I see. Well, Red works very different from C, and there're no variables (in a usual sense of the term) and no variable declarations.
phillvancejr
18:57I new it would not be like C, I was just checking if we had some alternative. Comments will have to do, thanks again for your help!
9214
18:58You just use one value (word!) as an indirect "pointer" to another value (none! or integer! in your case).
18:58And if you don't explicitly "point" word! value to anything, it still points to a "default" value of type unset!.
18:59So you can't "point" it to none! value and say "point to none but report it as an integer!".
greggirwin
19:06@phillvancejr in Red/System it works like C and other statically typed languages. In Red, *values* are strongly typed, but words used as variable are not. That is, they can refer to any value.
phillvancejr
19:06I knew it wouldn't work with the actual none! type. I was hoping it would be something like Go where each value is initialized to its datatype's respective none value if not explicitly set
19:06Ah ok, awesome! thanks @greggirwin! I haven't gone through the Red/System documentation yet
9214
19:07@phillvancejr so, to rephrase, you want to initialize "variable" with some default value (e.g. none!) and then change its value to, say, integer!?
phillvancejr
19:11I don't necessarily want to initialize it. when I say none, I mean some representation of no initialized value ( like NULL ) not necessarily the Red type none!. I just figured out a ghetto solution other than comments is to go ahead and assign the variable the type I want it to be so that when I probe person it at least lists the type. Then I'll just set it to the appropriate type when I create the object
greggirwin
19:11It's an important distinction because variables in statically typed languages allocate memory to store their values. In Red words *refer to* values in a given context.
19:13@phillvancejr adding clues that way is fine, just be aware that it doesn't provide any real protection, and you'll probably find other ways to achieve your goal as you get more familiar with Red.
phillvancejr
19:15for sure. In this instance I don't need it to actually type check anything. I just want to annotate the code so that if I take a break from the project I can come back to it and figure out what I was doing easier. When i want to check the types when creating objects, I just use a factory function
nedzadarek
20:13@phillvancejr you could break your code into objects or smaller functions.
o: object [
    s: make string! 100
    i: 0 
    t: make tag! []
    ]

append-n-times: func [str [string!] n [integer!] what [string!]][
    repeat i n [append str what]
    ]
  append-n-times "foo" 10 "*"
; "foo**********"
GiuseppeChillemi
21:04@greggirwin and how is called the list of all words that have values in a context?
21:05*value
greggirwin
21:37words-of.
GiuseppeChillemi
22:03@greggirwin I mean something like "vocabulary", "word list"...
greggirwin
22:04"words of" then. :^)
GiuseppeChillemi
22:09LOL :)
nedzadarek
23:17@GiuseppeChillemi if you insist (buggy):
>> of: make op! func ['word obj] [probe word if word = 'words [words-of get obj]]
== make op! [['word obj]]
>> words of o
words
== [a]
>> ?? o
o: 
make object! [
    a: 1]

giesse
05:23@nedzadarek if you're going that way, then
>> of: make op! func ['word value] [reflect get value word]
== make op! [['word value]]
>> words of system
== [version build words platform catalog state modules codecs schemes ports locale options script standard lexer console view reactivity]
05:24though, isn't it a bug that the second argument is also passed as a word?
toomasv
06:56@giesse It's a known bug.

Musings on of:
of: make op! function ['word 'value] [
    either any [
        attempt [out: reflect get value word] 
        attempt [out: reflect value word] 
        attempt [
            type!: get to-word head change back tail to-string word #"!" 
            out: parse value compose/deep [
                collect any [keep (type!) | skip]
            ]
        ]
    ][out][
        cause-error 'user 'message ["Bad arguments!"]
    ]
]
;== make op! [['word 'value /local out type!]]
words of system
;== [version build words platform catalog state modules codecs schemes ports locale ;options script standard lexer console view reactivity]
body of collect
;== [
;    keep: func [v /only] [either only [append/only collected v] [append collected v] v] 
;    unless collected [collected: make block! 16] 
;    parse body rule: [
;  ...
spec of find
;== [{Returns the series where a value is found, or NONE} 
;    series [series! bitset! typeset! any-object! map! none!] 
;    value [any-type!] 
;    /part "Limit the lengt...
values of #(a 1 b 2 c: 3.0)
;== [1 2 3.0]
words of [a 1 b 2 c: 3.0]
;== [a b]
set-words of [a 1 b 2 c: 3.0]
;== [c:]
integers of [a 1 b 2 c: 3.0]
;== [1 2]
spec of [a 1 b 2 c: 3.0]
;*** User Error: "Bad arguments!"
07:54Improved:
of: make op! function ['word 'value] [
    either any [
        attempt [out: reflect get value word] 
        attempt [out: reflect value word] 
        attempt [
            type!: get to-word head change back tail to-string word #"!" 
            rule: compose/deep [collect any [keep (type!) | skip]] 
            out: parse value rule
        ] 
        attempt [out: parse get value rule]
    ][out][
        cause-error 'user 'message ["Bad arguments!"]
    ]
]
nedzadarek
09:26@giesse It was just to show general syntax (word (without ') + of + value). I haven't made it safe nor implemented all X-of. Yes, something like reflect can be good - if reflect will add something, then it will be "automatically implemented". We can go deeper with other values, like @toomasv has done ( :clap: )
09:44@toomasv
ps. I don't what you are doing with the type! so, for simplicity, I added another attempt. We can add support for typeset!s as well :
of: make op! function ['word 'value] [
        either any [
            attempt [out: reflect get value word] 
            attempt [out: reflect value word] 
            attempt [
                if all [
                    typeset? t: get word
                    block? value 
                ][
                    out: parse value [collect any [keep t | skip]]
                ]
            ]
            attempt [
                type!: get to-word head change back tail to-string word #"!" 
                rule: compose/deep [collect any [keep (type!) | skip]] 
                out: parse value rule
            ] 
            attempt [out: parse get value rule]
        ][out][
            cause-error 'user 'message ["Bad arguments!"]
        ]
    ]
; make op! [['word 'value /local out t type! rule]]
  t: make typeset! [integer! float!]
; make typeset! [integer! float!]
  t of [1 2.3 "foo" <ba> 3 4.4 <f>]
; [1 2.3 3 4.4]
toomasv
09:46@nedzadarek Did you try it first? In former (little-bit [improved](https://gist.github.com/toomasv/58451e09cb7efa9b3e2bed93484a7ae2)) version:
>> scalars of [#"a" 1 3.0 a :g 5%]
== [#"a" 1 3.0 5%]
nedzadarek
09:48@toomasv ah, sorry, I missed this.
toomasv
09:49:smile:
>> t!: make typeset! [integer! float!]
== make typeset! [integer! float!]
>> ts of [1 4.0 a <b>]
== [1 4.0]
nedzadarek
09:50@toomasv I was just going to post it. I would go with just some-type! syntax thought.
toomasv
09:56@nedzadarek Sure, why not!
fergus4
18:09I have red in my env variables path (windows 10) but when I to use it from outside red folder I get "PROGRAM ERROR: Invalid encapsulated data"
9214
18:12@fergus4 https://gitter.im/red/red?at=5cc2cf1aa4ef097471009778
greggirwin
18:40Really nice @toomasv.
toomasv
19:00I like it too :smile: Great idea from @giesse and @nedzadarek!
nedzadarek
20:50
of: make op! func [rule source] [parse source [collect any [keep rule | skip]]]
; make op! [[rule source]]
  [integer!] of [1 2.3 4 5.6 <tag>]
; [1 4]
  [float!] of [1 2.3 4 5.6 <tag>]
; [2.3 5.6]
  [float! | integer!] of [1 2.3 4 5.6 <tag>]
; [1 2.3 4 5.6]
greggirwin
21:08Clever twist.

toomasv
05:45@nedzadarek Nice! Single type can be given w/o block too:
>> integer! of [1 3.0]
== [1]

Overall: reflective power lost, parsing power increased.
05:53And reflection regained:
of: make op! func [rule source] [
    either any [object? :source map? :source any-function? :source] [
        reflect :source rule
    ][
        parse source [collect any [keep rule | skip]]
    ]
]
'words of system
;== [version build words platform catalog state modules codecs schemes ports locale options script standar...
'words of #(a 1 b 2)
;== [a b]
'spec of :collect
;== [{Collect in a new block all the values passed to KEEP function from the body block} 
    body [block!...
number! of [1 a 3.0 b]
;== [1 3.0]
06:06
digits: charset "0123456789" 
rejoin digits of "kj3245jklj34j5kl2k3j4n5234kklj"
;== "32453452345234"
pekr
07:21Would it be useful having ofoficially added to RED? But then we have those dash based -of alternatives too ....
toomasv
11:40@pekr Sounds interesting to me, let’s see what lang-designers say ...
9214
12:24@phillvancejr @rcqls could you please add some specifics to this https://github.com/red/red/issues/3860 bug report?
endo64
15:51@pekr @toomasv we can add of wish to red/rep and move the design notes there to keep, and link to gitter to keep the conversation history
9214
15:58@endo64 not until this https://github.com/red/red/issues/3344 issue is closed. Making an infix variant of reflect is one thing, but making a mish-mash of Parse, reflection and what-not is another (which I personally do not support).
greggirwin
16:14I've thought about it while sipping coffee, and read back over the chat and examples. We should absolutely keep all this chat and code somewhere, and it would make a great article.

As for making it standard, I don't think so. Certainly not without more thought. We should keep the *-of funcs, as they are good names; friendlier than reflect. Of as an op! is very cool, and shows how malleable Red is. It's very tempting and seductive. But ops make you think more about precedence during evaluation, and are either special symbols today, one of a few logic operations, or is. Is is a special case, and not something that will be part of larger, more complex expressions.

The examples above, extracting by type, are *really* a siren song. I have a collect-values function which looks crude by comparison. It raises questions itself. For blocks you can just return values. Easy. What about maps and objects? Returning the values isn't very useful. Do you just return the words, words and values as a spec block, or the same type as the original?

I also just found some old notes I made at some point:
; We can make an `of` op, but you have to use literal values for the field,
; which isn't great. If used as vars you can hide that a bit, but that won't
; always work well either. Needs more thought, or maybe a design change in
; Red, if we want a general `of` operator.
context [
	reflectors: [body class keys spec values words]
	actions: [head tail head? tail? index? length? copy form mold complement absolute]

	set 'field-of func [
		field [word!]
		value [any-type!]
		/local fn
	][
		case [
			find reflectors field [reflect :value field]
			find actions field [fn: get field  fn :value]
		]
	]

	set 'of make op! :field-of
	
]

'words of system
'spec of :append
'head? of [1 2 3]
'index? of at [1 2 3] 2
'tail? of tail [1 2 3]
16:16My collect-values func is in a gist, but I have a local version with object support as well.
addos
16:28hi, how are pointers done in red/rebol?
9214
16:30@addos there are no pointers.
addos
16:30or references?
9214
16:31I suggest to read [some documentation](https://github.com/red/red/wiki/[LINKS]-Learning-resources) first. [Rebol/Core guide](http://www.rebol.com/docs/core23/rebolcore.html) is a good start, chapter 6 in particular.
addos
16:43@9214 thanks, I will review those docs
hiiamboris
18:12@greggirwin To speed things up, I would change
reflectors: [body class keys spec values words]
find reflectors field [reflect :value field]

into
reflectors: context [body: class: keys: spec: values: words: yes]
in reflectors field [reflect :value field]
toomasv
18:31The more I think/play with it the more it seems the only advantage of of would be shortcut to simple parse [collect... as substitute for non-existing find/all.
burque505
20:14@9214: No pointers? In Red/System there are, right? [4.8 Pointer](https://static.red-lang.org/red-system-specs.html#section-4.8)
greggirwin
20:18@hiiamboris for me, that would have to be a common speed problem, and a big speed gain, because the code, to me, is not as clear.
20:19@burque505 correct. Red/System is a C level language, and has to be able to do most, if not all, you can do in C. Red is a high level language, and pointers have no place there. They are too low level.
9214
21:29@burque505 if you haven't noticed, @addos asked about Red and Rebol, not Red/System. You can emulate pointers and references with series and words though. High-level languages (such as Red) give carte blanche with regard to how you manage your abstractions, but C-level thinking is too constrictive, and rarely has a merit in anything but system programming, performance-critical tasks or bit banging.
GiuseppeChillemi
21:40@addos one of the first differences and important topic you will encounter in RED/REBOL is that words are symbols which gets connected to other elements taking a value. The connection symbol is ":".

So:

myword: "hello"

Connects the first element, which is myword, to the third element, which is"hello", giving it a value.

The whole source is a long sequence of elements (symbols/value/blocks/series) grouped by blocks [] and connected via ":" .

The system maintains a list of words(symbols) and the element they are connected to.
To understand this, please look at this code enclosed in brackets:

[
   myword: ""
   probe myword
   append myword "hello"
   probe myword
   append myword " world ! "
   probe myword
]


You connect the first element of line 1 myword to the third element which is ""
Then you are appending "hello" to the element connected (pointed) from myword, which is the third element of line 1
Then you are appending " world ! " to the same third element of line 1

If you could see it in memory after its execution it would be:

[
   myword: "hello world!"
   probe myword
   append myword "hello"
   probe myword
   append myword " world ! "
   probe myword
]


Now lets do something that will let you see this working: loop the first code 3 times !

loop 3 [
   myword: ""
   probe myword
   append myword "hello"
   probe myword
   append myword " world ! "
   probe myword
]


Let's look at the output:

you get:

""
"hello"
"hello world ! "
"hello world ! "
"hello world ! hello"
"hello world ! hello world ! "
"hello world ! hello world ! "
"hello world ! hello world ! hello"
"hello world ! hello world ! hello world ! "
== "hello world ! hello world ! hello world ! "


Have you acknowledged the difference with other languages ?
21:54If you connect a word to a function you connect it to the result of that function:

So, if you

myword: copy ""

You don't see the result of copy "" but think about that line as:

myword: (result) copy ""

So, the third (hidden) element is the result of the copy function which is always a new ""

If you rewrite the code:

loop 3 [
   myword: copy ""
   probe myword
   append myword "hello"
   probe myword
   append myword " world ! "
   probe myword
]


'myword' will always be reset to "" at each run.

""
"hello"
"hello world ! "
""
"hello"
"hello world ! "
""
"hello"
"hello world ! "
== "hello world ! "


22:00Exception to this rule are literal values, as numbers. Think like they have no pointer to the third element but a direct value. RED/REBOL use them like they are stored directly in the word.

loop 3 [ 
   myword: 3 
   myword: myword + 1 
   probe myword
]


Result:

4
4
4
== 4
9214
22:12@addos if there's something that puzzles you in internal workings, try to consult authoritative explanations (and ignore the above gobbledygook) on Red evaluation model (e.g. [this](https://github.com/red/red/wiki/[DOC]-Why-you-have-to-copy-series-values) or [this](https://github.com/red/red/wiki/%5BNOTES%5D-How-Red-Works---A-brief-explanation)); but not until after you've finished Rebol/Core guide and got a hang of the language in general - there're too much nuances to grasp in one sit. Above all, just try to have some fun :wink:
addos
22:15thanks
GiuseppeChillemi
22:17@addos Start from simple things and be back with questions. They are the roots of knowledge.
addos
22:20yeah, rebol is kinda mind bending
nedzadarek
22:49> @nedzadarek Nice! Single type can be given w/o block too:
>
> >> integer! of [1 3.0]
> == [1]
>

> Overall: reflective power lost, parsing power increased.

@toomasv
sorry, It was meant to another attempt "clause".

To be honest, it is nice to see different types in the X of Y syntax but I am not sure if of would be the best keyword for all cases. For example instead of v: make vector! [1 2 3 4 5 6] 2x5 of v I would prefer v/2x5.
greggirwin
22:53But v/2x5 is normal path syntax, which selects. It's not a query interface.
nedzadarek
23:13@greggirwin Yes, that's why v/2x5 fits *select values from 2 to 5* better than of syntax. Or have you mean something else?
greggirwin
23:30A pair is not a range, but what I meant was that path syntax maps to select, which does not select *values*, but *the next* value.
23:34If you overload it for query purposes, you lose the ability to select on the type you designate for that, create an implicit copy/part, and generally open a can of worms. I know *you* know this, so it's more a comment for listeners. We are never against people thinking of new ways to do things, and spend their time deeply investigating them.
GiuseppeChillemi
23:35@GREGGIRWIN adding the chat to programming.red
23:49@addos note, in the model I have introduced there is a little mistake on the number of elements in the first line. It has been done on purpose. We will talk about it when you will discover it!
addos
23:53@GiuseppeChillemi Thank you for your explanation

GiuseppeChillemi
04:51You are welcome
nedzadarek
08:47@greggirwin
I don't mean make path syntax into query. I mean someone might implemented it "with the current system in mind". So **something** like this:
A/B
- B is a integer! => select nth element of a series
- B is a word! => use select
- B is a pair! => select values from B/x to B/y

> create an implicit copy/part

Yes, there is no some kind of point to part syntax so we have to copy it. I have tinkered with this [here](https://github.com/nedzadarek/point_to_part) (still using copy) so I wonder if it's possible to implemented something like this into new derived* block type using [extra field](https://github.com/red/red/blob/master/runtime/datatypes/structures.reds#L58).

* I've been thinking about *direction* - if you reverse something it "points to left", where original series "points to right". So, I don't know how those 2 things could coexist using the one field, so hence, new derived types.
toomasv
09:06@nedzadarek
Not path syntax, but otherwise something you propose?
~: make op! func [series [series!] selector [integer! word! pair!]][
    switch type?/word selector [
        integer! word! [series/:selector] 
        pair! [copy/part at series selector/1 at series selector/2 + 1]
    ]
]
;...
[a b c d e f g] ~ 3
;== c
[a b c d e f g] ~ 'e
;== f
[a b c d e f g] ~ 2x5
;== [b c d e]
"abcdefg" ~ 2x5
;== "bcde"
"abcdefg" ~ 3
;== #"c"
'a/b/c/d/f/g ~ 3x5
;== c/d/f
nedzadarek
09:22@toomasv *propose* is a strong word, but yes, something like this.
phillvancejr
16:31can i access values in the Red Header? For example if in my Red header i have Red [ title: "My Title" ] can I access this title value somehow?
9214
16:38@phillvancejr no, that feature is not yet implemented.
phillvancejr
16:39Ah ok thanks!
Rebol2Red
18:48I see this kind of commenting in some rebol code
do [
;;  -- Ask for the year.  If one is entered, it will show up on the
;;  -- console when it is typed.  If no year was entered and we are
;;  -- printing the current year, then display the current year so
;;  -- that some year shows up on the top of the calendar.
    if "" = year: ask "Year (ENTER for current):^/^/" [
        prin year: now/year
    ]
	...

Has this any advantage over using this?
do [
	comment {
		Now we will print the day numbers, staring at 1 and doing
		a maximum of 31 times.  The "repeat" function automatically
		starts the counter at 1.
	}
    if "" = year: ask "Year (ENTER for current):^/^/" [
        prin year: now/year
    ]    
	...
addos
18:54Hi, I noticed if I do something like this myvar: [test test2 test3 test4]. I can access myvar/test and get test2, or myvar/test3 and get test4. How does that work without converting to a hash?
9214
18:55@addos this is identical to searching for an element and returning the one that follows it, or none if nothing was found or if there's nothing past the element.
18:56
text
>> second find [a b c d] 'a
== b
>> select [a b c d] 'a
== b
>> block: [a b c d] block/a
== b
18:57@Rebol2Red ; is a lexical comment, comment {...} is a runtime construct. Technically, it's not a comment, just a "eat one argument and return nothing" substitute for it.
addos
18:57so would a hash still be faster for this kind of thing?
9214
18:58@addos yes, but not all datatypes are hashed. You may want to use map! instead.
addos
19:01what is the advantage of a map over a hash?
9214
19:05@addos map! is a key/value structure with hashed keys, hash! is more free-form and doesn't have a rigid key/value pairing, since it inherits most of its functionality from block!.
addos
19:05rebol is so amazing, man
Rebol2Red
20:19My windows language is Dutch but i think the systems language is still English because when i use system/locale/months
i get: ["January" "February" "March" "April" "May" "June" "July" "August" "September" "October" "November" "December"]
Do i have to set the language to Dutch in Red somewhere?
9214
20:26@Rebol2Red Red doesn't have any localisation support (yet).
greggirwin
21:46@addos note that blocks are fast enough for many cases. Unless you know your datasets will be large, and it's easy enough to write tests to find out the speed difference, blocks should be fine. For small sets in particular, or when making a lot of changes as your app runs, blocks are good because hashes have computational overhead blocks avoid.
addos
22:15interesting, thanks
greggirwin
23:11Anecdotally, I wrote production code in Rebol2 for 17 years and never needed hash! (R2 didn't have map! either). For some cases it will make a big difference of course.
addos
23:15does rebol have anything like, or will it ever have anything like, CSP channels, like what golang has?
greggirwin
23:19Concurrency is planned for 0.9.0, but the design isn't finalized yet.
23:19Some quick test code for block/hash/map:
23:19
b: collect [repeat i 1000 [keep reduce [form i i]]]
h: make hash! b
m: make map! b

k: "1"
profile/count/show [[b/:k][h/:k][m/:k]] 10'000
k: "100"
profile/count/show [[b/:k][h/:k][m/:k]] 10'000
k: "1000"
profile/count/show [[b/:k][h/:k][m/:k]] 10'000
23:19results:
23:19
>> k: "1"
== "1"
>> profile/count/show [[b/:k][h/:k][m/:k]] 10'000
Count: 10000
Time         | Time (Per)   | Memory      | Code
0:00:00.001  | 0:00:00      | 280         | [m/:k]
0:00:00.001  | 0:00:00      | 432         | [b/:k]
0:00:00.002  | 0:00:00      | 280         | [h/:k]
>> k: "100"
== "100"
>> profile/count/show [[b/:k][h/:k][m/:k]] 10'000
Count: 10000
Time         | Time (Per)   | Memory      | Code
0:00:00.003  | 0:00:00      | 280         | [h/:k]
0:00:00.004  | 0:00:00      | 280         | [m/:k]
0:00:00.039  | 0:00:00      | 432         | [b/:k]
>> k: "1000"
== "1000"
>> profile/count/show [[b/:k][h/:k][m/:k]] 10'000
Count: 10000
Time         | Time (Per)   | Memory      | Code
0:00:00.003  | 0:00:00      | 280         | [h/:k]
0:00:00.003  | 0:00:00      | 280         | [m/:k]
0:00:00.354  | 0:00:00      | 432         | [b/:k]
>> profile/count/show [[b/:k][h/:k][m/:k]] 1'000
Count: 1000
Time         | Time (Per)   | Memory      | Code
0:00:00      | 0:00:00      | 280         | [h/:k]
0:00:00.001  | 0:00:00      | 280         | [m/:k]
0:00:00.038  | 0:00:00      | 432         | [b/:k]
23:20Profile code: https://gist.github.com/greggirwin/908d44dc069ed84cf69f053e1308390d
addos
23:44whoa neat

nedzadarek
09:26So, for bigger numbers, block's access takes much more time than other types:
0:00:00.031  | 0:00:00      | 280         | [h/:k]
0:00:02.344  | 0:00:00      | 432         | [b/:k]

Do blocks have some kind of optimisation towards "key searches"?
toomasv
10:33IIRC Blocks are effective in adding, hashes in reading, maps in both.
endo64
16:02Block with key search optimization is hash!, since there is no key in blocks. If we need key & value then we should go for maps.
nedzadarek
16:46@endo64 so if I type b/:k where k is not integer! and b is a block! then it will check every 2nd element (starting from b/1)?
greggirwin
17:00@nedzadarek, no, it will check *every* item, unless you use select/skip. Blocks are not key-value structures, and have to do a linear search to find a value. That's why they are slowest for keys near the end.
>> blk: [a b c d e]
== [a b c d e]
>> blk/a
== b
>> blk/b
== c
>> blk/c
== d

It doesn't matter how big the entire block is though. So you can use blocks for large datasets, organize them so frequently accessed keys are near the top, and get good performance.
nedzadarek
17:27@greggirwin I have forgotten about this.
> It doesn't matter how big the entire block is though. So you can use blocks for large datasets, organize them so frequently accessed keys are near the top, and get good performance.

For data that I won't change, this solution seems fine. However if I change (especially add something to) it, time required to add something might be big (after I add "a lot" of data).
I wonder If I have to do this (to organize elements you mentioned) instead of just using other types. At least for key-value structures. Other structures (like B tree) might be better suited for blocks than for maps/hashes.
greggirwin
18:15Blocks are fine as is. Using maps is also fine. Hashes are good, too, but you'll hear me talk about premature optimization a *lot*. There are times we need to optimize performance, and times we don't. Focus on clear, maintainable, expressive code first.
temperfugit
22:25
>> block: [a b c d]
== [a b c d]
>> block/a
== b
>> index? block/a
== 417

Just messing around. I was expecting "2". Any idea why it would return "417"?
9214
22:31@temperfugit
>> index? 'b
== 418
>> find words-of system/words 'b
== [b < true <> invalid-arg integer arr1 % << or tuple a c d clipboard logic box null cause-error routines msg view flags title below cen...
>> index? find words-of system/words 'b
== 418
>> index? find [a b c d] 'b
== 2
>> select [a b c d] 'a
== b
>> index? select [a b c d] 'a
== 418
greggirwin
23:10Nice explanation @9214.
9214
23:11@greggirwin
>> note that I haven't said a word
== it's all just data!... and LOADable Red ;^)

temperfugit
03:13Thanks, @9214 .
nedzadarek
08:20@greggirwin Yes, I'm aware of premature optimization. I'm just very curious and I want to know a lot of techniques... in general *things*.
endo64
09:23@9214 @greggirwin isn't it too confusing that index? accepts any-word! and return its offset in system/words? is it decided to work that way?
hiiamboris
10:21Not in system/words in particular but in the context where that word is bound.
10:22I've seen this used by the View subsystem to mark what facets were changed and should be updated.
9214
10:34@endo64, what @hiiamboris said. index? returns [this](https://github.com/red/red/blob/master/runtime/datatypes/structures.reds#L190) part of a word.
phillvancejr
13:58Do we have the ability to create a web server in red?
endo64
14:33@phillvancejr Not yet, as full IO is not finished yet, but after 0.7.0 (full io, networking protocols) we will be able to do that.
addos
14:50going to be an exciting time when that happens
14:59is there a way to use red/rebol help to see what I can use to manipulate a type? For instance, can I have help tell me all the commands/functions I can call against a series?
endo64
15:03You can try ? series! and to get all the words try what.
addos
15:08I can't seem to get what to filter the results
mikeparr
15:15There is a list of series words at: http://www.red-by-example.org/#cat-s01 -nb it is human-generated though - may not be current.
endo64
15:30? series! didn't work? try ? "series!"
addos
16:05whoa
16:05ok, that worked
16:05that was really helpful
16:06thanks @endo64
endo64
16:07You're welcome
phillvancejr
17:10Thanks for your answer @endo64 !
toomasv
17:44@phillvancejr Also
probe last load help-string series!
[block! paren! string! file! url! path! lit-path! set-path! get-path! vector! hash! binary! tag! email! image!]
greggirwin
17:50help series! will show what @toomasv just did. What is very different and doesn't take an arg by default. If you use help what you can see how to filter using refinements. e.g. what/with and what/spec.
17:51@endo64 et al, on words and their index, it's an important aspect of Red that some features which make Red more self-reflective and self-supporting are available just like other functions. Some might say this is leaking abstractions, or breaking information hiding, but Red is different in that way, intentionally. The line is blurred, or invisible, between "normal" user programming, and learning more about how your tools work.
toomasv
17:54Also last load mold series!
greggirwin
17:56
>> my-series!: make typeset! last load mold series!
== make typeset! [block! paren! string! file! url! path! lit-path! set-path! get-path! vector! hash! binary! tag! email! ...
>> ? my-series!
MY-SERIES! is a typeset! value: make typeset! [block! paren! string! file! url! path! lit-path! set-path! get-path! vector! hash! binary! tag! email! image!]

Going in circles now... ;^)
toomasv
17:59Umps! Didn't read what was the problem ... :flushed:
endo64
18:04@greggirwin what I mean how useful returning a word's index in a context even if it is unset?
greggirwin
18:11The word still exists in the context, regardless of what value it refers to.
toomasv
18:12Finally read the question

> can I have help tell me all the commands/functions I can call against a series?

Not help, but still...
load replace/all first parse read https://raw.githubusercontent.com/red/red/master/runtime/actions.reds [thru ";-- Series actions --" collect keep to ";-- I/O actions --"] [#":" | #"*" | lf] ""
== [append at back change clear copy find head head? index? insert length? move next pick poke put remove...
greggirwin
18:13Niiiice. ;^) Going to blow a few minds here, for new Reducers.
toomasv
18:14:smiling_imp:
addos
18:14was looking for something more simple, something like ? "series!"
18:14which I think did what I was looking for
18:15why does sort modify the series I pass to it?
greggirwin
18:16@addos why wouldn't it? (leading question)
addos
18:16because I could call sort on a series and decide if I want to assign it to a variable or not
18:16or at least, so I would think
18:16so to do what I want, I have to copy the series first, and then sort the copy?
greggirwin
18:17Indeed. And if it copied by default, you couldn't sort in place. But you can always add sort copy ... to avoid modifying the original.
18:22This is an important design aspect. In immutable languages, you either can't, or have to work *very* hard to do this kind of thing. In Red, modifying series is the default, putting you in the driver's seat about when to copy, and making that explicit, which adds to your intent. It is also a gotcha that catches everyone at times, which is why we point people to https://github.com/red/red/wiki/%5BDOC%5D-Why-you-have-to-copy-series-values. It's a deeeeep aspect of Red, which you don't need to understand to use the language, but lets you think very differently about how things work.
toomasv
18:32Sorry, still messing with actions:
>> actions: load replace/all first parse read https://raw.githubusercontent.com.....
>> info: do %info.red
>> foreach action actions [prin uppercase form action i: info get action print mold select i 'spec print ""]
APPEND
["Returns the value a word refers to" 
    word [word! path! object!] 
    /any {If word has no value, return UNSET rather than causing an error} 
    /case "Use case-sensitive comparison (path only)" 
    return: [any-type!]]

AT
["Returns the value a word refers to" 
    word [word! path! object!] 
    /any {If word has no value, return UNSET rather than causing an error} 
    /case "Use case-sensitive comparison (path only)" 
    return: [any-type!]]

BACK
["Returns the value a word refers to" 
    word [word! path! object!] 
    /any {If word has no value, return UNSET rather than causing an error} 
    /case "Use case-sensitive comparison (path only)" 
    return: [any-type!]]

CHANGE
["Returns the value a word refers to" 
    word [word! path! object!] 
    /any {If word has no value, return UNSET rather than causing an error} 
    /case "Use case-sensitive comparison (path only)" 
    return: [any-type!]]
...
9214
18:41
text
>> actions: load form parse help-string action! [collect some [keep to "=>" to newline]]()
>> sort new-line/all collect [forall actions [if find first find spec-of get actions/1 block! 'series! [keep actions/1]]] off
== [append at back change clear copy find head head? index? insert length? modify move next pick poke put remove reverse select skip sort swap tail tail? take trim]
addos
18:44@greggirwin Thanks for the link, I will have to review it further
18:45@9214 that is pretty neat
nedzadarek
20:12@hiiamboris
> I've seen this used by the View subsystem to mark what facets were changed and should be updated.

It sounds like it's intended for "internal use". I have tried it and it's not so clean (last expression):
context1: object [
    a: 1
    b: 2
    c: 3]
w: bind 'b context1; == b
 index? w ; == 2
get first at words-of context1 2
; == 2
GiuseppeChillemi
20:24@phillvancejr
> Do we have the ability to create a web server in red?

Do you know that RED authors created the only web server engine in REBOL and for REBOL ? https://www.cheyenne-server.org/
nedzadarek
20:29@greggirwin
> it's an important aspect of Red that some features which make Red more self-reflective and self-supporting are available just like other functions. Some might say this is leaking abstractions, or breaking information hiding, but Red is different in that way, intentionally. The line is blurred, or invisible, between "normal" user programming, and learning more about how your tools work.

Is there something that prevents me from messing up? Is it user's *knowledge* or user have to know *a way* to do something?
rebolek
20:38@GiuseppeChillemi not the only but certainly most advanced. Basic web server can be found in Rebol examples by Carl (HTTP 1.0 is no rocket surgery).
GiuseppeChillemi
20:44@endo64
> @9214 @greggirwin isn't it too confusing that index? accepts any-word! and return its offset in system/words? is it decided to work that way?

I have had the same problem.
We have been subject to an illusion, a joke of our minds.
If you look at the code you will find the cause:

>> block: [a b c d]
== [a b c d]
>> block/a
== b
>> index? block/a
== 417


The first line: block: [a b c d] triggers to us the knowledge we are working with a block. We think index? should return the position in the series of the next element we get using select. Instead, we are selecting a word, then we are asking the index of that word out of the block !

I think there is no way to escape this trap other than introducing first the what's happening here:

--== Red 0.6.4 ==-- 
Type HELP for starting information. 

>> index? 'c
== 430
>> index? 'a
== 429
>> index? "sting"
== 1
>>


@temperfugit. Congratulation for having discovered (fallen into...) such powerful illusion.
20:55Pardon....
20:56The last console code should be changed with the following.

--== Red 0.6.4 ==-- 
Type HELP for starting information. 

>> index? 'c
== 430
>> index? 'a
== 429
endo64
20:59> we are selecting a word, then we are asking the index of that word out of the block

@GiuseppeChillemi It is not exactly I'm trying to say. I understand that block/a ;== b so index? block/a should return the index of 'b in the context it's bound.
21:04But, it should return the index even if the word is unset!.
21:08This leads index? will always return an integer because if the word is not exists, during querying the word we are making it exists in the system/words.
21:08But in that case the return value doesn't mean much.
21:11But I understand that system/words is not special than any other object.
GiuseppeChillemi
21:15@endo64 asking for the index of a word should not be meant to be used as an instrument to know if a word exists. It should be used in combination with a check on unset! status
21:18Also I do not understand which are the implications and the reasons to have it working that way. I surrender to the knowledge of the creators regarding such topic.
endo64
21:20What would index? in below case?
>> set/any o: context [a: 1 b: 2 c: 3] ()
>> o
== make object! [
    a: unset
    b: unset
    c: unset
]
21:21Currently it is
>> index? in o 'c
== 3

Which looks correct. Should it return error because c is unset? That is not useful too.
9214
21:23@endo64 why should it return an error? index? simply checks word's index in a context, but ignores its binding and value.
endo64
21:26@9214 I understand that, I refute my own thesis.
9214
21:33Digging thru my notes: index? will become a part of reflect at one point, and index? will be kept for series only. Initially it was a quick implementation to cover needs in View engine.
endo64
21:37That makes more sense.
21:39Other index? differences between Red & Rebol:
No /xy refinement yet.
index? at make image! 10x10 5x5 is 56 in Rebol, 45 in Red.
21:40Or better: index? at make image! 10x10 1x1 ; == 1 (Red), 12 (Rebol 2/3)
GiuseppeChillemi
21:45@9214 Asking for the index of a word in a contex that way is new to Red. Trying it in REBOL:

>> index? 'a
** Script Error: index? expected series argument of type: series port
** Where: halt-view
** Near: index? 'a


So index? works on:

Series
Blocks
Words..

.. and ?
nedzadarek
22:24@GiuseppeChillemi check SERIES! is a typeset! value: make typeset! [block! paren! string! file! url! path! lit-path! set-path! get-path! vector! hash! binary! tag! email! image!]
22:32Shouldn't image/rgb set colour for pixel **from some position** - not for all pixels?
i: make image! [100x100 255.0.0]
; make image! [100x100 #{
;     FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000...
  ? i

  length? i
; 10000
  i2: at i (divide (length? i) 2)
; make image! [100x100 #{
;     FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000...
  index? i2
; 5000
  index? i
; 1
  i2/rgb: 0.255.0
; 0.255.0


It works with, for example, with forall + image/integer:
forall i2 [i2/1: random 255.255.255]
; 82.21.222
  ? i2
greggirwin
23:00Good find @9214.

@nedzadarek the docs don't cover that case, and %units/image-test.red has only a small number of basic tests. Looks like there may be some things to check in image/set-data. offset is set [here](https://github.com/red/red/blob/master/runtime/datatypes/image.reds#L250), but not used.
23:02> Is there something that prevents me from messing up? Is it user's knowledge or user have to know a way to do something?

Users have to learn. Red is a high level language that helps you avoid a lot of work and errors. That doesn't make it completely safe, because it's so flexible. There is a great irony that almost anyone can use Red, and get a lot of useful work done, without ever encountering certain deep aspects of the lang. And they can safely ignore them most of the time (copying is an exception of course). That is, you can take the blue pill and use Red, but once you take the Red pill...

phillvancejr
13:44@GiuseppeChillemi yes I've been looking into Cheyenne also. Was just curious if it was available in Red itself yet :)
dockimbel
14:14@nedzadarek
> Shouldn't image/rgb set colour for pixel **from some position** - not for all pixels?

No, that feature is handled by using an integer index (like image/123 or i: 123 image/:i, same as for regular series. /rgb gives access to the whole image buffer at once, both for reading and writing. The way image buffers are handled internally makes it costly to restrict to only a part of that buffer. Moreover, changing the color from an arbitrary linear position in a 2D image has limited uses.
nedzadarek
16:27@greggirwin @dockimbel Thank you for the answers.
So for editing or reading part of an image we should build upon integer indexes (for example with forall)? Or shall we expect some relatively fast function for editing/writing images build-in in a future releases?
16:31@greggirwin
> Users have to learn (....) but once you take the Red pill...

I see.
ps. Red pill analogy is nice. I can see an advert with Laurence Fishburne and the Red pill... I mean language.
GiuseppeChillemi
16:48This evening I am so tired I will take the RED Pillow.
greggirwin
18:56@nedzadarek the fast way to work with image data is to use Red/System, as in the mandelbrot example, or use @ldci's work with RedCV.
phillvancejr
19:16Has anyone tried to run any C/C++ dylib stuff on MacOS? Might be related to my previous issue with libred, but I've created a simple dylib library with one function that I can use with C/C++ successfully but I can't get it to work with Red/System. I get the following error:
dyld: Library not loaded: @loader_path/libadd.dylib
  Referenced from: /Users/phill.vance/Desktop/Documents/Pers/Red/c_lib_test/./reds_test
  Reason: no suitable image found.  Did find:
        /Users/phill.vance/Desktop/Documents/Pers/Red/c_lib_test/./libadd.dylib: mach-o, but wrong architecture
        /Users/phill.vance/Desktop/Documents/Pers/Red/c_lib_test/libadd.dylib: mach-o, but wrong architecture
Abort trap: 6


my dynamic lib, "libadd.dylib" is in the same directory as the reds file

my Red/System code:
Red/System []

#import [
    "libadd.dylib" cdecl [
        add_five: "add_five" [ n [integer!] return: [integer!]]
    ]
]

print add_five 30
rcqls
19:20@phillvancejr 32bits dylib?
phillvancejr
19:21using 64 currently
rcqls
19:22red is only 32bits….
greggirwin
19:22Red is 32-bit only at this time.
phillvancejr
19:22...duh, sorry lol. Thanks guys
rcqls
19:27@phillvancejr BTW, this time the message was pretty understandable …. But not always… Compilation of the library with -m32 if you’re not on MacOS Mojave but with an earlier macOS version .
phillvancejr
19:56I'm most likely doing something wrong but... I after compiling a 32 bit library, now I get the following errors:
dyld: lazy symbol binding failed: Symbol not found: _add_five
  Referenced from: /Users/phill.vance/Desktop/Documents/Pers/Red/c_lib_test/./reds_test
  Expected in: flat namespace

dyld: Symbol not found: _add_five
  Referenced from: /Users/phill.vance/Desktop/Documents/Pers/Red/c_lib_test/./reds_test
  Expected in: flat namespace

Abort trap: 6
greggirwin
19:57Are you compiling for cdecl exports, no name-magled C++?
19:58Make sure the name matches, as there's a leading underscore on the func name there, which isn't in your R/S code.
phillvancejr
20:03thanks @greggirwin and @rcqls for your help and patience !!! It was the name mangling. I had to extern "C" to fix it.
greggirwin
20:04:+1:
rcqls
20:04@phillvancejr :clap:
nedzadarek
20:18@greggirwin Mandelbrot example? Where it is - I cannot find it.
About RedCV - I haven't been able to run it but I still wasted time on compiling.
greggirwin
20:40https://github.com/red/code/blob/master/Scripts/mandelbrot-fast.red
phillvancejr
20:49To use my dll in regular red, I need to use #system [ #include %library.reds ] right? Is there anything else that I need to make it work? Just getting undefined word
20:49Basing this off the julia binding example on Github.
greggirwin
21:36You do need to compile your Red app. Right now only Red/System has FFI, though Red will get it in the future, so you can run interpreted as well.
moliad
22:13just had a demo of RedCV in person with @ldci it is REALLY nice.

virtualAlan
00:01i added some more here - http://www.mycode4fun.co.uk/About-Red-Programming - you'll need to scroll down to the latest stuff - also added more to other pages, check it out ....
endo64
05:49Thanks @virtualAlan
mikeparr
07:24Very nice, @virtualAlan
nedzadarek
15:09@greggirwin Thank you for the link. I have tried both mandelbrots:
Data:
x-min -2.0
x-max 1.0
y-min -1.0
y-max 1.0
iterations 10

Mandelbrot slow:
repl - 54
-c -r 27
-c 28
-r 26
Mandelbrot fast:
coompiled ~0.2

What I get is that I will get 2x speed from compiling compared to just running a code.
Compiling a Red/System code make it even faster. It's ~100 times faster. It's even said that it still sub-optimal.
I assume that this code is good. Can a new person to the Red/System expect such gain in the speed?
19:37ps. I assume that even thought the Slow Mandelbrot shows white image it still does the same amount of loops/computations.
greggirwin
22:49@nedzadarek they are doing the same work, yes, but R/S can access and update the image data much more efficiently. Being new to R/S means learning a lot, if you're not already a C programmer, but offers the same speedup as C would.
22:49The key, as always, is knowing what will benefit from the speed. :^)

loziniak
10:07Hi! Shouldn't that return unset?
a: object [x: 1] probe get/any 'a/y
GiuseppeChillemi
11:43Is a button with an image inside possible ?
ldci
12:21@GiuseppeChillemi : basically all face objects include an image facet.
GiuseppeChillemi
12:37@ldci thanks. Will try later.
hiiamboris
16:58@loziniak get/any bind 'y a will
nedzadarek
17:01@GiuseppeChillemi there are few ways to do this:
- image + on-down:
i: make image! [200x200 255.0.0]
view [image i on-down [print 'clicked]]

- button + image (as @ldci said):
i: make image! [200x200 255.0.0] 
view [button 200x200 i on-down [print 'clicked]]
loziniak
17:55@hiiamboris thanks fot a workaround!
nedzadarek
19:44@loziniak do you need unset! value? If not you can check whenever or not given key exist in an object, e.g:
o: object [a: 1]
; make object! [
;     a: 1
; ]
  in o 'a
; a
  get in o 'a
; 1
  in o 'b
; none
19:48or '*-of function:
words-of o
; [a]
find (words-of o) 'a
; [a]
find (words-of o) 'b
; none
ps. I guess words-of should be used with object!` but don't cite me on this.
loziniak
20:44@nedzadarek Thanks for pointing out some nice solutions too. I already found another solution. My question was more about consistency in get implementation. I expected that get/any will return unset.
nedzadarek
21:37@loziniak In case of words that you type outside an objects (e.g. in the the console) the Red will put them into system/words and it will give them some value. unset! if you don't give it a value (e.g. 'a; find system/words 'just-type-some-characters ; == true).
**My guess** is that when you try to get a non-existent-word from an object, the Red won't put non-existent-word into the object. So the Red will raise error because get cannot retrieve a value where the key doesn't exist.
greggirwin
21:39Correct @nedzadarek (see line 1159 in %object.reds). And Red *can't* add new words to objects, as they are not extendable at this time. Only the global system context is.
giesse
22:27also
>> o: object [a: 1]
== make object! [
    a: 1
]
>> find o 'b
== none
>> find o 'a
== true
loziniak
22:52Perhaps that's true, but it still does not convince me that get/any should work just like get when used on path!
greggirwin
22:57Unset itself is a tricky beast, and should generally be avoided. But to even get that, a word has to exist in a context. Can we agree on that? Because if that's the case, you have to be able to set that word to a value. If you can't do that, you have to be able to extend any context.
22:59That is, if it works as you expect, then it also needs to support set, yes?

9214
00:17@hiiamboris

> get/any bind 'y a will

That's a weird suggestion, given that bind 'word returns word unaltered. i.e. your example is identical to get/any 'word with word being unset by default.
greggirwin
00:30Why it works is non-obvious. i.e., that it avoids the path syntax leading to the object! type handling it, and making it a simple word evaluation.
toomasv
03:31But:
>> y: 3
== 3
>> a: object [x: 1]
== make object! [
    x: 1
]
>> get/any bind 'y a
== 3
03:41And shouldn't this work? :flushed:
>> a: object [x: 1]
== make object! [
    x: 1
]
>> bind 'x a
== x
>> x
*** Script Error: x has no value
giesse
04:32no, the second x is not bound to a
04:34
>> a: object [x: 1]
== make object! [
    x: 1
]
>> first-x: bind 'x a
== x
>> second-x: 'x
== x
>> get first-x
== 1
>> get second-x
*** Script Error: x has no value
*** Where: get
*** Stack:  

>> b: reduce [first-x second-x]
== [x x]
>> reduce b
*** Script Error: x has no value
*** Where: reduce
*** Stack:  

>> x: 'global
== global
>> reduce b
== [1 global]
toomasv
04:35Ah, yes, thanks!
hiiamboris
09:44@9214 right, my mistake
10:17only the boring way then, right? either x: in a 'x [get/any x][]
greggirwin
17:12@toomasv on your first question:
>> c: context? bind 'y a
== make object! [
    datatype!: datatype!
    unset!: unset!
    none!: none!
    logic!: logic!
    block!: block!
    paren!: paren!
    string!:...
>> c: context? bind 'x a
== make object! [
    x: 1
]
toomasv
18:07Yes, thanks. I forgot that bind doesn't bind "in place", but returns bound word. Silly me.
greggirwin
18:56Based on the above, the re-bound word returned is attached to the global context. So it's about trying to bind a word to a context where that word doesn't exist. @9214, add that to your notes for the binding article.
18:59So your y already existed, bound to the global context, and there's no y in a, so it's not re-bound.
nedzadarek
20:39@greggirwin
> Correct @nedzadarek (see line 1159 in %object.reds). And Red *can't* add new words to objects, as they are not extendable at this time. Only the global system context is.

I have forgotten about "objects are nto extendable" but system/words confused me. Thank you for reminder.

GiuseppeChillemi
21:48I remember Carl creating a converter from makedoc to asciidoc. Do you remeber about this tool , or a makedoc version wich as an asciidoc emitter ?
22:03(Maybe it was markdown instead of asciidoc ? It was the time when he created the wip wiki..
22:37Spotted also a MakeDoc3 but could not find it...

greggirwin
02:54I don't recall a converter @GiuseppeChillemi.
GiuseppeChillemi
07:19@greggirwin
It's not a converter, maybe an emitter expecially suited for markdown. Carl starts talking about modifications to make it Makedoc more markdown style here: http://www.rebol.com/article/0446.html. The in other documents affirms the whole REBOL site is made form a special version which is used to be part of WIP Wiki.
07:23Also this seems to me makedoc3 or an alpha version: http://reb4.me/r3/makedoc
phillvancejr
17:11how can I set a button to be disabled by default (not clickable) then set it to enabled later? I tried
export-button: button "Export" enabled? no


but this does not work. Do I access it with export-button/enabled?
toomasv
17:35@phillvancejr button disabled
phillvancejr
17:38Thanks Toomas, and how do I reenable it?
17:40nvm, I got it, thanks you for your help!
nedzadarek
19:48For somebody that doesn't know it yet:view [b: button "Export" disabled button "enable export" [b/enabled?: true]]
btw. is it my pc or does enabling b have animation (fade in)?
greggirwin
19:54Animation is based on OS settings.
19:55@phillvancejr, the syntax for setting values directly in facets is to use with. e.g.
view [b: button "Export" with [enabled?: false] button "enable export" [b/enabled?: true]]

GalenIvanov
06:30@nedzadarek It's animated on my pc at work (win 10) too.
GiuseppeChillemi
07:47Is there a way to have a "PRESSED" button ?
pekr
07:48You mean toggle probably. Not sure e.g. Windows provides one?
nedzadarek
08:25@greggirwin @GalenIvanov thank you
ps. I'm on win 8.1 if anyone interested.
toomasv
08:45@GiuseppeChillemi Only custom-made.
GiuseppeChillemi
22:21@toomasv their are far fro actual knowledge. I prefer them for their visibility when you are at some distance from the display.
22:25@toomasv I mean "far from my knowledge, I am not able to create them"

toomasv
06:39@GiuseppeChillemi One possibility:
fnt: make font! [color: white style: 'bold]
_yes_: draw 50x25 [fill-pen snow pen off box 0x0 49x24]
_no_: draw 50x25 [fill-pen snow pen off box 0x0 49x24]
_yes_: draw _yes_ [fill-pen leaf pen gray box 0x0 49x24 5 font fnt text 9x1 "Yes"]
_no_: draw _no_ [fill-pen brick pen gray box 0x0 49x24 5 font fnt text 12x1 "No"]
view [base 50x25 data false with [image: _no_] on-down [
    face/data: not face/data 
    face/image: get pick [_yes_ _no_] face/data]
]
GiuseppeChillemi
08:15@toomasv another lesson from one of my teachers
toomasv
09:24@GiuseppeChillemi Here's an example of usage of [toggle-button as style](https://github.com/toomasv/learning/blob/master/styles/buttons/toggle.red):
view [
    title "Toggle examples" 
    t1: toggle with [extra/true: "Is switched on" extra/false: "Is switched off"] 
    t2: toggle on-up [t1/actors/on-down t1] 
    t3: toggle with [default: true extra/true: "On" extra/false: "Off"]
]

[![toggles](https://toomasv.red/images/Styles/toggle.gif)](https://toomasv.red/images/Styles/toggle.gif)
rcqls
09:44@toomasv :thumbsup: and also some debug for linux/GTK ….
toomasv
10:03@rcqls Can you try if the [new version](https://github.com/toomasv/learning/blob/master/styles/buttons/toggle.red) with transparent background works in GTK
[![image.png](https://files.gitter.im/red/help/BHiO/thumb/image.png)](https://files.gitter.im/red/help/BHiO/image.png)
rcqls
10:05@toomasv The bug is more serious! I think it is rrelated to image…. But I’ll give a try...
10:07@toomasv THe last version does not work anymore on macOS… On Linux/GTK it is more serious as I said ...
toomasv
10:10OK, thanks, I'll revert it to snow background.
GiuseppeChillemi
20:00@greggirwin
> I don't recall a converter @GiuseppeChillemi.

Suprise, I have found something ! https://github.com/rgchris/Scripts/tree/master/makedoc
Open the ASCIIDOC.r and read the header: "ASCIIDOC Emitter !".
20:03I have to understand where and how use it.
20:19
Directory with more files: http://reb4.me/md/
The project should be "MakeDOC Anywhere" but it is nor indexed neither documented
Here is the page where I have found the name
http://ross-gill.com/page/MakeDoc

>
20:20Last update december 2018 !
rgchris
21:27It'll be a little much to explain now, but the idea is that you have two functions: LOAD-DOC and MAKE-DOC. The latter function is a text->html function, the former creates a document object that allows for more nuanced handling.
21:31To see the latter, you can try (Rebol 2):
do http://reb4.me/r/makedoc
doc: load-doc "Foo"
? doc
doc/render
GiuseppeChillemi
23:20I have understood the concept. Will try it and I'll be back

GiuseppeChillemi
06:05@rgchris I guess http://reb4.me/r/make doc will use emitters from http://reb4.me/MD/ ?
mikeparr
07:56Type conversion. I see that we can use e.g. to string! and also to-string. In fact there are a number of 'to-xxx' functions. Is there a difference, a style issue, etc?
rebolek
07:57
>>  ?? to-string
to-string: func ["Convert to string! value" value][to string! :value]

08:08Some people prefer it, because it's one char shorter :)
mikeparr
08:09Thanks @rebolek . Same behaviour. I was wondering about future deprecation etc.
rebolek
08:15I don't think it's going to be deprecated. There are also some to-xxx funcs that don't have to xxx! counterpart, like to-hex.
mikeparr
08:16thanks, got it!
nedzadarek
08:47
@rebolek
> Some people prefer it, because it's one char shorter :)

I think it's more than "1 character shorter":
- ! is harder to type
- I can read to-string faster because it's one word; to string! is two words.>
rebolek
09:28@nedzadarek thanks, so there are more reasons. I actually prefer to xxx!, so I remembered just this one.
greggirwin
15:35Carl's explanation for the to- funcs, IIRC, was that to confused some early users, or wasn't as obvious. The difference is small, so it's not just the syntax, but the constraints the functions add. Because to allows prototype values, and *that* is something people aren't used to. it's also a powerful feature. e.g.
>> to "" 1
== "1"
toomasv
15:54Wow! Didn't know that
>> to %ha "hi"
== %hi
xmonader
17:22is there a docset available for red/rebol ?
endo64
17:55@xmonader Nope, and it is too early to have one for Red, first need to complete the official docs.
rgchris
19:34@GiuseppeChillemi Yes, but that's configurable if you download the script and change the ROOT header setting.
19:35There are some design limitations to the object model that I hope to address at some point, but if you wish to use a different emitter, there is the /WITH refinement on both LOAD-DOC and MAKE-DOC.
19:44Sorry, that should be /CUSTOM:
do http://reb4.me/r/makedoc
make-doc/custom "Foo" [markup: %asciidoc.r]
GiuseppeChillemi
19:48@rgchris , Rebol world has:
MakeDoc Pro
MakeDoc2
MakeDoc3
NicomDoc

Which of these products are now outdated thanks to you version ?
19:52(Oh no, everything disappeared !)
19:58(Not everything,just something ;-)
rgchris
23:20Depends what your goals are. Mine is built on md2 and has some shared dna with Gabriele’s md3. It’s intended to be versatile and introspective (eg. can add methods to the object model to extract headers, customize the RSP template to chop the content in different ways).
phillvancejr
23:22Can i convert a red/system c-string into a red-string? I'm in a #system block and I want to pass a c-string I received from a dynamic library into a red function that takes a normal red string. I used " as red-string!" to convert the c-string into a red-string and everything compiles. However when I run the binary I get an error. Code:
output: copy "" ; empty string

output-val: func [ val [string!]][ ; sets output to the argument passed into it
    output: val
]

#system [
      #import [
        "libGreet32.dylib" cdecl [
             greet: "Greet" [return: [c-string!]] ; function that returns a c-string
      ]
]

    v: as red-string! greet ; call greet and convert it to a red-string!

    
    #call [ output-val v ] ; call the red function with the red-string version

]


It compiles fine, but when I run it I get:
*** Runtime Error 1: access violation
*** at: 001762CCh
greggirwin
23:57https://github.com/red/red/wiki/%5BDOC%5D-Guru-Meditations#convert-c-string-to-red-string

GiuseppeChillemi
07:12@rgchris is the markup language of your makedoc different from makedoc2 and incompatible?
07:46Note: Also MakeDoc3 does not seem officially available and can't find it.
giesse
18:36It was supposed to be available from rebol.com. http://colellachiara.com/soft/MD3/md3.html
GiuseppeChillemi
20:51@giesse have you a link to the code ? Is it complete ?

rgchris
02:26@GiuseppeChillemi For the most part it's compatible. I don't believe that inline formatting was formally included in md2. My version here has rudimentary MarkDown-style inline formatting, though with some caveats (big one is that the second component of []() link convention needs to be a valid Rebol block).
02:28Additionally, the RSP template can reference the document object:
make-doc/custom "[Foo](%/bar)" [
    template: {<div class="wrapper"><%= document/render %></div>}
]
giesse
06:39@GiuseppeChillemi it was a RT project, I'm not sure if it was ever published.

My literate programming stuff aside, I don't think there's anything unique about it. It was meant to consolidate the various versions in one single standard, not add anything new in particular, IIRC.
GiuseppeChillemi
13:29@giesse It think it wasn't, I can't find it anywhere.
22:26Functions have a parse dialect for arguments. Is it someway accessible? I wish to provide it a block of arguments and let it be validated...
hiiamboris
22:41@GiuseppeChillemi you can make your own function constructor, and see also /chit-chat from [here](https://gitter.im/red/chit-chat?at=5c99b5552fb6800d8080f9da)
GiuseppeChillemi
22:53@hiiamboris I wish to use/reuse the standard one but of course I can create another one from scratch
hiiamboris
23:06The standard one is in R/S:
https://github.com/red/red/blob/master/runtime/natives.reds#L417
https://github.com/red/red/blob/master/runtime/datatypes/function.reds#L742
23:07And maybe https://github.com/red/REP/issues/24 for more info
23:10Here's also a [tool for you](https://gitlab.com/hiiamboris/red-codex/) if you would ever like to navigate the Red source code base
nedzadarek
23:36
f: func [spec body] [func spec (head insert body [print 'hey])]
; func [spec body][func spec (head insert body [print 'hey])]
  f2: f [] []
; func [][print 'hey]
  f2
hey

greggirwin
03:37@GiuseppeChillemi you can check out the code help uses to do its job (in %environment/console/help.red).
>> fn-spec-parser: :help-ctx/func-spec-ctx/parse-func-spec
== func [{Parses a function spec and returns an object model of it.} 
    spec [block! any-function!] 
    /local =val 
 ...
>> probe fn-spec-parser :append
make object! [
    desc: {Inserts value(s) at series tail; returns series head}
    attr: none
    params: [
        [name series type [series! bitset!] desc none] 
        [name value type [any-type!] desc none]
    ]
    refinements: [[name 
        /part desc "Limit the number of values inserted" params [[name 
            length type [number! series!] desc none
        ]]
    ] [name 
        /only desc {Insert block types as single values (overrides /part)} params []
    ] [name 
        /dup desc "Duplicate the inserted values" params [[name 
            count type [integer!] desc none
        ]]
    ]]
    locals: []
    returns: [name return type [series! bitset!] desc none]
]
JLCyclo
14:04Some help: I try to make a pull request for JLCyclo/community forked from red/community. I made a successful git push. I cannot make the pull request, can someone make it for me ? (I think that my previous pull request was made by PeterWAWood). Thanks
nedzadarek
16:19Should overriding default action by block (e.g base on-down [] [overridden by this block] ] - here [overridden by this block] over-rides on-down action ) be allowed? Or at least should it raise some warning (I am not sure if there is such thing in the Red).
It may cause some weird bugs:
view [base  on-down [

  either 1 = 2 [
    "do something" ]
    some-word: 42
  ][
    probe 'empty-bkock
  ]  
 
]

In the above code I have forgotten to delete ] after "do something" & close whole view. This code however runs without errors.

ps. of course I simplified the code.
greggirwin
17:54@JLCyclo the best thing to do is figure out how you can make your own PRs. The team can't support doing it for others.

1) How are you trying to make the PR (CLI, Tortoise, etc.)?
2) What error message do you get?
18:17@nedzadarek that's a good question, which leads to other questions. My first instinct was to say that it should work as is, because we can't know the use cases. e.g. templating or generating VID code, where it could be convenient. I quickly changed my mind, but now come the new questions.

VID can catch the default block case easily, and see if there's already a handler in place. But what about having on-down [a] on-down [b]? Faces are just objects, but VID is a dialect. In the general case, Red will let you reset values all you want. So that should be allowed. But VID works differently than processing an object spec block, so we can justify saying that it works differently, and add protections.

Can anyone think of a concrete use case where the current behavior is useful?

Should VID check for multiple assignments to the same actor, and disallow them, or is the current behavior simple to explain and reason about, and should be left as is for that reason?
hiiamboris
18:28@greggirwin My view is that what doesn't do anything useful should be (ideally) disallowed (if it's worth the time implementing it - in this case I'm not sure it is):
view [base on-down [probe 1] [probe 1]]
view [base on-down [probe 1] on-down [probe 2]]
greggirwin
18:43Handling the default block case should be very quick and easy (see line 381 in %VID.red). And even the other check shouldn't be bad (line 339).

We could certainly add it as an open design question, but I don't think we have a specific place for those. It's not exactly a REP.
hiiamboris
18:50Maybe we should start a wiki page as a hub with links to all open and closed design questions that were ever discussed? (I've had this idea for some time, but I only have links to a few of those)
greggirwin
19:01:+1:
JLCyclo
19:32@greggirwin
19:37I use git for windows, and I made a successful git push. To make the pull request I use a web browser, but it does not seem to work when I clic the button "new pull request", there is a no ending message "fetching latest commit". I think the web browser is obsolete and I cannot update.
endo64
21:00@JLCyclo Here I've created a PR from your fork into main repo: https://github.com/red/community/pull/15
21:03Note that your master branch is 3 commits behind from red:master, its better to pull from the upstream and merge into your repo before making further changes to prevent possible conflicts.
nedzadarek
22:33@greggirwin Does the view see the below codes differently:
1:
view [
  style b: base on-down [print 'default-b] 
  b blue 
  b red on-down [print 'not-default]
]
; default-b
; not-default

2:
view [base on-down [probe 1] [probe 1]]
view [base on-down [probe 1] on-down [probe 2]]

In the first case we are changing actors of (potentially) someone else.
In the second case we are are overriding our own actors.

Nr. 1 seems reasonable but Nr. 2 is not.

greggirwin
03:48Styles are an excellent point @nedzadarek . You *have to* be able to override actions in styles.
view [
  style b: base on-down [print 'default-b] 
  b1: b blue 
  b2: b red on-down [print 'not-default]
  button [probe b1/actors probe b2/actors]
]

And if you make a new style from an existing style, you need to be able to redefine actors there. That means either we keep things as they are, and people need to be aware that they work like objects, so it's consistent there, or somebody digs in and comes up with an alternative to propose, which we can test to see which we like better.
hiiamboris
13:29@greggirwin https://github.com/red/red/wiki/[LINKS]-Design-questions
Filled it with what I could recall. Maybe somebody will make an addition? ;)
JLCyclo
16:41@endo64 Thanks for the PR. The new update of rdbstep.red is a step debugger to step into loops, conditional branches and functions.
hiiamboris
17:27@JLCyclo Great! Although it looks like step doesn't get into loops (tried it on spuny-mortals.red). Gets into function calls though ☺
greggirwin
19:14@hiiamboris and @JLCyclo :+1:
19:15@hiiamboris great stuff in there. Thanks for the detective work.
nedzadarek
19:38:+1: @hiiamboris

GalenIvanov
07:09@greggirwin Thank you for the to "" 1 hint. It's very useful in codegolf :) Until now I have been using s: form n, I can use s: to""n from now on. The gain is much more substantial with b: to[]n when I need to convert a value to a block. Of course this is abuse of the language and has nothing to do with good programming practice.
greggirwin
GalenIvanov
07:29It's good for characters too :). By the way, a very convenient way to test non-GUI Red code is using tio.run:
07:29[Try it online!](https://tio.run/##K0pN@R@UmhId@z/RSsHMjKugKD8pVaEkX1lJTynx/38A)
07:31[TIO](https://tio.run/#) hosts 248 practical and 390 recreational programming languages, for a total of 638 languages
nedzadarek
09:32@GalenIvanov that's amazing. I haven't really tested it but it has potential. I may try some language that I haven't been able to run.
GalenIvanov
10:13@nedzadarek Yes, it is! You don't have to install or configure anything, just code.
AiguyGary_twitter
10:51Is there any way to go to a label in Red? I am in a function with thousands of if statements and I want to avoid calling the function recursively but I have a need to branch back to the the top of the list of if statements inside the same function just when certain if statements are true but not all the time. Think of it as a large state machine. Normally I try to avoid go to statements as good code practice dictates but sometimes they come in handy.
nedzadarek
11:56@AiguyGary_twitter catch + throw:
probe catch [
    if 2 = 2 [
        print "2=2"
        throw "thrown"
    ]
    if 3 = 3 [
        print "You shouldn't see this"
    ]
]
11:56
2=2
"thrown"
; == "thrown"
11:57ps. you can catch & throw with specific name (with /name refinement)
AiguyGary_twitter
12:21Thanks, I'll give that a try. But I think I've decided to throw a forever loop around the if statements and put a break at the bottom if it made it the whole way through the if statements so it could return from the function. Then if the if statement I want to return to the top is true I'll just use the word "continue" that should skip the rest of the if statements and return to the top of the loop.
nedzadarek
12:46^^ I see
lepinekong_twitter
15:33@greggirwin I have given up red for the moment because I encountered bugs I cannot solve quickly, I intend to go back to Red I guess in 1 year, when I'll get some funding and I'll pay someone instead, for now I'm switching to nodejs, meanwhile red will continue to develop and grow I hope ;)
endo64
16:30@GalenIvanov thanks for sharing tio, who added Red there?
dockimbel
16:38@GalenIvanov Nice. Is there a way to run it through the interpreter instead of compilation?
greggirwin
17:05@GalenIvanov I hadn't see, or had forgotten, TIO. Thanks for posting about that!
17:08I got an error with just 1 + 1 for the code.
Compiling /home/runner/.code.tio ...
Compiling compression library...
...using libRedRT built on 6-Jan-2019/20:35:35
*** Red Compiler Internal Error: Script Error : copy expected value argument of type: series port bitset 
*** Where: rejoin 
*** Near:  [mold copy/part pos 40] 

/srv/wrappers/red: line 5: ./.bin.tio: No such file or directory

Then saw there was no default header. Setting that to Red [] solved it. Strange error for that.
17:10@AiguyGary_twitter if it's a state machine, why not make it one?
hiiamboris
18:25> Is there any way to go to a label in Red?

Coincidentally I was thinking about the same thing a few days ago. How can I twist Red to implement a goto? It's so good for code obfuscation.... ☺
Here's my attempt: https://gitlab.com/snippets/1856859
with-goto [
	x: 0
	label 100
	probe x: x + 1
	if x < 5 [goto 100]
	if x = 5 [goto there]
	probe "won't see me!"
	[
		[
			[
				probe "level 4"
			]
			label there
			probe "level 3"
		]
		probe "level 2"
	]
	probe "level 1"
	? x
]

1
2
3
4
5
"level 3"
"level 2"
"level 1"
X is an integer! value: 5
GaryMiller
19:28Yeah, GOTO is like a gun. If you don't know where, how, and when to use it somebody's gonna get hurt! :)
nedzadarek
19:29@dockimbel is passing --encap as an argument enough? I am not sure how to check it because system/state/interpreted? returns false in both cases.
greggirwin
19:48Clever use of lit args, parse, and non-local flow control @hiiamboris. Tried a quick hack to see if you could just use issue! vals, and eliminate the label func, but will take more than a minute, as there's some subtlety there. ;^) The top/loop label is fine, but not the inner label. May try to look later.
19:50I do like the idea that it's a dialect, as with special handling in draw, so you can make the feature available in a constrained way.
hiiamboris
20:08@greggirwin Yeah.. that's curious indeed, why it doesn't work with the issue...
20:12Ah of course! because it goto-es to itself :) :) :)
20:16You're right this is simpler - https://gitlab.com/snippets/1856884
greggirwin
20:50Ah, I figured you'd see if faster than I.
20:55This example is one of those things that makes me wonder anew at how Red can be molded to new purposes. In that small amount of (albeit dense and advanced) code, you've shown something pretty amazing, IMO, because it's not just flat-code capable. It's much more dangerous. ;^) Article worthy to be sure.
20:57It's also going to make me think about how it might make some things much easier. The concept of throw/catch and non-local flow control can be very tricky to manage. I've only needed it a few times in many years, and it's very easy to get wrong. If we think in terms of "code chunks" it may offer up new ways to solve problems and assemble things.
hiiamboris
21:03> It's much more dangerous

Hahah. Dangerous indeed, as it's totally ignorant to control flow (functions, loops) inside the given code block (;
JLCyclo
21:21@hiiamboris About step into loop : the block body of the loop has to be at a constant position. For the word "repeat", the constant position for the block body is 4 . For this issue, use () to group several words in one group.
21:22For spuny-mortals.red, yous can replace `
21:23repeat i length? shelf-with-spoons [..]
21:24with

repeat i (length? shelf-with-spoons) [..]



hiiamboris
21:41@JLCyclo I see. Thanks :) Maybe it should be clarified somewhere in the help...
By the way, are you aware you can discover the arity of most expressions (like that length? ... thing) to make the debugger more flexible? I think @9214 has had some pretty successful experiments with that.

mikeparr
09:54Action! and Native! - - I'm looking at the 'help' output, and wondering why I need to be told if a word is a native or an action. Actions seem to apply to more datatypes, but this is in the spec, I think.
dockimbel
10:11@mikeparr It is for sake of consistency. The real duality that matters for users is function! vs action!/native!. Though, when ports and user-types will be introduced, knowing which native is of action! type will be more relevant.
mikeparr
11:07Thanks @dockimbel
GalenIvanov
11:43@endo64 I don't know who had added Red there - I know it was there around January 2018. Later on I requested to be updated to 0.6.4
11:46@dockimbel I don't know if there's a way to runi t hrough the interpreter.
12:04@greggirwin One of the main goals of TIO is to serve as a test environment for sharing the solutions of the problems in Programming Puzzles & Code Golf section of StackExchange. That's why the edit fields are split to "Header" , "Code", "Footer" and so on. The submissions tp PPCG only count the length (in bytes ans characters) in the "Code" section. And yes, you need to add Red[] in the Header or in Code :)
jlhouchin_gitlab
16:05Conversation moved from red/red
@dockimbel
> @jlhouchin_gitlab As mentioned above by Gregg and me, split is a performance and memory killer and should be replaced in your code by find/last/tail:
>
lisp
> price: to float! find/last/tail line ","
>

> That said, the GC should still compensate (at the expense of the running time) for the huge number of extra allocations done by split in your code...
>
> I think you can move this discussion to red/help room as it is more appropriate.

I understand what you and Gregg are appropriately saying about split. At some point it will be appropriately replaced but not by what you are suggesting. As I mentioned this is profiling test to compare different languages and implementations. In all of the rest of my code and in other tests, every value of the split line is used. So while in this limited example I only use the last value. In all other uses of the historical code it looks like this:

>datetime,open,high,low,close
>2019-05-05T22:00:00Z,1.11800,1.11814,1.11800,1.11808

or this

>datetime,price
>2019-05-05T22:00:00Z,1.11800

While the data appears uniform, it does not arrive to me from the api that way. Here it is uniform because I made it so. So while it arrives via the api I may have no way of knowing whether or not the date and time have milliseconds. Or whether the floats have any trailing 0s.

It may have come to me as such:
>2019-05-05T22:00:00.000000000Z,1.118,1.11814,1.118,1.11808

And in my processing I truncated and padded to make it uniform. And if it is actual tick data with millisecond timing I would possible pad 0s to the time.

But ultimately should I go with Red.
(And I currently do not see any better solution for programming anywhere else at the moment or in any visible future. And I thank you for providing that opportunity and vision for such a system.)

I will be doing as Gregg suggested and processing my data and saving in Red format. All of the csv files on my computer are of the formatting of my choosing. Saving them in Red format instead of csv in order to improve performance and make loading them into Red is seemingly one of the easiest changes to make and I would think allow me to clean up a lot of code. :)

The file in this particular test was simply chosen because it is similar, was able to do what I wanted to test, and was publicly available.

16:10Is there something other than 'split which would split the csv string into its values, preserving all the values? Do so faster and more efficiently than 'split? I played with 'find briefly. But as the docs say it returns the tail. But I also need the head.
dockimbel
16:20@jlhouchin_gitlab
> Is there something other than 'split which would split the csv string into its values, preserving all the values? Do so faster and more efficiently than 'split? I played with 'find briefly. But as the docs say it returns the tail. But I also need the head.

Parse dialect is there for parsing and extracting values. You don't need to cut the input file in lines, just feed the whole file buffer to Parse, and with appropriate rules, you can extract all the data you need without unnecessary memory overhead.
endo64
16:21@jlhouchin_gitlab You could write something in parse with collect to split csv, in the end it would be very similar to split (see its source by source split) but you may gain little performance there.
jlhouchin_gitlab
16:22@dockimbel
Thanks. I hadn't thought about parse. I haven't gotten that far into my Red education. I do look forward to it when I have enough of the basics.
nedzadarek
16:28@jlhouchin_gitlab what do you mean by
> split the csv string into its values, preserving all the values

jlhouchin_gitlab
17:14@nedzadarek
Simply this. The 'find suggestion loses the head value. At least to my understanding. And does not seem to make it easier to extract individual values.

When I
'''red
split "2019-05-05T22:00:00.000000000Z,1.118,1.11814,1.118,1.11808" ","
'''
I want [2019-05-05T22:00:00.000000000Z 1.118 1.11814 1.118 1.11808]
not what I get with 'find. Find as per the conversation was only returning the very last value as that was what I was calculating in the sample test. However, in general, I want every value. 'find does not seem to provide that.

That is what I meant. Now I understand the values above have not been coerced into their types but will be returned as strings.
endo64
17:22Yes, you need to load them.
greggirwin
18:04@jlhouchin_gitlab in this example, you can cheat easily.
>> s: "2019-05-05T22:00:00.000000000Z,1.118,1.11814,1.118,1.11808"
== {2019-05-05T22:00:00.000000000Z,1.118,1.11814,1.118,1.11808}
>> load replace/all s "," " "
== [5-May-2019/22:00:00 1.118 1.11814 1.118 1.11808]
18:05Replace, however is intended to be flexible and not high performance. So you'll take a hit there.
18:07You can see how to do that with system/lexer/pre-load, about halfway down in https://www.red-lang.org/2017/03/062-libred-and-macros.html .
18:08The catch is that if you have data that still isn't loadable Red, you'll have to do more massaging on it before using load.
18:10As you convert your data, be aware that read/write and load/save are your basic I/O functions, where load/save are intended to make working with Red data easier, and read/write are more general purpose. You can mix and match however it works best though.
jlhouchin_gitlab
18:22I mentioned in a different thread that I need to access a REST API. The api prefers persistent connections and restricts new connections to 2 per second.
Does Red support persistent connections?
Also they have a streaming api?
Does Red support http streaming?

I have not seen anyway in Red to make http calls which include headers. Is any of this currently possible in Red.

Or will I need to drop a level. If so where do I find the http code that read uses to retrieve a webpage.

Thanks.

[From the OANDA docs](http://developer.oanda.com/rest-live-v20/pricing-ep/)

>curl \
-H "Authorization: Bearer 757302104546640350fcd0874ce4a0d7-184a182bde8c67df7845aaa4db1cef66" \
"https://stream-fxtrade.oanda.com/v3/accounts/101-001-1914781-001/pricing/stream?instruments=EUR_USD%2CUSD_CAD"
>
>Response Headers
>
>HTTP/1.1 200 OK
>Access-Control-Allow-Headers: Authorization, Content-Type, Accept-Datetime-Format, OANDA-Agent
>Access-Control-Allow-Methods: PUT, PATCH, POST, GET, OPTIONS, DELETE
>Access-Control-Allow-Origin: *
>Content-Type: application/octet-stream
18:27@greggirwin
> As you convert your data, be aware that read/write and load/save are your basic I/O functions, where load/save are intended to make working with Red data easier, and read/write are more general purpose. You can mix and match however it works best though.

Should I settle on Red and this is looking strong. I would want to learn to load/save well as it seems to be the best way to handle data in Red. Especially if I do not care to use it outside of Red. I am looking for a language that I can spend years with. That I can make lifelong friends with and it accomplish (if possible) everything that I need to do. Red seems like a really nice place to settle down. Thanks for all your (and everyones) help.
greggirwin
18:29Red doesn't support persistent connections at this time. It will come with Full I/O in 0.7.0.
18:30I've used Rebol, Red's predecessor, since 2001, and still haven't found anything better for general use. It really spoils you. The only problem is that once you get used to certain aspects of it, there's no going back. It ruins other languages for you. :^)
18:32On HTTP requests: https://github.com/red/red/wiki/%5BDOC%5D-Guru-Meditations#how-to-make-http-requests
jlhouchin_gitlab
19:02@greggirwin
Thanks for the information.

I am very agreeable to being spoiled or ruined. I thought Smalltalk would be it. But alas no. I am just working my way reading all the documentation I can. Getting Red into my head.

I am glad there is a current way to handle the headers. That is a very important aspect to any REST api that requires authentication to access a certain account's information.

Persistent connections are nice. But I can deal with the 2 request per second limitation until then.

Would streaming possibly also come with 0.7.0? Or at some point? Streaming is required for using certain APIs, such as FIX. Nothing I require at the moment.
nedzadarek
20:24@jlhouchin_gitlab
> The 'find suggestion loses the head value

Incorrect. You can use head:
arr: [a 1 b 2 c 3]
; [a 1 b 2 c 3]
  find arr 'b
; [b 2 c 3]
  head find arr 'b
; [a 1 b 2 c 3]

Some functions (e.g. insert, append don't change its head value.

> And does not seem to make it easier to extract individual values.

Yes, as it finds only 1 value and series only holds starting (not ending) position - so you have to use some kind of loop or something:
s: "2019-05-05T22:00:00.000000000Z,1.118,1.11814,1.118,1.11808"
; {2019-05-05T22:00:00.000000000Z,1.118,1.11814,1.118,1.11808}
  while [not tail? s] [
    f: find s #","
    if none? f [s: head s break]
    change f #" "
    s: next f
    ]
  s
; {2019-05-05T22:00:00.000000000Z 1.118 1.11814 1.118 1.11808}

I think it should be better than running whole series:
s: "2019-05-05T22:00:00.000000000Z,1.118,1.11814,1.118,1.11808"
  forall s [
            if #"," = s/1 [
              change s #" "
           ]
  ]

20:32Paste this in the Red and some text editor (notepad on the Windows works)
str: "2019-05-05T22:00:00.000000000Z,1.118,1.11814,1.118,1.11808"
probe str

greggirwin
20:39Streaming will come with full I/O, as you will have low level TCP control when needed.
20:42@nedzadarek shows, writing an optimized replace func is pretty easy. And since there are many ways to do it, we may see The Great Red Optimizer awaken and profile a few. :^)
20:43An R/S version will win the speed contest of course, especially if limited to strings and single char replacements.
Sunnypt
22:27I have found this site. this is awesome site. hundreds of Red examples here. http://www.mycode4fun.co.uk/About-Red-Programming and here. http://www.mycode4fun.co.uk/red-beginners-reference-guide but the best thing I found is a drag and dop gui maker , like VB you drag onto a grid and it generates the red code. this is so good. it's here. http://www.mycode4fun.co.uk/red-apps

greggirwin
22:27@Sunnypt there are some other people writing tools like that as well.
jlhouchin_gitlab
22:28@nedzadarek
Thanks. I will try out later and learn. But I am not understanding this:

> Paste this in the Red and some text editor (notepad on the Windows works)

red
str: "2019-05-05T22:00:00.000000000Z,1.118,1.11814,1.118,1.11808"
probe str
22:28I am trying to request an url with headers and am having problems. I do not know that I am doing it right. It is for the api I mentioned above.
When I copy and paste my information into the curl template above it works. It also works in the 3 other implementations I have.

I crash and get this error.

*** Runtime Error 1: access violation
*** at: F7EBB38Dh

I know you can't run this code as you may not have an account with this broker. But maybe the error is visible.

Any help greatly appreciated.

probe write/info "https://api-fxpractice.oanda.com/v3/accounts/MY-ACCOUNT-ID/pricing?instruments=EUR_USD" [
    GET
    [ Authorization: "Authorization: Bearer MY-ACCOUNT-TOKEN"
      Content-Type: "Content-Type: application/json"
    ]
]
greggirwin
22:30@Sunnypt we can collect more general tool links [here](https://github.com/red/red/wiki/%5BLINKS%5D-Tools-(Written-in-Red)), but more IDE type projects are listed [here](https://github.com/red/red/wiki/%5BLINKS%5D-GUI-Programming). If @virtualAlan 's tool isn't there, please add a link for it.
22:33@jlhouchin_gitlab it shouldn't crash (are you doing it in the REPL?), but the first problem is that you're trying to write to a string, not a url, which is not allowed. If you paste your code above into the REPL, you should see that error.
22:34Here's what I get:
>> probe write/info https://api-fxpractice.oanda.com/v3/accounts/MY-ACCOUNT-ID/pricing?instruments=EUR_USD [
[        GET
[        [ Authorization: "Authorization: Bearer MY-ACCOUNT-TOKEN"
[          Content-Type: "Content-Type: application/json"
[        ]
[    ]
[400 #(
    Content-Length: "58"
    Content-Type: "application/json"
    Access-Control-Allow-Headers: {Authorization, Content-Type, Accept-Datetime-Format, OANDA-Agent, ETag}
    Access-Control-Allow-Methods: "PUT, PATCH, POST, GET, OPTIONS, DELETE"
    Access-Control-Allow-Origin: "*"
    Access-Control-Expose-Headers: "ETag, RequestID"
) {{"errorMessage":"Invalid value specified for 'accountID'"}}]
== [400 #(
    Content-Length: "58"
    Content-Type: "application/json"
    Access-Control-Allow-Headers: {Authorization...
22:34You just need to remove the quotes around your URL. They are a literal type in Red.
gltewalt
22:34I the GUI Console, I'm getting (escape) returned for the string "2019-05-05T22:00:00.000000000Z,1.118,1.11814,1.118,1.11808".
greggirwin
22:35That message may have been a typo from @nedzadarek.
22:37@jlhouchin_gitlab if it crashes when compiled, it looks like you get a chance at a new debug ticket. ;^) Search issues to make sure there's not another one covering it already.
Sunnypt
22:38@greggirwin thank you - dont know how to add a link, not very user friendly
greggirwin
22:38It's a wiki, so just click Edit near the top of the page, and format your new link like the others. Or ask for more help. :^)
Sunnypt
22:47Gregg, yes sorry, bit of a newcomer , am doing my best but that's why a code generater is helpful to me
greggirwin
22:51No problem at all.
22:53I specialized in VB for 11 years, so I get it. The funny thing is, once I got used to VID, I largely gave up on my own GUI IDE experiments. I do think they will be good for a lot of people though, and worth pursuing.
nedzadarek
23:14@greggirwin Yes.
how about optimised (for different things) string's types, or in general, series' types?

@jlhouchin_gitlab [about this](https://gitter.im/red/help?at=5cdc9297f52a2375163b1980)
At the end of the string there is one more character. You cannot see it in the Red (there is (escape) when you hit the enter key as pointed by @gltewalt ). notepad shows this character as something like this: .
I posted it because I think the Red should display all characters, even as some thing like this .

jlhouchin_gitlab
00:31@greggirwin
> Here's what I get:

>> probe write/info https://api-fxpractice.oanda.com/v3/accounts/MY-ACCOUNT-ID/pricing?instruments=EUR_USD [
[        GET
[        [ Authorization: "Authorization: Bearer MY-ACCOUNT-TOKEN"
[          Content-Type: "Content-Type: application/json"
[        ]
[    ]
[400 #(
    Content-Length: "58"
    Content-Type: "application/json"
    Access-Control-Allow-Headers: {Authorization, Content-Type, Accept-Datetime-Format, OANDA-Agent, ETag}
    Access-Control-Allow-Methods: "PUT, PATCH, POST, GET, OPTIONS, DELETE"
    Access-Control-Allow-Origin: "*"
    Access-Control-Expose-Headers: "ETag, RequestID"
) {{"errorMessage":"Invalid value specified for 'accountID'"}}]
== [400 #(
    Content-Length: "58"
    Content-Type: "application/json"
    Access-Control-Allow-Headers: {Authorization...



Thanks. I fixed that. Now I get this authorization error. I do not know why. The ID and the TOKEN is correct.
Thanks for working with me.

[401 #(
    Access-Control-Allow-Headers: {Authorization, Content-Type, Accept-Datetime-Format, OANDA-Agent, ETag}
    Access-Control-Allow-Methods: "PUT, PATCH, POST, GET, OPTIONS, DELETE"
    Access-Control-Allow-Origin: "*"
    Access-Control-Expose-Headers: "ETag, RequestID"
    Content-Length: "65"
    Content-Type: "application/json"
) {{"errorMessage":"Insufficient authorization to perform request."}}]


This Python code with the same ID and TOKEN works

import urllib.request
req = urllib.request.Request("https://api-fxpractice.oanda.com/v3/accounts/MY-ACCOUNT-ID/pricing?instruments=EUR_USD")
req.add_header("Content-Type", "application/json")
req.add_header("Authorization", "Bearer MY-ACCOUNT-TOKEN")
r = urllib.request.urlopen(req)
print(r.read())

##prints the below response.

b'{"time":"2019-05-16T00:15:18.484475526Z","prices":[{"type":"PRICE","time":"2019-05-16T00:15:05.242899793Z","bids":[{"price":"1.12052","liquidity":10000000}],"asks":[{"price":"1.12065","liquidity":10000000}],"closeoutBid":"1.12037","closeoutAsk":"1.12080","status":"tradeable","tradeable":true,"unitsAvailable":{"default":{"long":"10000000","short":"10000000"},"openOnly":{"long":"10000000","short":"0"},"reduceFirst":{"long":"10000000","short":"10000000"},"reduceOnly":{"long":"0","short":"10000000"}},"quoteHomeConversionFactors":{"positiveUnits":"1.00000000","negativeUnits":"1.00000000"},"instrument":"EUR_USD"}]}'





gltewalt
04:02Are Bearer and MY-ACCOUNT-TOKEN acting as variables?
greggirwin
04:23@jlhouchin_gitlab I didn't look closely at your request. My fault. You have the header names in the content, duplicated. What about this?
probe write/info https://api-fxpractice.oanda.com/v3/accounts/MY-ACCOUNT-ID/pricing?instruments=EUR_USD [
	GET
	[
		Authorization: "Bearer MY-ACCOUNT-TOKEN"
		Content-Type: "application/json"
	]
]
gltewalt
04:41Is write/info implemented yet? It doesn't have a summary in help.
06:52Is there no easy or clean way to interpolate with url!?
06:53
>> val: '?idx=
== ?idx=
>> compose [http://www.me.com/(val)]
== [http://www.me.com/ ?idx=]
>> load trim/all form compose [http://www.me.com/(val)]
== http://www.me.com/?idx=
06:55
>> probe http://www.me.com/:val
http://www.me.com/:val
== http://www.me.com/:val
>> probe http://www.me.com/(val)
http://www.me.com/
== ?idx=
endo64
06:56append?
>> append http://www.me.com/ val
== http://www.me.com/?idx=
gltewalt
07:00Thanks.
Simple enough, but it seems like it would be good to pull the value in directly with :val
07:01http://www.imtired.com/:val
07:02Or (val)
endo64
07:06But: is a valid character for URLs
gltewalt
07:07Except for the first :
07:11: Can’t be first or last character
meijeru
07:13You would like a treatment analogous to a path! value, but the / in url! and file! values has a different meaning than the /in paths. Nevertheless, a _literal_ value may be added, like u: http://abc u/f == http://abc/f. That design decision was taken over from REBOL, and one could put that into question, since unlike with paths, it is not allowed to append an _evaluated_ value.
gltewalt
07:22What was the reasoning behind preventing evaluated values from being appended?
meijeru
08:00Good question!
nedzadarek
09:57@gltewalt how about using strings:
v: ":f"
; ":f"
  url: http://www.me.com/
; http://www.me.com/
  url/:v
; http://www.me.com/:f
  url/(v)
; http://www.me.com/:f

jlhouchin_gitlab
10:31@greggirwin
@jlhouchin_gitlab I didn't look closely at your request. My fault. You have the header names in the content, duplicated. What about this?
probe write/info https://api-fxpractice.oanda.com/v3/accounts/MY-ACCOUNT-ID/pricing?instruments=EUR_USD [
	GET
	[
		Authorization: "Bearer MY-ACCOUNT-TOKEN"
		Content-Type: "application/json"
	]
]

My bad. I thought I had already tried that combination. I don't know. But now when I compile, it works.

The reason I did it that way is because the sole example I have is in the Guru Meditation link. It is the way it is done there.

I am good with this.
I can start porting my code over and creating the app. :)

I will have to watch for errors and such. I want my app to be exceptionally fault tolerant. I want the network outages handled gracefully. I want to handle errors on the server side gracefully.

Thanks again for the help. Does this mean I am on the way to becoming a Reducer? :)
10:40

My original code had this:
rt-account-token: "Bearer MY-ACCOUNT-TOKEN"
...
                Authorization: rt-account-token ; "Bearer  MY-ACCOUNT-TOKEN"
...


The only change to my code. Compiles fine, and I get this error:
*** Runtime Error 1: access violation
*** at: F7E9ACC8h


I would prefer to use variables if I could and pass them into the func. Or have the func read them from a config file. I would prefer not to hard code them.

I am sure there is something very basic to Red that I haven't got to yet and am missing.
Any help greatly appreciated. Thanks.>
rebolek
10:43@jlhouchin_gitlab

You get this error because current HTTP(S) implementation supports only string values for headers/data. It's a bug that's not going to be fixed in current implementation, because ports are being rewritten, so it makes no sense to waste time on it. Therefore currently it's user's duty, to make sure that all passed data are strings. Or you could use my [HTTP-tools](https://github.com/rebolek/red-tools/blob/master/http-tools.red), that among other things make sure that all passed values are converted to string.

send-request/auth https://api-fxpractice.oanda.com/v3/accounts/MY-ACCOUNT-ID/pricing?instruments=EUR_USD 'GET 'Bearer MY-ACCOUNT-TOKEN
10:45If you want to do it maunaly, use something like
probe write/info https://api-fxpractice.oanda.com/v3/accounts/MY-ACCOUNT-ID/pricing?instruments=EUR_USD compose/deep [
    GET
    [
        Authorization: (rejoin ["Bearer " MY-ACCOUNT-TOKEN])
        Content-Type: "application/json"
    ]
]
endo64
11:01Or you can find, remove and insert your ID there:
>> url: https://api-fxpractice.oanda.com/v3/accounts/MY-ACCOUNT-ID/pricing?instruments=EUR_USD
>> head insert remove/part find url "MY-ACCOUNT-ID" 13 "XYZ"
== https://api-fxpractice.oanda.com/v3/accounts/XYZ/pricing?instruments=EUR_USD


13 is the length of the string MY-ACCOUNT-ID.
11:02If your account ID and the string is same length then change would work too:
>> head change find url "MY-ACCOUNT-ID" "1234567890123"
== https://api-fxpractice.oanda.com/v3/accounts/1234567890123/pricing?instruments=EUR_USD
11:03Note that if you don't want to change the url just copy it. >> head change find copy url "MY-ACCOUNT-ID" "1234567890123"
rebolek
11:15@endo64 the problem is not MY-ACCOUNT-ID in url!, but MY-ACCOUNT-TOKEN in header data.
11:16MY-ACCOUNT-ID can be easily solved with rejoin for example, which is simpler that head insert remove/part find url "MY-ACCOUNT-ID" 13 "XYZ"
jlhouchin_gitlab
11:32@rebolek
Thanks for all your suggestions and information.
The below compiles and runs.

Red []
rt-account-id: "MY-ACCOUNT-ID"
rt-account-token: "MY-ACCOUNT-TOKEN"
rt-account-hostname: "api-fxpractice.oanda.com"
instrument: "EUR_USD"
price-url: to-url (rejoin ["https://" rt-account-hostname "/v3/accounts/" rt-account-id "/pricing?instruments=" instrument])

price-loop: func [] [
    count: 0
    while [count < 10] [
        count: count + 1
        print [count now]
        probe write/info price-url compose/deep [
            GET
            [
                Authorization: (rejoin ["Bearer " rt-account-token])
                Content-Type: "application/json"
            ]
        ]
    ]
]

price-loop


rebolek
11:33@jlhouchin_gitlab :+1:
endo64
13:26@rebolek Ah, you're right, I didn't exactly follow, sorry
greggirwin
16:10@jlhouchin_gitlab you are well on your way. :^)

Note that you're using compose and rejoin in the loop, which is fine and low impact compared to network activity, but you can build your header block just once and use that inside the loop. e.g.
Red []
rt-account-id: "MY-ACCOUNT-ID"
rt-account-token: "MY-ACCOUNT-TOKEN"
rt-account-hostname: "api-fxpractice.oanda.com"
instrument: "EUR_USD"
price-url: to-url (rejoin ["https://" rt-account-hostname "/v3/accounts/" rt-account-id "/pricing?instruments=" instrument])

price-loop: function [] [
    count: 0
    req-info: compose/deep [
        GET
        [
            Authorization: (rejoin ["Bearer " rt-account-token])
            Content-Type: "application/json"
        ]
    ]
    while [count < 10] [
        count: count + 1
        print [count now]
        probe write/info price-url req-info
    ]
]

price-loop

Note that I changed func to function as well. The difference in the two is that function automatically localizes set-words in the body, while func does not. Func lets you list them in the spec using a /local refinement.
16:57> Nevertheless, a literal value may be added, like u: http://abc u/f == http://abc/f. That design decision was taken over from REBOL, and one could put that into question, since unlike with paths, it is not allowed to append an evaluated value.

@gltewalt @meijeru this behavior was carried over from Rebol because it's so useful. Urls are a type of string, but strings are general, while URLs also contain the concept of a path, a hierarchy. They can also legally contain : chars, so supporting get-word syntax in them means we would need a way to suppress that evaluation, potentially on a per-segment level. That will get ugly fast.

A small correction here is that there is no "appending" going on, as append works just fine with urls. What you have is a path syntax, and each type gets to determine how it handles path syntax (when accessed via a word reference, so it's a real path!).

I was going to suggest my composite func, but it currently wants to read url and file params. I will revisit that decision today.
gltewalt
17:00I doesn’t have to be get-word. Maybe paren.
I’ll look at composite if it’s on your GitHub
greggirwin
17:03https://gist.github.com/greggirwin/d40a0e3b4c8de31a7d3b82695b9b4b03 which is out of date. I'll update with my local version shortly.
17:15Gist updated.
17:18Parens are valid in URLs, though Red doesn't allow them today. If someone wants to take on the analysis for that, showing pros and cons, we will happily evaluate it.
addos
18:50Hi, so I was trying to do socket stuff in rebol. I connection: open/lines tcp://hostname:port, and I do a while loop, where I try to read connection/1, and I notice that eventually this times out. Is there some other way I am supposed to read from the socket?
jlhouchin_gitlab
19:48> @jlhouchin_gitlab you are well on your way. :^)
>
> Note that you're using compose and rejoin in the loop, which is fine and low impact compared to network activity, but you can build your header block just once and use that inside the loop. e.g.
>
> Red []
> rt-account-id: "MY-ACCOUNT-ID"
> rt-account-token: "MY-ACCOUNT-TOKEN"
> rt-account-hostname: "api-fxpractice.oanda.com"
> instrument: "EUR_USD"
> price-url: to-url (rejoin ["https://" rt-account-hostname "/v3/accounts/" rt-account-id "/pricing?instruments=" instrument])
> 
> price-loop: function [] [
>     count: 0
>     req-info: compose/deep [
>         GET
>         [
>             Authorization: (rejoin ["Bearer " rt-account-token])
>             Content-Type: "application/json"
>         ]
>     ]
>     while [count < 10] [
>         count: count + 1
>         print [count now]
>         probe write/info price-url req-info
>     ]
> ]
> 
> price-loop
>

> Note that I changed func to function as well. The difference in the two is that function automatically localizes set-words in the body, while func does not. Func lets you list them in the spec using a /local refinement.

Thanks for the information.
I hadn't thought that out yet. I am kind of playing around porting some of my code to Red as I try to learn. That is one of the ways I like to learn is by implementing (porting) what I have already done somewhere else. It is at least a problem I have some familiarity with.

However, Red is different enough that I don't notice some of the simple things like that right away. In fact that code wasn't a port at all but a simple from the scratch write of something I do a lot of.

The one thing I haven't yet wrapped my brain around in Red is that place the words or variables inside of the block doesn't make the value of them available to the block.

In most languages I have used, placing a string variable inside of a block or parenthesis is like actually placing the string inside. Or an integer or float or whatever the variables value is.

I still have to cross that bridge of learning. But what I see in Red, it is worth whatever effort is required. :)

greggirwin
19:50@addos some examples:
- http://www.rebol.org/view-script.r?script=tcpserver.r
- http://rebol.net/cookbook/recipes/0034.html
- http://rebol.net/cookbook/recipes/0028.html
19:51@jlhouchin_gitlab porting is a good way to start.
19:53If I understand what you're saying, its a key element of understanding Red. That is, when evaluation occurs. Blocks are not evaluated by default. It can be tricky, because a function like print evaluates them for you, making it look like they're always evaluated.
>> str: "abc" 
== "abc"
>> num: 123
== 123
>> blk: [str num]
== [str num]
>> reduce blk
== ["abc" 123]
19:57Reduce evaluates a block, which may be what you're after. Compose lets you evaluate only the parts of a block that are in parens. Paren! values themselves are evaluated automatically, but the block containing them has to be evaluated for them to be processed.
>> blk: [str num (1 + 2)]
== [str num (1 + 2)]
>> type? last blk
== paren!
>> reduce blk
== ["abc" 123 3]

In normal code, parens will evaluate just as you expect, but if you create blocks that aren't evaluated, they can be passed around as Red data, including any parens inside them. It's a learning curve. :^)
nedzadarek
19:58@gltewalt
> I doesn’t have to be get-word. Maybe paren.
> I’ll look at composite if it’s on your GitHub

strings?
19:58^^ unless I'm missing something
greggirwin
19:58Another thing you may hit is that math precedence is always left to right, unless you use the math dialect, which gives certain operators precedence. Parens are handy to make precedence clear.
nedzadarek
20:17@greggirwin @jlhouchin_gitlab
> Func lets you list them in the spec using a /local refinement.

function does this as well. In my opinion, people should use function by default.
has and does some uses in "short functions".
func is when you don't want to use /extern from the function... which is something that may change lots of stuffs without user even knowing it.
greggirwin
20:24@nedzadarek correct, /local is still available in function, because you can set values with set or in parse, for example, that the set-word collection logic won't catch.
20:29> In my opinion, people should use function by default.

Saying "people should", when applied to broad statements, presumes too much in most cases. :^)
20:31We'll certainly make recommendations about best practices at times, but carefully and with strong rationale behind them.
moliad
20:31in this case, I'll stand behind @nedzadarek, using func is not a good practice.
20:32:tongue:
hiiamboris
20:35func is great in objects (otherwise one has to deal with self/ all the time)
greggirwin
20:35I disagree. It's a different approach, but not a lesser one IMO. Nor do I think that design decision was made lightly. I do agree that people coming from other langs will find function more familiar or comfortable in some ways, but that doesn't mean it's always a better choice.
moliad
20:35using func generates so many bugs.
greggirwin
20:36That hasn't been my experience @moliad.
rebolek
20:36No, not caring about your words generates bugs :)
nedzadarek
20:36@greggirwin
> @nedzadarek correct, /local is still available in function, because you can set values with set or in parse, for example, that the set-word collection logic won't catch.

that's why I made [function-all-local](https://github.com/nedzadarek/function-all-local)... haven't used it since I made it thought.

greggirwin
20:37@nedzadarek I've written *so many* things through the years, thinking "This will help", and then found I was wrong.
moliad
20:39@greggirwin you surprise me :smile: I find absolutely no positives in side-effects. I don't even store my globals in the global context anymore. I store them in a globals object. that way I have even less bugs related to code cross binding without my knowledge.
greggirwin
20:40For all we agree on Max, you and I have very different styles sometimes. :^)

But I did *not* say that side-effects were a net positive.
moliad
20:41yep... I think this is the first time we have such an opposite POV :smirk:
greggirwin
20:44There are pros and cons to func and function, and you write, review, and read code differently based on their use, as with has and does. Each has their place.
20:50Function can be seductive, because you write code thinking "Whew! Don't have to worry about words leaking out!", but you may write larger functions, and do so more quickly, with less review and consideration, than you would with func. You also don't have a visible list of what locals are used, and may duplicate values under different names, obscuring intent, or even leading to other bugs.

One place function is very helpful is when prototyping functions, where you're changing things a lot, and may miss a local during a change, or just move faster by not having to list them.
nedzadarek
20:52@greggirwin
> but that doesn't mean it's always a better choice.

I think having side effects in one place (/extern) is good. Maybe catching all set-words might cause some problems but I would rather extern than local it.

> I've written so many things through the years, thinking "This will help", and then found I was wrong.

It might be good but as always I look for improvements. And I try to be open minded and listen to people with more experience, like you.
20:54> Function can be seductive(...)other bugs

I got this problem with parse. But still, you can write "clear" function. It's not a problem of function but rather programmer.
JLCyclo
20:55@hiiamboris Step into loops looks for the block body at a constant position. Step into conditional blocks (if, unless, either, case..) uses fetch-next to find the block bodies. I think fetch-next is not the perfect solution for conditional blocks. I have some cases that I have to add ( and ) to group expressions to detect the block bodies for stepping into. I can make some tests to add fecth-next for loops. The perfect solution would be to move into the script block to analyse as do/next without doing it.
greggirwin
20:55> It's not a problem of function but rather programmer.

It's also not a problem of func but rather the programmer. ;^)
nedzadarek
20:57ps. as fair I remember [topaz parse](https://github.com/giesse/red-topaz-parse) doesn't have this problem because it uses set-words instead of set X value.
20:58@greggirwin
> It's also not a problem of func but rather the programmer. ;^)

Yes, but function has less thing to worry about. So, for me, it's still better default choice.
greggirwin
20:58My point is that neither func or function are "better", they are different and each should be used where most appropriate.
20:59And what seems best to the people working on the code.
21:00I'm fine with you making it your personal default. :^)
nedzadarek
21:11@greggirwin
I think it's more about your usage of func(which is not bad) that makes it better in your eyes.
Well, I'm fine with anything as far anyone write readable code.
dander
21:21My feeling is that for naive bugs, which are possible to write with either func or function, it's more likely to be a subtle effect for func, but more likely to be obvious with function. Certainly it depends on what you are doing, but I tend to think that function is a safer default, especially for beginners. Having tools that show you via coloration or some other means which words are local or global would help a lot too.

moliad
06:40I haven't used func for about 10 years. actually I've used it twice, cause it was used to reset all members of an object... I stopped using it the day I lost 2 days trying to track a random leaking function destroying the round function, being used by another function doing draw.... 10 files appart and 2 months time earlier. yes.. I had used used round instead of circle and never realized round was also a math function :-)
06:41anyhow... on a totally different level, can any one tell me if we can do http POST calls in any ways using Red?
06:42I need to send documents to a little web service (no https needed).
rebolek
06:43@moliad write/info link [POST [post: "data"]] or use my send-request wrapper from https://github.com/rebolek/red-tools/blob/master/http-tools.red
06:43HTTPS is no problem, Red supports both.
moliad
06:45thanks for this... the http-tools wrapper looks cools !
rebolek
06:46@moliad thanks. I does handle lot of small things that you'll probably encounter when using write/info, like that write/info link [POST [key: value]] will result in crash, because value must be string and so on.
moliad
06:47@ rebolek why do read and write have no documentation for /info ? any idea?
rebolek
06:47@moliad I believe that it will come with full IO support, it's a temporary stuff now.
06:48Also see https://github.com/red/red/wiki/[DOC]-Guru-Meditations#how-to-make-http-requests
moliad
06:49:thumbsup:
07:00works flawlessly ... AND UTF8 ... wow feels good to be in 2019 with the rest of the world :wink:
rebolek
07:00:smile:
07:01Well rest of the world is moving to HTTP/2 and HTTP/3, so it will take some time to get there, but it's much better than non-UTF HTTP only :)
moliad
07:02does feel a bit weird to use write to read data from a server, but I guess its just habit
rebolek
07:02You have to think about it as writing data to server to get some response.
moliad
07:04yep, not all abstraction have the same level of feel for all devices .... http doesn't have different read and write modes. so it can feel weird
07:04(either way)
mikeparr
14:56The mod function should work with pair!, the spec says.
Below, I expected the result: 10x1 - - but got:
>> mod 100x10 30x3
*** Script Error: cannot compare 10x1 with 0

hiiamboris
15:14@mikeparr https://github.com/red/red/issues/2674
mikeparr
15:46@hiiamboris mod - thanks - should have checked!
addos
16:00@greggirwin can you help explain exactly what this is doing in this code?
- http://rebol.net/cookbook/recipes/0028.html
16:00in the client
16:01it is doing a foreach msg any [copy port []] { }
16:01err [ ]
greggirwin
17:21It's copying incoming data out of the port, and if no data is there, it uses an empty block as the default, which causes nothing to be put into the output area.
jlhouchin_gitlab
17:37@greggirwin
> Another thing you may hit is that math precedence is always left to right, unless you use the math dialect, which gives certain operators precedence. Parens are handy to make precedence clear.

I can deal with that. Smalltalk is also left to right, 1 indexed.

I generally like parens anyway and not have to depend on an implementation's precedence.

Yes. I need to be alert when something is in an unevaluated block. But how do I tell if something is an unevaluated block? And there is how is the block being evaluated?

instruments: ["EUR_USD" "USD_JPY"] 
to url! [https :rt-account-hostname "v3/accounts" :rt-account-id "pricing?instruments="  ["EUR_USD" "USD_JPY"]]


to url! is evaluating the block in a manner of speaking. It does act upon the values.
https is not a string but is being joined to strings. When it sees the block with instruments it will convert to a string and delimit with %20.

Why can't it take a variable which is a string and insert the string along with the other strings, literals and blocks?

Seems like it would be something useful for to url! to do.
addos
17:50Gregg thanks
moliad
17:56@jlhouchin_gitlab if we want to be precise we can say that no block is ever evaluated by itself. it has to go through a dialect or function of some kind. This is hidden at the top level since the body of any application (which is a block) will be evaluated by the DO dialect. this dialect is also used or the basis behind by many other functions like most loops, functions, conditionals and a few native reducing functions like REDUCE and COMPOSE
greggirwin
17:57@jlhouchin_gitlab

> But how do I tell if something is an unevaluated block? And there is how is the block being evaluated?

*That* is one of the great mysteries that experience teaches you. :^) Blocks are unevaluated by default. Do and reduce perform a general evaluation, and functions that take blocks *may* evaluate them. For example, foreach does *not* its series arg, but it *does* evaluate its body arg. But while evaluates both its cond and body args. If that seems inconsistent, think about it a bit. Red is fun for making you think.

There are a couple gotchas, to humble you, and me, and many others. Switch is one, because it doesn't evaluate its cases arg. This comes back to the importance of literal forms, and what ends up being a net win, even if it trips us up on occasion.

The other thing you'll find is that some values, when rendered as text, are indistinguishable from their true nature. This, along with copying series values, will mess with you at times as you climb Mount Redsuvius. e.g. the literals, [true false none] and datatypes. Just ask if you get stuck or need an explanation.
17:57I'm always too slow. ;^)
moliad
17:57hehe two different simultaneous explanations :-)
greggirwin
17:58@jlhouchin_gitlab here's an example.
a: 1 b: 2 c: 3
foreach val [a b c][print val]
foreach val reduce [a b c][print val]

But we won't get into binding yet, as that will make your head explode. ;^)
18:10In the case of your url example, you can see that it's using the text, formed to become part of the url! value, which is a type of string.

If you ask "Why not evaluate by default?", it's similar to the "Why not copy by default?" answer. If Red evaluated by default, how do you tell it *not* to? To prevent evaluation, you'd have to use quote or other tricks all over the place. But wait, there's more!
>> rt-account-hostname: "GREGG"
== "GREGG"
>> rejoin [https:// :rt-account-hostname "v3/accounts" :rt-account-id "pricing?instruments="  ["EUR_USD" "USD_JPY"]]
== https://GREGGv3/accountspricing?instruments=EUR_USD%20USD_JPY

Note that I didn't use to url!, but rejoin (short for reduce and join). And yet I got a url! value as a result. That's because I used :// at the end of the first value, which is how Red identifies URLs, and it appends the rest of the values to that. I'll leave a couple other wrinkles for your brain to ponder about the result. Use help and source in the REPL. They are your friends.
moliad
18:13:thumbsup:
nedzadarek
19:48@jlhouchin_gitlab
> Why can't it take a variable which is a string and insert the string along with the other strings, literals and blocks?
> Seems like it would be something useful for to url! to do.

I haven't used it too much so I guess it's more useful to use words instead evaluating them. And you can do this yourself, building your own block:
bl: copy []
append bl 'https
append bl 'me.com
append bl 'foo
to-url bl ; == https://me.com/foo

or use compose (a: "https" c: "foo" to-url compose [(a) me.com (c)]) or reduce(a: "https" c: "foo" to-url [a 'me.com c])`
jlhouchin_gitlab
21:23@greggirwin
Thanks for all the education. I don't where I got onto to-url which is what I have in the above code. It is also in the code where you advise me to remove the req-info from the loop.

Probably from being advised that I need to use a url and not a string so I found the function which created URLs.

The challenge here is the documentation. Where in the documentation can I learn what you are explaining? Where in rejoin or in url in the documentation can I learn. I understand that Red's documentation may not be there yet. And that is okay. It won't stop me or slow me down because I see the big picture and the long term benefits to using Red. Even if it slightly delays my current project. It is a worthy change of direction. But some people may not be so agreeable or have the liberty to be so.

I have VSCode on half my screen, a REPL on the other half, and a few dozen windows of documentation on the other half. :)

There is nothing in help rejoin to inform me of the fact that it would create a url.

>> help rejoin
USAGE:
     REJOIN block

DESCRIPTION: 
     Reduces and joins a block of values. 
     REJOIN is a function! value.

ARGUMENTS:
     block        [block!] "Values to reduce and join."


I may require more help than someone else. But to me for me. That doesn't help me at all to understand that:

http:// + "google.com" + "/find_me?" + ["red" "rejoin" "url"]] ==
http://google.com/find_me?red%20rejoin%20url

That said. If it is in the documentation. Please educate on where and how to find it. Teach me to fish.

If there is not such documentation, what can we do to begin to make it so? And can we make it where those of us who just got an education can help populate that documentation.

Where could I learned that rejoin upon receiving an head value of http:// would know this is a url and create a url and also handle blocks with a list of strings to convert to a single string delimited with %20?

Even if I need to learn to read the source code for this education. Where in the code base is this. And then I would still like to see this in the docs somewhere so that normal users would not have to know what arguments does a function take. How will it evaluate the block or values in the arguments.

I briefly looked at url.reds and I did not find what would lead me to understand. I haven't found where rejoin is defined yet.

I love that you are happy to help and are friendly in doing so. But I now your time is valuable. You have other things to do. I want you answering questions that need answered instead of things that I feel should be in documentation somewhere. I am willing to help. Even if it is no more than take what I have been taught here and document it somewhere discoverable, so that you don't have to answer the same questions over and over again. I am sure that occurs often enough with the nature of Red.

Thanks for listening to my bellyaching.
greggirwin
22:11We sometimes say "Use the source Luke".
>> source rejoin
rejoin: func ["Reduces and joins a block of values." 
    block [block!] "Values to reduce and join"
][
    if empty? block: reduce block [return block] 
    append either series? first block [copy first block] [
        form first block
    ] next block
]

?? is a shortcut for source as well.

If a function is written in Red, you can see the source directly in the REPL.
22:15It won't tell you that it returns a URL though, because it won't. It will return the same type as the first value, if that value is a series (series? first block). If it's *not* a series, it will form that value, turning it into a string, and your overall result will also be a string.
>> rejoin [%file "_" 'a 'b 'c]
== %file_abc
>> rejoin [<tag> "_" 'a 'b 'c]
== <tag_abc>
>> rejoin [[block] "_" 'a 'b 'c]
== [block "_" a b c]
>> rejoin [#issue "_" 'a 'b 'c]
== "issue_abc"
>> rejoin [123 "_" 'a 'b 'c]
== "123_abc"

22:17https://github.com/red/red/wiki/%5BLINKS%5D-Unofficial-Tutorials-and-Resources lists some other resources, and if you make notes of what trips you up, their authors, or even team Red, will be glad to find a home for your hard-earned advice.
22:20As much as documentation may help, and it does of course, playing with Red is often the best teacher. "To do is to learn" as someone once said. It's fun, and often leads to insights and understanding you'll never get from docs. It may even lead to that most exciting phrase a scientist can utter: That's funny.
22:22I have a feeling the help you get from people here will be paid with interest when someone new comes along and you feel confident enough to pass on what you know.
moliad
22:25I find the best way to learn is often to open up the REPL and just wing it, trying to grasp the variations I'm trying to do and see how various types and functions react together. Even after 20 years, I still discover new cool ways to assemble some functions I use .
22:26you'll see that the intrinsic design of Rebol, ( the language inspiring Red ) has a unique orthogonality which makes things more and more obvious since the same precepts you learn early are re-used in many new contexts of use.
22:27for example, refinements have the same names when they are logically related. we even start to follow the design in our own code, since it just "seems obvious" it should be done in a certain way at some point.
22:28this whole concept of conceptual reuse is still the thing I hate about most other languages. OOP tends to make systems which are much less OO than Red in design.
greggirwin
22:29You can also use what or help with a partial text or datatype to match, and get a list of words in the system. From there you can explore to your heart's content.
moliad
22:29python for example uses a different method name for insert/append on all datatypes which can add something to themselves... at some point you keep forgetting which type uses which synonym... it gets annoying when you've done a bit of Red
jlhouchin_gitlab
22:31@moliad
I have used Python for 25 years. I have been annoyed from the beginning. Which is why I always struggle to use it even though you can make a nice theoretical argument for it. Which is why I have always struggled to leave Smalltalk (Pharo).
greggirwin
22:35@moliad Bertrand Meyer has a book where he talks all about Linnaean Naming (i.e. consistent and categorical), so you don't have insert/remove, push/pop, enqueue/deque, ... just always insert/remove for any kind of list.
22:37It's called Reusable Software. Heavy OO of course, because he's the Eiffel guy, but still a great book.
22:40@jlhouchin_gitlab if I hear you thinking correctly right now, it might be "Why not put that info in the doc string for the functions?" Because we can't. Well, we *could*, but those strings necessarily need to be kept short, so they are really more reminders, not full documentation. What we may do is add another function that leads to full docs for a func. @rebolek already wrote a cool func that takes you to the source for natives in the repo, and eventually, we can add docs, like help and source work.
jlhouchin_gitlab
23:42For example. Gregg stated
> It won't tell you that it returns a URL though, because it won't. It will return the same type as the first value, if that value is a series (series? first block). If it's *not* a series, it will form that value, turning it into a string, and your overall result will also be a string.

... that rejoin returns the value of its first type. Where is the above information in the documentation? Or do I have to by trial and error discover such, if I every put it together? And does every new user of Red have to learn that way. If so, it will keep the numbers down.

And when I say documentation. I do not mean doc strings. Not every language has such a construct. However, I have scoured as much online documentation as I can and am not discovering what I seek.

https://doc.red-lang.org/en/

Is such a source. To me, that is the canonical source for the core of Red. Which is part of the hard part in learning Red. If I want to learn Python. I can go to python.org and find ample material to get me started. Great documentation.

The information for source rejoin or ?? rejoin is invaluable. Thank you. But Alas it still doesn't provide the information you provided above.

And yes, I understand, once I know Red better, I may understand the source better and it is obvious that the first value determines everything, because we are know sending everything to whatever in the first value is to construct the new object. But it might not be so obvious to someone who is just coming to Red. Someone who is attempting to learn by doing. By doing what he has already done in 3 other diverse languages without so much struggle. And what I have written above may not be accurate. It is a stream of consciousness statement.

If I am remotely correct. If I understand that since the first part is a url and now url provides the context for the construction. Where in the documentation or in the source do I find the above information in the construction or appending or rejoining to a url that a block of strings is converted.

Documentation could tell me that. Yes trial and error could tell me that. However, if my thoughts are it joins a bunch of strings and creates a url object. I might end up creating my own function to take a block of strings and delimiting them appropriately for the url never know that rejoin will do that. Until I make my source code public and then somebody tells me. But not till after I have done untold amounts of undocumented stupid.

There is a very legitimate place for documentation. I understand and value reading the source code. Smalltalk is the king of that. Everything, and I mean everything in the image is available. Only that which is the vm is unavailable inside the image. Despite that, there is a need for documenting those things which the source code may not tell you.

How far down the rabbit trail do I go before I learn that the first item in the block determines everything when it comes to evaluation of the block in certain contexts? Is that documented anywhere?

I haven't seen that here:
http://www.rebol.com/docs/core23/rebolcore-7.html

Or do I (or someone else) simply get frustrated and get off the rabbit trail. I am hardier than many. But Red could lose many potentially worthy people because of this.

I am used to nicely document classes and methods. And I believe many who may want to explore Red are also so accustomed. You understand their inputs and outputs. Yes, I understand that in Red context determines things. And that is true most anywhere. That is what polymorphism is about. I can't simply read about the message at: in Smalltalk (Pharo) without knowing who the receiver is. (the context)
Which in the Pharo image there are about 70 implementers.

Don't get me wrong. I am not saying Pharo good, Red bad. But this is a current struggle in learning Red. And I do not believe I am or will be alone. I am here at the moment because I see value in Red and what Red aspires to become.
23:51

I am a big fan of good REPLs. Red's is not bad, but not great yet. I try it as much as possibly can or need to for discovery and learning. I would not be here if Red didn't have a REPL.

Smalltalk is all live, dynamic. You can run code from within code. Within anywhere in the image. If this were a Smalltalk image. I could select any code that has been typed anywhere and right-click and select doit and it would be executed. Smalltalk is as alive and dynamic as you get. You can modify your program while it is executing.

So trust me. I will use the REPL. However, as I have demonstrated it doens't have all the answers. It doesn't answer all questions fully. Because they aren't fully answered in the docs or the source. Which leaves trial and error. Trial and error is good. But trial and error requires the user to try the right things to git the right answers. Or else they will keep on until they give up or do eventually ask the right question or try the right thing. For an explorer or newbie to a language. That might be enough to walk away.

Got to go. Have a great weekend. Be back Sunday morning.
Thanks again for y'all's patience. Y'all is a legitimate word in Texas. :)>

greggirwin
00:09> ... that rejoin returns the value of its first type. Where is the above information in the documentation? Or do I have to by trial and error discover such, if I every put it together? And does every new user of Red have to learn that way. If so, it will keep the numbers down.

We'd love to have complete, up-to-date, documentation. Don't think we don't. But we only have so many hours in the day. Python has a 20+ year head start on us, so I think it's fair to ask what the Python docs looked like in 1998 or so. :^)

You're *very* new to Red. Give it a little time and see if things start clicking into place for you.
jlhouchin_gitlab
01:06@greggirwin
I agree 100% that is why I offered to help. I would like to be a part of part of a solution. But Red needs to have a place for that solution. It is a struggle to wade through all of the external third party docs. Documentation of core Red needs to be quality official Red docs.

What I was arguing for as much as anything was not the fact that the docs I desire are not to be found bad that it was seemingly not desired, because we can discover through experimentation in the repl.

I understand that I am very new to Red and I do expect to improve. But I think the road for future travelers could be better. There needs to be sufficient documentation to at least have a core foundation of understanding.

Good documentation is a culture that must be cultivated in a community or it won't exist. Anywhere it exists, the community made an effort to create the culture. It is work. Most developers value documentation, but do not like creating it. Which is why so many projects are great on code but poor on docs.

From someone on the outside. From what I have seen on the areas I have seen. The docs are not sufficient. I know others have worked there way to understanding by experimentation and lots of questions.

Unfortunately Red doesn't even have a persistent source of community conversation where questions are easily searched and discovered. I have always extensively searching mailing lists or newsgroups before asking a question to see if it had already been asked. That isn't as easy with Red.

I have to go for now. Will check in in 25+ hours. Thanks.
greggirwin
01:18We know Gitter isn't a great persistent resource, but mailing lists are a dying breed. Rebol still has one, but it's not used much. AltMe was our old warhorse, and predated many modern chat systems and had even better features. But it's a darknet desktop app, and we haven't rewritten it in Red yet. :^)

We have a number of doc targets planned, but we also tend to do things differently. For official docs, there will be a high bar set on quality, so it's not something we expect will come from the wider community, without a strong editor guiding a small team of leaders. This is not to say other langs have poor docs. We've examined a lot of them and hope to learn from all of them.
gltewalt
01:49@jlhouchin_gitlab
You consult Rebol documentation as another resource as Red is about 95% compatible.

http://www.rebol.com/docs/dictionary.html
01:55Maybe 90% compatible
06:10How to iterate the files of a directory again? foreach f what-dir [] doesn't work
ne1uno
06:34what-dir: read somedir
greggirwin
06:42what-dir is already a func @ne1uno.
06:42But, yes, the magic is that you have to read the dir.
06:42foreach f read what-dir [print f]
gltewalt
06:46:+1:
toomasv
07:28
each: make op! func [fn block][forall block [fn block/1]]
:print each read %.
dander
07:35@toomasv I really like that each!
toomasv
07:44:smile:
Claudio08
08:32Thanks for all these explanations and tips. All is very usefull, each time i learn something new. About list directory, is possible to list only directory or files or sort them?
toomasv
08:38@Claudio08
foreach f read %. [if dir? f [print f]]
foreach f read %. [if not dir? f [print f]]
sort collect [foreach f read %. [if dir? f [keep f]]]
;:print each sort collect [foreach f read %. [if dir? f [keep f]]]
Claudio08
08:43I must note all this knowhow in a book. Thanks
toomasv
08:44@Claudio08 You are welcome!
mikeparr
08:51@jlhouchin_gitlab - I agree with everything you say about documentation and experimentation. There are also ways to do certain tasks in a very neat short way, and it is difficult to find these 'patterns'.
toomasv
08:55Convoluted each:
>> each: make op! function [fn block][
    append fns: clear [] reduce :fn 
    foreach fn fns [
        words: parse spec-of :fn [collect [
            some [refinement! break | keep word! | skip]]
        ] 
        code: compose/deep [
            block: collect [
                foreach [(words)] block [
                    attempt [keep (compose either op? :fn [
                        [(words/1) fn (words/2)]
                    ] [
                        [fn (words)]
                    ])]
                ]
            ]
        ] 
        do code
    ]
]
== make op! [[fn block /local fns words code]]
>> :print each [1 2 3 4]
1
2
3
4
== []
>> :probe each [1 2 3 4]
1
2
3
4
== [1 2 3 4]
>> [:add :probe] each [1 2 3 4]
3
7
== [3 7]
>> [:add :multiply] each [1 2 3 4]
== [21]
>> [:+ :*] each [1 2 3 4]
== [21]
nedzadarek
13:15@jlhouchin_gitlab
that's why I value examples. Even you don't fully understand certain topic you get "a gist" of it.
Claudio08
13:35I have seen in some code that is used:
foo: function [ ...
or
set 'foo function [ ...
What is the difference? Thanks
nedzadarek
13:43@Claudio08 it depends on the code. Both points some value (a function in this case) to some word (foo in this case).
In general, set is more versatile (you can do more). For example you can have your name stored in the block and pick one:
bl: [foo baz bar]
set bl/1 function [][print 'foo-foo]
foo ; foo-foo

ps. as you can manipulate values inside a block you can do similar stuffs:
>> do compose [(to-set-word bl/1) function [] [print "inside new foo1"]]
== func [][print "inside new foo1"]
>> foo
inside new foo1
Claudio08
13:50@nedzadarek thanks, so "set" is not used only for functions?
toomasv
14:21@Claudio08 No, set is a general function that sets values to words (single word or path or words in block or in object). See ? set and experiment with it. Try e.g:
set bl: [a b c] 1
set bl [1 2]
set bl [3 4 5]
set/any bl/1 ()
set/some bl reduce [1 none 2]
set ob: object [a: none b: none c: none] reduce bl
set ob context [a: 10 c: none]

Use reduce to see what happens in the blocks and objects.
It is often used in function or in context/object to make a word global -- if it is not already declared local.
Claudio08
14:47@toomasv thanks. Sorry but now another new thing:
set/any bl/1 ()
the use here of "()" what does it mean?
toomasv
15:02@Claudio08
>> probe ()
unset

It returns unset and is there to demonstrate that set/any let's you set words without rising error even if there is no value set. Without /any error is generated.
15:27Fun stuff:
set [dir file] collect [
    keep copy/deep [[][]] 
    foreach f read %. [append collected/(pick [1 2] dir? f) f]
]
:print each file
:print each dir
greggirwin
16:25
filter: function [
	"Returns two blocks: items that pass the test, and those that don't"
	series [series!]
	test [any-function!] "Test (predicate) to perform on each value; must take one arg"
	/only "Return a single block of values that pass the test"
][
	;TBD: Is it worth optimizing to avoid collecting values we won't need to return?
	result: copy/deep [[][]]
	foreach value series [
		append/only pick result make logic! test :value :value
	]
	either only [result/1][result]
]
set [dirs files] filter read %. :dir?
dirs: filter/only read %. :dir?
16:27dir is a standard func, so changes to dirs.
16:32Filter traditionally only returns items that pass the test. This was an experiment I did some time back, because filter, like pad is ambiguous in my mind. Does it filter *in* or filter *out*? Does it pad *to* the left, or *on* the left?
16:36Another consideration is the subtle casting to logic of the test result. This version uses make so zero values from a test become false.
toomasv
16:48@greggirwin Nice! It is of cause more general than my little snippet (although logic is similar). I was mainly fascinated by usage of collected which is not obvious without knowing the source.
17:03May be separate for two groups and filter/filter/out for one?
separate: function [series test][
    collect [keep [[][]] foreach val series [append/only collected/(pick [1 2] test :val) :val]]
]
>> set [dirs files] separate read %. :dir?
greggirwin
17:13Separate, good word.
17:13Partition is another one I noted.
17:15I used that for an old func that took multiple predicates, and have a similar one called group-by.
toomasv
17:16@greggirwin E.g.
filter: function [series test /out][
    collect [foreach val series [if out xor test :val [keep/only :val]]]
]
files: filter/out read %. :dir?
greggirwin
17:16And, yes, yours is very clever.
nedzadarek
18:33@toomasv /out -> nice addition to filter HOF.
As fair I remember partition is more used than separate. To be honest, I haven't seen separate in any language I have tried.
> I was mainly fascinated by usage of collected which is not obvious without knowing the source.

If you are interested in the collect you can try my edit: [cold](https://github.com/nedzadarek/cold.red).
18:34@Claudio08 well, @toomasv have already answered the question ( :+1: ).
luce80
18:49@toomasv Could you please rewrite your filter function using parse...collect...keep ?
toomasv
18:53@luce80
filter: function [series test /out /local val][
    parse series [collect some [set val skip if (out xor test :val) keep (:val) | skip]]
]
19:30@nedzadarek Interesting! Thanks.
gltewalt
20:16The other issue is the .png's are corrupted this way if I do replace-all .bmp .png what-dir, but first things first
20:40Because right now, it's not really a convert - more like rename

greggirwin
01:09You're never reading the file, to write its data back out under a new name. Break it down into steps, so you can check your new name, and know what data you're writing, rather than trying to do too much in a single line.
01:09To convert images, you'll want to use load and save with /as.
gltewalt
01:13Tried save/as but gives me error.
I’ll get back to it tonight
luce80
07:43@toomasv thanks, it should be faster since the loop is inside parse. I added it to my collection but will change xor with <>. It obviously can filter also already filtered data ...
gltewalt
07:48Works with valid save/as formats, but end up with filename.old-extension.new-extension
foo 'bmp 'png what-dir

foo: func [directory from-suffix to-suffix][
    foreach file read directory [
        if find file rejoin ['. from-suffix][
            save rejoin [file '. to-suffix] load/as file to-suffix
        ]
    ]
]
nedzadarek
10:34@gltewalt I think it should be foo what-dir 'bmp 'png
gltewalt
10:46Yeah
nedzadarek
11:38Can we load html (or in general markup text)? For example I have html-code: { code : here } and I want [ { code : here } ] (every tag! as a tag! and everything else as a string!).
11:44Or shall I write it myself (parse or load/next)?
toomasv
13:10@gltewalt How about this:
convert-all: func [directory 'from-suffix 'to-suffix][
    foreach file read directory [
        if find file rejoin [dot from-suffix][
            save/as rejoin [
				directory replace copy file next suffix? file form to-suffix
			] load rejoin [directory file] to-suffix
        ]
    ]
]
; convert-all %. png gif
luce80
14:03@nedzadarek You can start from the very nice html parse example at: https://www.red-lang.org/2013/11/041-introducing-parse.html
nedzadarek
14:50@gltewalt @toomasv
If you are looking "change all files within given directory with a given extension (e.g. bmp) to other extension" then I think you can just check last length? from-suffix character if they are the same as from-suffix. Something like this (I don't care about directories here):
f: %foo.bmp
; %foo.bmp
  from-suffix: "bmp"
; "bmp"
  to-suffix: "png"
; "png"
  f: at (tail file) (negate (1 + length? "bmp") )
; %.bmp
  if f [ 
    f: next f
    change/part f to-suffix (length? f)
    ]
; %""
  f
; %png
  head f
; %foo.png
14:52@luce80 so, I have to do it on my own. Well, thank you as this example from that page makes a hierarchy. I'm not sure about parsing to >. I have to think about it.
gltewalt
19:20@toomasv Did you test it? I tried the save/as rejoin way.
jlhouchin_gitlab
19:23I want to thank everyone who engaged me with advice and conversation. You have enlightened and educated me. But for the moment I will have to pull back. My initial version 1.0 of the project needs to be completed in a timely manner. I have it mostly implemented in other languages. I wanted to explore what Red could offer and if it could be an enjoyable solution that would not significantly delay deployment. I believe at this time that my best way forward is with what I already have going.

I will re-examine Red and its opportunities at a later time when my project is complete and deployed. Red may be appropriate for v2.x. I also have other projects when this is complete for which Red may be an interesting opportunity. When I have more time to spend learning.

Again, thank you for your graciousness and patience with my questions. I wish you all well and may you enjoy your journey.
toomasv
19:45@gltewalt I did, superficially. I see that delete file is missing from after rejoin [directory file] to-suffix, so currently the above code leaves original files there.
20:23Experiment with some more frequently used shell commands on Win (tried on W10 only):
context [
	reform: func [block][form reduce block]
	_spec: [:file1 :file2 /q]
	_ask: [file1 " to " file2 "? (y/n) "]
	opts: object [
		mv: object [spec: _spec question: compose ["Move " (_ask)] cmd: ["move" file1 file2]]
		cp: object [spec: _spec question: compose ["Copy " (_ask)] cmd: ["copy" file1 file2]]
		rn: object [spec: _spec question: compose ["Rename " (_ask)] cmd: ["ren" file1 file2]]
		rm: object [spec: [:file2 /q] question: ["Remove " file2 "? (y/n) "] cmd: ["del" file2]]
	]
	
	body: [
		if any [q "y" = ask rejoin (question)][
			call/error reform (cmd) err: copy "" 
			if not empty? err [print err return none] 
			to-file file2
		]
	]
	
	foreach fn [mv cp rn rm][
		set fn func opts/:fn/spec probe compose/deep/only bind body opts/:fn
	]
]

E.g.:
>> mv two.png two1.png
Move two.png to two1.png? (y/n) y
== %two1.png
>> cp/q two.png three.png
== %three.png

gltewalt
20:48So the delete here should work

convert-all: func [directory 'from-suffix 'to-suffix][
    foreach file read directory [
        if find file rejoin [dot from-suffix][
            save/as rejoin [
                directory replace copy file next suffix? file form to-suffix
            ] load rejoin [directory file] to-suffix
            delete file
        ]
    ]
]
21:08delete-all: func ['suffix][call/shell rejoin ['del space '* dot suffix]]
greggirwin
22:01@nedzadarek we plan to include an XML loader, but haven't decided on HTML yet. @rgchris is a great resource on that. And we're happy for people to submit things, but in this case I can tell you that the XML loader will face intense scrutiny before being accepted.
22:01If we agree on the interface, people can write to that spec, and then we can always replace them later, if needed.

toomasv
03:14@gltewalt Yes. But probably some kind of checking if file was susccessfully converted before deleting the original would be nice.
GalenIvanov
12:13@toomasv Your each is a good adjective for a vector DSL. Arthur Whitney's K programming language(s) has '- each, \:- eachleft, /: - eachright, ': -eachprior. In fact most of the primitives are fully right atomic, which means that they penetrate to the deepest levels of the right argument, for example [5 * (1 2 3; (4 5; (6; 7 8)))](https://tio.run/##y9bNS8/7/99UQUtBw1DBSMHYWkHDRMHUWsPMWsFcwUJTU/P/fwA)
toomasv
13:09@GalenIvanov Too hard for me! :flushed:
nedzadarek
13:34@GalenIvanov what do left, rightand prior means?
13:56@toomasv
:point_up: [May 18, 2019 10:55 AM](https://gitter.im/red/help?at=5cdfc8990ac9852a95fa52f0)
As fair I can see it's called fold: https://en.wikipedia.org/wiki/Fold_(higher-order_function) in the functional paradigms.
^^ Just find a link with the text "higher order function" because gitter markdown is bad.
@GalenIvanov
> which means that they penetrate to the deepest levels of the right argument

It's doable in the Red however catching "nested errors" might be "not so elegant": https://gist.github.com/nedzadarek/11183796d3733076c56e4d8d04ca861e
toomasv
14:04@nedzadarek Hmm, I would rather say it's multiFoldL.
mikeparr
14:23Version 'bug'. I don't want people to spend any time on this, but something might just spring to mind, and save me some time. I have a biggish intricate program that interprets fine with 0.61, but not with 0.64. I'm getting an error when I do a 'get', as in:
x: get to path! rejoin ["xfiles/" a "/" b]  ;-- rejoin result looks sensible

*** Script Error: path must start with a word: xfiles/index/blk
*** Where: get

Basically, I wondered if 'get' has changed as Red evolved?
toomasv
14:34@mikeparr Try load instead of to path!. Currently "xfiles/a/b" is turned into first element of the path; load makes it normal path.
nedzadarek
14:38@toomasv
> @nedzadarek Hmm, I would rather say it's multiFoldL.

I mean fold in general, but why multi?
toomasv
14:41Because it takes several funcs in row to foldL. But I don't know much about HOF, so I may easily err.
nedzadarek
14:42@toomasv I see
mikeparr
14:59@toomasv Load - to path! - Oh yes, you are 'the man', Toomas! Works fine now. The 'to path!' version worked in 0.61. Thank-you so much!
toomasv
15:02@mikeparr You are welcome!
greggirwin
17:18@mikeparr this is one of those cases where the textual representation's limits can trip us up. I don't remember the change, as it was some time ago, but I try to remember other ways to confirm my assumptions.
>> to block! to path! rejoin ["xfiles/" a "/" b] 
== [xfiles/xxx/yyyy]
>> to block! load rejoin ["xfiles/" a "/" b] 
== [xfiles xxx yyyy]
>> length? to path! rejoin ["xfiles/" a "/" b] 
== 1
>> length? load rejoin ["xfiles/" a "/" b] 
== 3
>> first to path! rejoin ["xfiles/" a "/" b] 
== xfiles/xxx/yyyy
>> first load rejoin ["xfiles/" a "/" b] 
== xfiles
toomasv
17:38The last ones were what I tried :)

GalenIvanov
06:22@nedzadarek Thanks for you code!
06:23The primitive verbs in K are either monadic (have only one argument - right, or x) or dyadic (have two arguments - left and right, or x and y).
06:24m is monadic, d is dyadic
06:24m'l is each. Apply the monad to each x, producing a new list
06:24x d'y is each dyad. Pair up values from x and y and apply them to the dyad, producing a new list
06:25d':l is eachprior. Apply the dyad to each element of the list (left argument) and the element preceding that element in the list (right argument), producing a new list.
06:25x d/:l is eachright. Apply the dyad to the entire left argument and each right argument, producing a new list.
06:25l d\:x is eachleft. Apply the dyad to each left argument and the entire right argument, producing a new list.
06:26You mentioned fold - in K it is / - d/l is over, also known as foldl. Apply the dyad to pairs of values in x from left to right and carrying each result forward, reducing the list to a single value.
06:28(I copied the explanations from the oK manual - oK is an opensource JavaScript implementation of K)
06:28https://github.com/JohnEarnest/ok/blob/gh-pages/docs/Manual.md
06:35@toomasv I'm more than sure you can code them. The question is whether you need or will ever use the vector paradigm in your work. It's very useful for some tasks, especially when the data has regular array shape. (In fact K uses lists in contrast with APL an J which use arrays.)
toomasv
08:17@GalenIvanov Interesting, thanks!
JLCyclo
11:59A question: In rebol, there is the instruction echo to enable/disable redirection output from print/prin to a file. Is there an analoguous way to do it in Red ?
rebolek
12:00@JLCyclo not yet, but it may come with full IO.
nedzadarek
22:54@GalenIvanov thank you for explanations + link. I have played with the idea of a different each. Here is what I get ( https://gist.github.com/nedzadarek/a72f06a3a0249db1dafffecf72735976 ):
Opinions:
1) Monadic each: It's very useful. I have seen it in the almost all "not basic" language.
2) Diadic each: From time to time I need to do things with 2 series. It would be useful to have it in a language but is it necessary? Do somebody use it? Does somebody have examples?
3) Eachprior: I have no idea where I can use it. Does somebody has examples?
4) & 5) They are very similar. The power of it comes from a function used. We can use one function (in my case merge) in different cases (append vs insert). Without function like merge it can be simulated by 2nd function (eachleft instead of eachright, or eachright instead of eachleft):
append*: func [v s] [append copy s v]
each5 arr2 arr1 :append*
; == [[1 2 10] [1 2 20] [1 2 30]]
each4 arr1 arr2 :merge
; == [[1 2 10] [1 2 20] [1 2 30]]

Still... I don't remember using such feature. As with 3) examples needed.

GalenIvanov
08:45@nedzadarek Thank you for your implementation and comments. I'll try to make/find some examples. About eachprior - one use is for finding deltas. Some examples:
[Sequential Processing](https://github.com/JohnEarnest/ok/blob/gh-pages/docs/Programming.md#sequential-processing)
08:46eachleft and eachright can be used when a Cartesian product of the elements of two lists is needed:
08:47[Cartesian Product](https://github.com/JohnEarnest/ok/blob/gh-pages/docs/Programming.md#cartesian-product)
09:01@nedzadarek The problem solving using array languages need some paradigm shift (as for any programming language which is worth learning, like Red). Here is a function checking if a year is leap (1) or not (0).
09:01[leap:{2!+/~4 100 400!\:x}](https://tio.run/##y9bNz/7/Pyc1scCq2khRW7/ORMHQwEDBxMBAMcaqohYso25oaWmpYGQAFDcyMAISQBX/AQ)
09:02{} is function (can be lambda)
09:03x is function's default argument
09:03!\: finds the modulo of x with each 4, 100 and 400
09:04~ negates the result - 0 becomes 1, every non-zero becomes 0
09:05+/ is reduce by addition (or fold)
09:052! - modulo 2
09:08So we get 0 for each 4, 100 or 400 if the year is divisible by it or the remainder otherwise. ~ negates the result, we'll have only ones and zeros, which we add up with +/
09:15if the year is odd, we 'll have nonzero remainders for the three 4, 100 and 400, negating them will result in 0 0 0, adding them up to 0, 2 mod 0 is 0 -> not a leap year.
09:16if we test 2100 - 4 100 400!\:2100 -> 0 0 100
09:16~0 0 100 -> 1 1 0
09:17+/1 1 0 -> 2; 2!2 -> 0 -> not a leap year
nedzadarek
09:40@GalenIvanov
> Cartesian product of the elements of two lists is needed

Well, I would just use 2 loops/each but I can see it can be used if a programmer understand it.

Such paradigm shift may be too big for some programming languages. I used the J. In my opinion it's wonderful at first sight but after the line gets bigger it loses clarity.
09:56@greggirwin I see, well, I have written something using load/next but it's for limited use. So I wouldn't submit it but if someone takes an idea from it then it's ok.

Would it be hard to do HTML's version after you will implement XML loader? I mean XML and HTML share many things. As for [a site](https://techdifferences.com/difference-between-xml-and-html.html#KeyDifferences), I think only this would cause problems:
-When it comes to language type HTML is case insensitive. As against, XML is case sensitive.
- XML does not permit any mistake if there are some errors in the code it could not be parsed. Inversely, in HTML small errors can be neglected.
- Whitespaces in XML are used for a specific use as XML considers every single character. On the contrary, HTML can ignore the whitespaces.
- The tags in XML are mandatory to be closed, whereas in HTML an open tag can also work completely fine.
GalenIvanov
10:53@nedzadarek Well, if you used J, you know what I was talking about. Sorry for spamming the page with stuff not related ro Red.
greggirwin
18:55@nedzadarek HTML should be pretty easy after XML, but it may also be stricter than some systems, because poorly formed HTML is a bad thing.
18:56The "can also work completely fine" part is the issue. Tags *should* always be closed, and we may enforce that.
nedzadarek
20:31@greggirwin
> The "can also work completely fine" part is the issue. Tags *should* always be closed, and we may enforce that.

As for [void/singleton tags](https://www.lifewire.com/html-singleton-tags-3468620) - wouldn't this make this html-loader almost useless?

greggirwin
00:59It depends on your view. XHTML requires that void elements be closing tags, correct? That leaves plain HTML, and the very common cases of
and
. Note that I didn't say *dogmatically strict*, so the loader can allow what we feel is the most useful combination of things. But once we relax things, the data is no longer strictly structured. Then the question is: What do you want to do with it? So when you say "almost useless", I'll ask "almost useless in what context?"
01:02There are a million tough calls we have to make, and compatibility is a big one. Our world is full of bad ideas and poor designs that make our lives miserable, but they linger on for the sake of compatibility. It's not easy. I want my 20+ year old apps to run on my current OS without change, because that would be nice. But I also know a time comes when we have to let go. So, if you think void elements are important in the HTML loader, defend that position concretely.
01:04For those listening, know that I *like* @nedzadarek and am not attacking their stance or views. I sometimes post messages like the above to help us all work together more effectively.
01:07We have a wiki page [here](https://github.com/red/red/wiki/%5BDOC%5D-Red-Should...-(Feature-Wars)) that speaks to this type of thing.
beenotung
03:01I wonder if I can compile from the red console (instead of switching between red console and shell)

03:39From the demo, sometimes u
03:40From the demo, sometimes I see "Needs: 'View", sometime without the single quote, is it the same ?
ne1uno
03:43I think either works right now
beenotung
05:20Is there unlike tutorial / blog about using red for web server or backend ? I found a handful on resources on how to make it for GUI, but I want to learn the languages and built in functions first.
05:21A purpose in mind is to build web server or code generator for other static type language (e.g. typescript, which doesn't support macro)
05:22It's typo "it that any tutorial …". I'm not used to the gitter app, it send out too easily and cannot correct the message
05:23"Is there any" … typo again
05:25I don't have typo problem so often on telegram, is gitter actively applying auto correct, that override my keyboard ?
rebolek
05:53@beenotung if you want to compile from console, you can do something like call "rebol my-compile-script.r" and add some boilerplate code around it to prepare compilation script which would be just a one-liner with do/args %red.r "compilation options here".
greggirwin
06:04@beenotung Gitter takes some getting used to. :^)
06:05Full I/O will come in 0.7.0. Until then, you can't write a web server in Red.
semiherdogan
06:40Hi, i have updated red version on my mac and on first run it gave me an error says " *console-2019-5-2... is not optimized for your mac and needs to be updated.* "
After this warning it works without any problem.
Is this warning related to the latest build?
rebolek
06:42I believe it's macOS warning for 32bit apps.
06:42https://www.computerworld.com/article/3268645/what-is-the-not-optimized-for-your-mac-warning-message.html
semiherdogan
06:52@rebolek thank you. now i have disabled 32bit warnings by typing defaults write -g CSUIDisable32BitWarning -boolean FALSE i will check again on next build if any warning occurred.
nd9600
17:59This seems like a really stupid question, but I'm changing the compiler and interpreter for https://github.com/red/red/issues/3482 (I've got it compiling op!s in objects now, but not blocks yet), and obviously the compiler is https://github.com/red/red/blob/master/compiler.r , but where's the interpreter? I can't find it
18:00runtime/interpreter.reds, nevermind, find found it for me
greggirwin
endo64
22:27> I wonder if I can compile from the red console (instead of switching between red console and shell)

@beenotung You can use a function like compile: func [arg] [call/console rejoin [{red -c } arg]]
Then you will be able to compile inside the REPL: compile "test.red
greggirwin
22:33Good point @endo64. Somewhere I started a dialect for that.
endo64
22:47And when ever you need to go to shell without loosing your Red/CLI session (words etc.) you can do call/console "cmd" (on Windows), when you exit from shell you will be in the REPL again.

meijeru
11:29Was this recently implemented? On my W10 GUI console I get Internal Error: reserved for future use (or not yet implemented).
nedzadarek
13:35@greggirwin
> XHTML requires that void elements be closing tags, correct?

Yes

> "almost useless in what context?"

Well, "almost useless" was too much but according to my math only ~1/2 of the top websites (more later) closes img tags.
From 41 websites from the [top 50 websites](https://en.wikipedia.org/wiki/List_of_most_popular_websites)(excluding repeated (e.g. google), cannot find tag and with adult content):
- open 19
- closed 22
Websites closes img by adding / at the end of the opening thag. 2 sites have mixed (open & closed) tags and one site closes it using .
ps. I have done it manually so there might be mistakes. I have OpenOffice Calc file if somebody need it.

> What do you want to do with it?

Work with already existing websites. If I'm creating my own websites I can make it into xhml so this is not a problem.

> For those listening, know that I *like* @nedzadarek and am not attacking their stance or views. I sometimes post messages like the above to help us all work together more effectively.

I haven't seen any aggression so far. @greggirwin talks to you with politeness and patience.
greggirwin
16:17@meijeru it only works for the CLI console.
16:18@nedzadarek good notes and numbers. Don't lose them, and maybe even put them in a new wiki page for Codecs.
giesse
18:24Parsing HTML is not trivial but it's not that hard. I don't think it will be a big deal for most people, I don't see why basic stuff like image tags as @nedzadarek should be a problem. In fact, most people will probably only need something like R2's load/markup or similar lightweight approach.
greggirwin
18:26Agreed. As with all codecs, we should handle the most common and useful cases well. If those are done at the mezz level, and people need to handle special cases, they have a springboard to work from.
giesse
18:26See https://giesse.github.io/rebol-power-mezz/parsers/ml-parser.html for a "better" load/markup, and https://giesse.github.io/rebol-power-mezz/mezz/load-html.html for a complete HTML parser (HTML 5 was not a thing at the time, but it would be easy enough to add)
greggirwin
18:28One of the big decisions with all SGML deriviatives, and other formats that have metadata for values (attributes), is what the loaded data looks like in Red.
18:30And while Nenad wants a fast XML parser, so we compare well on larger documents to other langs, I'm good with a first step being at the mezz level, because that at least lets people try Red. We'll find out in testing how it performs.
loziniak
20:07Hi! Is there an easy way to do numbers formatting? For example fixed decimal places - displaying 1.1 as 1.100?
dander
20:11@loziniak maybe something like this, but it seems like it could be better
>> pad/with 1.1 5 #"0"
== "1.100"
20:12that isn't going to trim overly long numbers though
9214
20:13@loziniak, @greggirwin has format dialect in progress.
loziniak
20:16It would help a lot.
20:16So for now, I'll write my own formatting logic. Thanks!
greggirwin
20:58@loziniak check out https://github.com/greggirwin/red-formatting and steal parts you can use.
loziniak
23:03Nice piece of work, thanks @greggirwin.

nedzadarek
09:56Is there a way to get "an user language" in the red? system/locale is:
language   none!         none
     language*  none!         none
     locale     none!         none
     locale*    none!         none
     ; ...

endo64
11:10@nedzadarek Currently no, could use call or API, on Windows:
result: make string! 1024 call/output "systeminfo.exe" result
trim copy/part pos: find/tail result "System Locale:" find pos "^/"
; == "tr;Turkish"
Claudio08
14:14@nedzadarek Hi, i used the following only for test on Win10; the call take some seconds

>> call/output {powershell -command Get-WinSystemLocale} s: ""
== 0
>> l: to-block s
== [
    LCID Name DisplayName 
    ---- ---- ----------- 
    1040 it-IT I...
>> l/8
== it-IT
>> l/9
== Italiano
>>
14:30@nedzadarek with "Format-List"

>> call/output {powershell -command Get-WinSystemLocale | Format-List Name,LCID} s: ""
== 0
>> print s


Name : it-IT
LCID : 1040




>>

nedzadarek
21:42@endo64 so it's planned (maybe system/locale)?
Well, it gives me:
*** Access Error: invalid UTF-8 encoding: #{887567A5}
*** Where: call

@Claudio08 well, it works but it's slow (~4,5 second)
>> find/tail s "Name : "
== "pl-PL^/LCID : 1045^/"
>> s2: find/tail s "Name : "
== "pl-PL^/LCID : 1045^/"
>> split s2 newline
== ["pl-PL" "LCID : 1045" ""]
>> first split s2 newline
== "pl-PL"

@endo64 @Claudio08 For my need I would rather not use system calls.
Thank you both.
21:53ps. win 8.1 x64
greggirwin
22:38@nedzadarek it hasn't been decided if Red will automatically load the OS locale info into system/locale, or if we'll let the user do it on demand. If anyone wants to do the R&D on the various OS APIs, that would be great. A wiki page is fine to start.
nedzadarek
22:44@greggirwin I see

nd9600
14:33
a: reduce [function [x y][x + y]]
probe a/1 4 5

should print 9 when you compile and run it, shouldn't it?
The interpreter prints 9, but when I run the compiled file I get func [x y][x + y]

This might make it hard to fix the compiler for block!s in https://github.com/red/red/issues/3482 since I don't have a working version to test against
dockimbel
14:38@nd9600 The compiler cannot infer in such cases that a/1 is a function call. We need a smarter stack handling for that, that I plan to work on next year.
nd9600
14:39Ah ok, thanks
hiiamboris
17:39@nd9600 here's some info for you :point_up: [March 14, 2019 7:45 PM](https://gitter.im/red/red?at=5c8a8518bf7990126ea1cafb)
And mind the line width ☺ Some of your are 280 chars long. There isn't a certain limit in [the guidelines](https://github.com/red/red/wiki/[DOC]-Contributor-Guidelines) but I'd keep it at 130 tops.

nd9600
07:15@hiiamboris thanks, that's very helpful
GiuseppeChillemi
17:34Is there a way to download and view offline gitter chats?
hiiamboris
17:39@rebolek should know a way ☻
dander
17:44@GiuseppeChillemi check out the download-room function in [gitter-tools](https://github.com/rebolek/gritter/blob/master/gitter-tools.red). You need to find your gitter API token first, and save in a local %options.red which contains token: "your-token" (I think)
rebolek
17:48@dander I’m too slow! :snail:
dander
18:03@rebolek only this time 😏
GiuseppeChillemi
20:09@dander @rebolek and how do I later view it in a stile like the current browser view?
rebolek
20:25@GiuseppeChillemi you would need to add some conversion to html
20:26I should add support to Gritter to view offline data
GiuseppeChillemi
22:16Thanks. I would like to create some script to navigate through chat messages and mark the start of a topic and sub topics

hiiamboris
10:47In R2 & R3 ?? was working like probe - it returned the value. In Red it returns unset - is it by design? And if so - why?
dockimbel
13:30@hiiamboris I was not aware that it was an argument pass-thru in Rebol, I always used it as a standalone expression. You can submit a PR to make it return the argument.
hiiamboris
13:51:+1:
Oldes
15:13I prefer return it unset personally, because I use it mainly from command line and without unset the returned value is duplicated. Like:
15:15[![image.png](https://files.gitter.im/red/help/J1s4/thumb/image.png)](https://files.gitter.im/red/help/J1s4/image.png)
15:17Versus:
15:17[![image.png](https://files.gitter.im/red/help/2zal/thumb/image.png)](https://files.gitter.im/red/help/2zal/image.png)
hiiamboris
15:21A good argument
15:22OK then I'll just add it to Rebol/Red diff page.
Oldes
15:22There are better examples.. like ?? system/options
endo64
16:17And ?? only exists on console, not when you compile or execute your script.
hiiamboris
16:29@endo64 ? only exists in console, ?? always: https://github.com/red/red/blob/073d19179c7b20d96a405e915bf8a2572e83b870/environment/functions.red#L77
greggirwin
16:50Agreed that it should stay as-is.
endo64
20:26Thanks @hiiamboris for correcting,
greggirwin
20:32But if it returns unset, the value of that is really in the console. Should it *be* only in the console, and probe should be used otherwise?
nedzadarek
20:45@greggirwin ?? takes lit-param ('value) but probe takes normal param (any-type).
greggirwin
20:53Ah, yes. Details. Hmmmm.
nedzadarek
22:53@hiiamboris how about simple refinement:
??*: func ["Prints a word and the value it refers to (molded)" 
    'value [word! path!]
    /return-value "Returns value"
][
    prin mold :value 
    prin ": " 
    print either value? :value [mold get/any :value] ["unset!"]
    either return-value [return get/any value][exit]
]
GiuseppeChillemi
22:55Is there a way to change the red gfx which appears on the windows bar of a compiled application and its text?
greggirwin
22:57I vote no. While ?? *might* be useful in code, and examples will help me see how people leverage the lit-arg aspect, my historical use of it is like @dockimbel's, and I think it's best if we consider it a console helper.
22:57@GiuseppeChillemi have you tried using icon: %my-file.ico in the header?
22:58It's doc'd somewhere, but I'd have to search to, so if you search for it, post the link here for the rest of us. :^)
GiuseppeChillemi
23:10@greggirwin as it exists, I'll search for it.

GiuseppeChillemi
16:24@greggirwin
https://www.red-lang.org/2016/03/060-red-gui-system.html
"Icon: file! or block! of files"
greggirwin
21:00:+1:

Claudio08
15:42@nedzadarek @greggirwin Hi, [here you can find two basic examples](https://github.com/Claudio08/Red-lang-first-steps) to retrive in Red/System with Windows API some locals names. For me was a good exercise, hope it's useful for someone else. Example of code result:
returned Red block :
[1040 "it-IT" "italiano" "Italiano (Italia)" "Italian (Italy)"]
GetUserDefaultLCID:  1040
GetUserDefaultLocaleName:  it-IT
LOCALE_SNATIVELANGUAGENAME:  italiano
LOCALE_SLOCALIZEDDISPLAYNAME:  Italiano (Italia)
LOCALE_SENGLISHDISPLAYNAME:  Italian (Italy)

and
returned Red block :
["lunedì" "martedì" "mercoledì" "giovedì" "venerdì" "sabato" "domenica" "lun" "mar" "mer" "gio" "ven" "sab" "dom"]

returned Red block :
["gennaio" "febbraio" "marzo" "aprile" "maggio" "giugno" "luglio" "agosto" "settembre" "ottobre" "novembre" "dicembre"]
nedzadarek
15:50@Claudio08 :clap:
You should post it somewhere so it's not lost.
@greggirwin said:
> If anyone wants to do the R&D on the various OS APIs, that would be great. A wiki page is fine to start.
greggirwin
16:15@Claudio08 Great! And please do add a Locale Handling wiki page to link from, as @nedzadarek said.
Claudio08
16:27@nedzadarek @greggirwin for the moment are saved in my space in github. I do not know how to add it in a wiki page. Pls if you can training me or you create the page and i will post there the code.
greggirwin
17:03@Claudio08 sure thing. If you go to https://github.com/red/red/wiki, in the upper right area is a New Page button. That gives you an editing area, and you can just save the page. I recommend you go to a few other pages, see how links are formatted, etc. and then you can create a Locale Handling page. Easy to edit if anything goes wrong, and we can help if you get stuck.
nedzadarek
19:40@Claudio08 to add to the above message: there is preview button to see how it would look like after you create/edit page.

Claudio08
12:28@greggirwin @nedzadarek created in the wiki [[HOWTO] Windows Locale Handling](http://github.com/red/red/wiki/%5BHOWTO%5D-Windows-Locale-Handling), hope that is ok
nedzadarek
12:29@Claudio08 :+1:
greggirwin
17:07:+1:
jlhouchin_gitlab
21:29I couldn't stay away for long. Red is just to attractive. It looks like the future to me. :)

I am working my way through the book Learn Red - Fundamentals of Red.

It talks about moving forward through a series with next. He says that each call to next increments the index

In the repl I do this:

>> l: [1 2 3 4 5 6 7 8 9]
== [1 2 3 4 5 6 7 8 9]
>> index? l
== 1
>> next l
== [2 3 4 5 6 7 8 9]
>> index? l
== 1
>> next l
== [2 3 4 5 6 7 8 9]
>> index? l
== 1

Am I doing something wrong or am I understanding something wrong.

Thanks.
greggirwin
21:31Hooked! We are the <insert drug of choice> of programming languages. :^)
21:32The Pakt book has some things that could be clarified, if that's your reference. Next *returns* a new offset, but does not modify the series reference it is applied to.
jlhouchin_gitlab
21:32 @greggirwin
:)
greggirwin
21:33
>> l: [1 2 3 4 5 6 7 8 9]
== [1 2 3 4 5 6 7 8 9]
>> index? next l
== 2
>> index? next next l
== 3
>> index? next next next l
== 4
>> n: next next l
== [3 4 5 6 7 8 9]
>> index? n
== 3

And it's nice to see you again. :^)
21:33So you can see that l and n refer to the same series, but at different offsets.
21:34You could also reassign to l, which is what you normally do, if stepping through a series in a loop of some kind.
21:35
>> l
== [1 2 3 4 5 6 7 8 9]
>> while [not tail? l][print mold l  l: next l]
[1 2 3 4 5 6 7 8 9]
[2 3 4 5 6 7 8 9]
[3 4 5 6 7 8 9]
[4 5 6 7 8 9]
[5 6 7 8 9]
[6 7 8 9]
[7 8 9]
[8 9]
[9]
jlhouchin_gitlab
21:41@greggirwin
Thanks. Glad to be back. Red looks like a nice place to call home.

It currently isn't the fastest solution of those I have played with. But I know that will improve with time. It is sufficient. Regardless, the other languages will never have the vision for what a language can be and what computing can be like you all have expressed for Red.

I also don't know if I consciously understood Red is a Lisp. That explains a lot. I have been looking for a practical, open source, cross platform Lisp to learn for a while. I couldn't find one. I guess I have now. I tried PicoLisp. It is interesting but its handling of numbers didn't work for me. Clojure is interesting. But I just can't handle the whole Java pig.
21:44Yes, the Packt book. I am enjoying it thus far.

I had seen the reassign pattern before. It is very usable. It would be very similar to popping a value off the head in something else.

It just seemed that the way things were said, that one could iterate over the values of the series using next while leaving the series intact. Not a problem. I just want to clarify my understanding. Thanks.
greggirwin
22:42Check out foreach and forall.
giesse
23:03@jlhouchin_gitlab more accurately, REBOL was heavily inspired by Logo ( https://en.wikipedia.org/wiki/Logo_(programming_language) ) and Forth ( https://en.wikipedia.org/wiki/Forth_(programming_language) ), so it is indeed rather closely related to Lisp.
23:05(if you click the above links, make sure they include the ) at the end, the link parser here does not seem to be very good.)
jlhouchin_gitlab
23:39@greggirwin

Yes, I am aware of foreach and forall. However, what I was looking for was something that was controlled by another function and not controlled by foreach.

candles: candlestream
loop [
    do [ something ]
    do [ something-with next candles ]
    do [ something-else ]
]

as opposed to
candles: candlestream
foreach candle candles [
    do [ something ]
    do [something-with candle]
    do [something-else]
]


I haven't put a lot of thought into it. And I haven't gotten to the part of my app where I have iterators in other languages. So I don't know how I want to implement at the moment. Just learning my options.

endo64
08:51@jlhouchin_gitlab How about a function like this: b: [1 2 3 4] forward: func ['word] [also get word set word next get word]
08:54forward b ; == [1 2 3 4] and b is now [2 3 4]
jlhouchin_gitlab
12:33@endo64
I don't yet understand what you wrote. It does seem to return the adjusted series. However, most of the time what I would need and I would think others also. Is to pop the head of the series. Returning the head and reassigning the series. I am sorry I was not more clear above as to what I wanted.

b: [1 2 3 4]
while b [
value: pop b ;== value is 1 and b is [2 3 4]
]
value is now 4 and b is now []

Much to learn. Thanks.
toomasv
12:43@jlhouchin_gitlab To just pop a value from head use take:
>> b: [1 2 3 4]
== [1 2 3 4]
>> value: take b
== 1
>> b
== [2 3 4]

But it modifies series.

Here is pop func (modified from @endo64 's) which returns first element and increments index:
>> pop: func ['series][also first get series set series next get series]
== func ['series][also first get series set series next get series]
>> value: pop b
== 1
>> b
== [2 3 4]
>> head b
== [1 2 3 4]
jlhouchin_gitlab
12:48@toomasv
Thanks. I haven't gotten to take in the book yet. It does exactly what I was referring to. Playing with it in the repl. Nice, very powerful. :)
toomasv
12:49:+1:
endo64
14:07@jlhouchin_gitlab I wrote it without first because easily write first foward blk to get the first value and also move forward the index.
14:08And don't forget that take modifies its argument.
greggirwin
19:46@endo64 @toomasv, I have incr/decr that could use review and comment. Will make a gist.
19:53https://gist.github.com/greggirwin/4dd6deb56dcba704bf6d418aff244373
hiiamboris
20:12I think it's a bad fit for Red. No set-words = word is leaking from the function, react won't see it, etc.
greggirwin
20:38There are many aspects here: Core idea (useful or not), design, and implementation.

What is the leak, exactly?

How can we solve the react issue, or do we eliminate potentially useful features because of that?
hiiamboris
20:53React relies on a specific pattern, because Red is too flexible to reason about otherwise. A special case can be made, i.e. like function does for foreach but it's a crutch, and a performance hit.
nedzadarek
20:59@greggirwin
; ...
>> i: incr 'i
== i
>> get i
== i

is it normal?
greggirwin
20:59@nedzadarek yes, read the comment in the code.
hiiamboris
21:00Leak can be either a local that one has forgotten to initialize, or (not necessarily intentional) modification of an external word (intentional would be using set) that happened during refactoring.
greggirwin
21:00Whether that's the best design choice is a different matter. :^)
21:02@hiiamboris so do we limit features because they won't work reactively, or note that not everything can?

So any leaks are not the fault of incr, but of calling code, correct?
21:04And a "leak" could be an intentional use of a global value, yes?
21:05Examples will help me to understand your thinking.
nedzadarek
21:05> @nedzadarek yes, read the comment in the code.

right
hiiamboris
21:12@greggirwin I believe there's a reason that a set-word is a single token and a separate datatype, not a just word and a colon. And the reason may be to introduce the very pattern you're avoiding :) Just thinking...
greggirwin
21:28Still not answering my question. Can I take it that you think it should never use indirection to update a reference in place, including paths, or that you have a better implementation that uses set-word syntax?
hiiamboris
21:44Yeah, sorry. Too many questions, and I've no final answers ☺ You're putting it correctly. I don't think that increment & decrement are worth the trouble they will cause by indirect value replacement.
21:47word: += n something would solve the issue though. Still, is it that common that we should have it instead of word: word + n?
21:54> word: += n something would solve the issue though

On a second thought, not entirely. From reactive system's point of view, in word: word + n we have both clear reactive sources and a clear destination. In word: += n the source can only be obtained by making a special case.
21:58Makes me think if we can revise the reactivity somehow...
greggirwin
21:59How do you pronounce +=?
hiiamboris
22:00I don't :) But it's from C.
dander
22:02I've always pronounced it "plus equals", but perhaps "increment" would be better, or "incr" for short :)
greggirwin
22:02@hiiamboris, I know. My point is, how do you say it, and what does it tell you?
hiiamboris
22:04"Plus equals" sounds good enough. Tells me that operands are added and an assignment is made.
22:05Replace it with =+ or =add or even incr-by whatever, I don't mind.
greggirwin
22:06OK, let's go with "plus equals", which is how I read it as well.

Do we use = for assignment in Red? Does anyone in school, ever, hear the phrase "plus equals"?
hiiamboris
22:06Not the point here. Point was, leave the set-word ☻
greggirwin
22:08It is the point, because you suggested it. So we discuss it to see if it's better. What we need is a concrete alternative to incr's problems as you see them.
22:08And is it better for Red, or better for humans in general?
hiiamboris
22:09Will incr-by operator name suit you?
greggirwin
22:09Noting that these are all compromises with brevity, clarity, and intent.
22:10Is incr-by better than incr and incr/by as I have them now?
22:10With a hint of reason in the opening comment of the gist.
hiiamboris
22:10incr/by cannot be an operator (it's a path). incr too (need 2 operands to make an op)
greggirwin
22:12So your solution, to get reactive support, and use set-word syntax, requires it to be an op!. Correct?
hiiamboris
22:12Yeah. Like is op.
greggirwin
22:13OK, that's progress. Now I see your view better.
dander
22:13Why can't set be used for reactors? And could that be changed?
greggirwin
22:14That may be possible @dander. I don't remember the details right now. @hiiamboris knows them much better, with recent work he's done.
hiiamboris
22:14@dander set evaluates the word given (set x gets x). You don't know what x is on reaction creation stage.
greggirwin
22:15There you go.
dander
22:17Oh, so do I understand correctly that you can't define a reaction using set, but a reaction would propagate from a reactor! which was modified using set?
22:18hopefully I'm not mangling the terminology
greggirwin
22:20@hiiamboris if we got with the op! approach, we give up a few things, and the syntax will be odd if we use incr as the name. i.e. x: incr 1. Makes it look like you're incrementing 1. And we can't get around that. Incr-by is a much better name in that case. If we use an incr function, it doesn't work with react, but you can still use other set-word based code to do so. Is that an accurate assessment?
hiiamboris
22:21Actually, I'm misleading you all. Sorry. set approach will work.
greggirwin
22:22OK, so now it's a matter of design choices. Whew! :^)
hiiamboris
greggirwin
22:24If you want to write up some reactor examples to include in the gist, for test and demo purposes, that would be great.
hiiamboris
22:29I'll think about it at a better time than night ☻
22:35Now that I'm analyzing where my idea about set-words came from, I'm starting to recall. Reactors will indeed detect a change, be it set or set-word. But as you might know I wanted to write a reactivity visualizing tool. It's there that this was a problem. It will not know the reactive target until the moment this target gets modified. Not a big deal either, just an implementation detail that will have to be explained to the users.
greggirwin
22:44Good to know.
nedzadarek
23:07@hiiamboris
> word: += n something would solve the issue though. Still, is it that common that we should have it instead of word: word + n?

There's group of = operator which I don't remember the name. Maybe we can implement system where a: = 1 is changed into a: function a 1 (or a: a op 1 in case of an operator)?
... well, that might be over engineering but you know that the above exist.
23:24How about incrementing by the number of digits after dot:
float-incr: function [v] [
    digits-after-dot: length? find/tail (to-string v) #"." 
    
    s: copy "0."
    repeat _ digits-after-dot - 1 [
        append s #"0"
    ]
    append s #"1"
    
    v + to-float s
]

  float-incr 1.0
; 1.1
  float-incr 1.01
; 1.02
  float-incr 1.011
; 1.012

ps. sadly:
float-incr 1.09
; 1.1
  float-incr float-incr 1.09
; 1.2

greggirwin
23:26@nedzadarek what is the use case for something like that?

nedzadarek
09:45@greggirwin For example generating loot from games. You have small chance to get a loot (for simplicity I have made it 'fail/'win states). After 100 tries your chances increase.
https://gist.github.com/nedzadarek/736f6188d72d6011d25e7292eff98460
rebolek
09:49@nedzadarek repeat _ x [...], I see you don't use _, so why not loop x [...]?
nedzadarek
09:53@rebolek I still forgot about many ways to do things. Thank you.
rebolek
09:53You're not alone :)
nedzadarek
09:59That's reassuring.
hiiamboris
11:12@greggirwin left you a comment there. But no *useful* react tests come to mind ☺
nedzadarek
11:29@greggirwin Some time ago you mentioned extended help. I have tried it using html. The code is [here](https://github.com/nedzadarek/extended-help).
11:35And you had a question like this:
> how do you keep parsed html

I know it has probably limited usage but I have kept whole tag. This allows you to get elements by whole tag, for example:
html: [
    <section id="foo"> [
      "something"
    ]
    <section id="baz"> [
       "something else"
    ]
]
html/(<section id="foo">)
html/(<section id="baz">)

Output:
== [
    "something"
]
== [
    "something else"
]
gurzgri
13:08> Not the point here. Point was, leave the set-word ☻

@hiiamboris @greggirwin Being late to the discussion and not being entirely serious: You could do
a: 1
++: func ['word [set-word!]] [set word: to-word word 1 + get word] 
++ a:
++ a:
++ a:
== 4

if you desperately need the increased value beeing collected as a function local word. :-)
I don't recall ever being caught by ++ and -- not using set-words in R2/R3, though, because wherever a word which should've been function local was the argument to ++ or --, that very word has been set using set-word syntax in the same function. Hence being local anyway.
nedzadarek
15:44@gurzgri If you are not being serious then I won't be as well:
system/lexer/pre-load: func [src][
    first-character: charset [
        #"a" - #"z" #"A" - #"Z" #"_"
    ]
    later-characters: charset [
        #"a" - #"z" #"A" - #"Z" #"_" #"0" - #"9"
    ]
    word-rule: [
        first-character
        any later-characters
    ]
    parse src [
      change ["++" copy incr-word word-rule ] (rejoin reduce [incr-word ": " incr-word " + 1"])
    ]
]
a: 1
++a
; == 2
++a
; == 3
++a
; == 4
gurzgri
15:48@nedzadarek Cool stuff on a whole different level, that! Doesn't help re: function auto-local words, though ... :)
nedzadarek
15:51@gurzgri it's just string change. If you need auto-local function try [this](https://github.com/nedzadarek/function-all-local).
15:51ps. ^^ not sure if you mean this by saying "function auto-local words"
Oldes
16:30@nedzadarek :point_up: [June 5, 2019 1:35 PM](https://gitter.im/red/help?at=5cf7a8f33dcdab4003f3272b) probably out of topic as I don't know to what you were answering, but I personally try to avoid load HTML data. I parse them in RAW format, which is much more lightweight... for example to get all images from google's query, I have just this:
parse data [
	any [
		thru {imgres?imgurl=} copy imgurl to {&imgrefurl=}
		thru {"pt":"}         copy desc   to {"}
		(
			print desc
			print imgurl
			print ""
		) 
	]
]

... and I don't care about the rest of JS/CSS/HTML shit which is also served to me.
toomasv
17:55@greggirwin

> I have incr/decr that could use review and comment.

It's an amazing piece of code (concerns about compatibility with react aside - I can't say anything in this regard). I imagine it could be promoted to action!, eh?
xmonader
18:24I'm sure you guys are working way too hard, but is there a channel to give constant updates on the red language weekly maybe or daily ?
dander
18:27@xmonader, have you seen https://progress.red-lang.org/ ?
xmonader
18:35@dander first time to see that link :) thank you. is there also issues tracking documentation status?
dander
18:41@xmonader I'm not sure about that one. Do you mean on the docs repo? https://github.com/red/docs/issues
xmonader
18:44I checked the those issues, none of them describes the required state of docs, as I see under construction https://www.red-lang.org/p/documentation.html here, and I don't see what's going to be constructed
18:45@dander e.g story providing soft documentation for X,Y,Z, full API documentation, examples on the API those can be stories to be tracked on the repo
dander
18:48I don't know if those things have been defined or are tracked anywhere
xmonader
18:48I see. Thank you anyhow :)
9214
18:55> is there also issues tracking documentation status

See [REP 3](https://github.com/red/REP/blob/master/REPs/rep-0003.adoc).
xmonader
19:00Thanks
greggirwin
19:25@nedzadarek will check out your help stuff later. Thanks!

On float-incr, I would probably use general incr with a scaling down of the percentage you want to increase by each time, for consistency. I guess my original question should have been more specific, about the mathematical goal/algo of adding another digit.
nedzadarek
20:05@greggirwin I see. That kind of problems have many, easy to understand, solution. Percentage solution seems nice too.
20:11@Oldes Yes, it's of topic but thank you nevertheless.
ps. for my problem :point_up: [June 5, 2019 1:29 PM](https://gitter.im/red/help?at=5cf7a7b1702b7e5e763225df) I don't need speed but I care whenever or not it works.

jlhouchin_gitlab
12:24I am using Red 0.6.4 for Linux built 1-May-2019/13:32:06-05:00 commit #8d712e4

I am working through the Packt book Learn Red - Fundamentals of Red.
Chapter 7 has functions of request-file and request-dir
But neither seem to be available.

The book when written seems to be using 0.6.3.
Any help appreciated.
toomasv
12:56@jlhouchin_gitlab On W10 both are working as expected (my current build is from May 21).
9214
13:01@jlhouchin_gitlab both functions rely on View backend, which is not officially supported on Linux.
jlhouchin_gitlab
13:04@9214
Okay. That would explain it. I knew Linux did not have a GUI. But I thought this would have worked in a CLI or in the REPL.
9214
13:10@jlhouchin_gitlab if you'd examine their source, you'd learn that they are aliases for system/view/platform/request-dir and system/view/platform/request-file. On Linux system/view object is absent alltogether. Neither CLI nor REPL have anything to do with it.
rcqls
15:03@jlhouchin_gitlab As @9214 mentionned it, there is only a branch red/GTKdealing with these functions. You can go to red/GTK room to have fiurther information. Also you could test [red-gtk](https://cqls.dyndoc.fr/users/RCqls/Red/red-gtk) but the latest build requires some further dependencies needed for camera stuff.
jlhouchin_gitlab
18:45@rcqls
Thanks. I have briefly looked at the red/gtk room.
Looks like interesting stuff you are doing. I will definitely at some point be ready to give it a try.

Right now I simply working my way through the book and learn Red sufficiently to port a couple of server side projects. Once I am more comfortable in Red, I will pay a visit to the red/gtk room and see what I need to do to give it a try.
rcqls
23:15@jlhouchin_gitlab Good to hear that and at some point I will write bash script to install all the dependencies for major linux distributions.
jlhouchin_gitlab
23:57@rcqls
That would be awesome. Personally I am currently using Xubuntu 19.04.
I would love to be able to write some personal stuff for myself and family. I can handle cli. But I have a wife on MacOS, children on Xubuntu, children on MacOS, and even some children on Windows (against my wishes :). They like gui. And yes, I have that many children. :)
I can even install 3 additional distributions on my laptop for testing if that helps. There are a couple lean and mean distros I have been wanting to play with.

Out of curiosity, will Red run on NetBSD sometime in the future? Possibly after it is completely bootstrapped?

Thanks.

greggirwin
03:47Your family is the perfect test environment. :^)
03:48Beyond major OSs, others need a champion. We're already spread thin.
jlhouchin_gitlab
11:16@greggirwin
Yes. I have always been a big believer in good cross platform software.
I have always believed my decision for platform should never be a requirement for someone else's choice of platform. We each have different needs, desires and goals.

Understood, and agree. I just don't yet know enough about that level of Red to know what that entails. I don't currently use NetBSD. But have always appreciated it and want it to succeed. LIke Red I admire its goals and what it strives for. Maybe someday I can be that champion (financially, not technically). :)

nedzadarek
12:42> Hi, to some extent I followed some guides on building interpreter for LISP/Scheme, but I dont know how to build an interpreter for Red lang, for learning purpose I want to build a one, from where I can start?

1) If you don't know it yet, you need to have an understanding of [series/blocks](http://www.rebol.com/docs/core23/rebolcore-6.html).
2-a) If it's some easy interpreter, you can just iterate over series:
f: function [src][
    foreach element src [
        case [
            element = 'aaa [
                print "Hello world"
            ]
            
            element = 'bbb [
                print "Goodbye cruel world"
            ]
        ]
    ]
]

2-b) If you need something more complex you should learn some parse - [parse introduction](https://www.red-lang.org/2013/11/041-introducing-parse.html)

ralfwenske
07:40I’m a bit puzzled by this: I can save an object to file - however when I load the file the contained map doesn’t keep object values?
Red 0.6.4 for macOS built 8-Jun-2019/18:04:27+10:00 commit #1b68168

Red []
o: make object! [
    a: make object! [ab: 23 cd: 45] 
    m: #()
]
ox: context [x: 1 y: 2]
put o/m 'a ox
put o/m 'x "something"
put o/m 'b context [xx: 3 yy: 4]
put o/m 'c context [xz: 5 yz: 6]
save %test.obj o
o1: read %test.obj
o2: load %test.obj
print ["The saved object:"]
print o1
print [newline "The loaded object:"]
probe o2

The output is this:
The saved object:
make object! [
a: make object! [
ab: 23
cd: 45
]
m: #(
a: make object! [
x: 1
y: 2
]
x: "something"
b: make object! [
xx: 3
yy: 4
]
c: make object! [
xz: 5
yz: 6
]
)
]

The loaded object:
[make object! [
    a: make object! [
        ab: 23 
        cd: 45
    ] 
    m: #(
        a: make
        object!: [
            xz: 5 
            yz: 6
        ]
        x: "something"
        b: make
        c: make
    )
]]

What am i missing?
nedzadarek
08:49@ralfwenske first, load won't execute any code, so make object! [...] won't work:
>> load "make object! [a: 1]"
== [make object! [a: 1]]
>> length? load "make object! [a: 1]"
== 3
08:59Secondly, if you want an object (or run any code) you need to somehow execute it, do might help:
>> select do{#(aa: 11)} 'aa
== 11

... but it seems that map doesn't support such syntax:
>> #(a: object [a: 1])
*** Script Error: invalid argument: [a: object [a: 1]]
*** Where: do
*** Stack: load

You would have to save it in some serialized form or something, like save/all but it's still not implemented (as for Red 0.6.4 for Windows built 24-May-2019/13:56:13+02:00 commit #d56d840).
Oldes
09:26@nedzadarek Red has not yet implemented construction syntax as it was in Rebol:
>> mold/all make object! [a: 1]
== "#[object! [^/    a: 1^/]]"
>> mold/all/flat make object! [a: 1]
== "#[object! [a: 1]]"
>> length? load {#[object! [a: 1]]}
== 1
ralfwenske
09:33Thanks @nedzadarek I will revert to my original (already working) solution where I store just values-of object (a single object type) in the map.
I am learning a lot by writing a simple 'object database' …. and enjoying the clarity of the language and implementation (as far as I understand it) :)
Will look forward to be able to save and load variations of objects as value of maps.
9214
11:09> I store just values-of object (a single object type) in the map

You might as well use block!or map! of map!s instead, because the scheme you describe doesn't make any sense.

map! doesn't evaluate anything you put into it, so, while put #() 'a object [b: 'c] works, #(a: object [b: 'c]) will not, because map! thinks that a: object is a key/value pair and [b: 'c] is an illegal key. In other words, it follows construct semantics.

The same happens with #(a: make object! [b: 'c]): a: make is a valid key/value pair, so as object! [b: 'c].

>> put m: #() 'a object [b: 'c] 
== make object! [
    b: 'c
]
>> m
== #(
    a: make object! [
        b: 'c
    ]
)
>> #(a: make object! [b: 'c])
== #(
    a: make
    object!: [b: 'c]
)

So, if you want to save and load your data in a map!, you need to use values that have literal syntactic forms, e.g. block!, paren!, map!, etc.
rebolek
11:12block of maps is my preferred data structure
9214
11:14IIRC @rebolek has a special dialect for queries over block of maps, qobom.
rebolek
11:34yup, it's SQL-like dialect that's really useful when working with block of maps
nedzadarek
11:55@Oldes I see, thank you.
12:10@ralfwenske
Do you really need object!s? In the Red there are other key-value store types. Even block can act as one.
If you don't need to really on other fields like this (b depends on a a):
o: object [
    a: 4
    b: func [][a + 1000000]
]

I would choice other types. My preference is map! as it's the easiest to use.
ps. no problem
Claudio08
14:45Hi, i need to merge two or more Red scripts and then compile it in only one .exe
e.g. in "main.red" i want to include "xyz.red" that contain some Red code custom functions.
I used in main.red "do %xyz.red" and with the interpreter it work.
I can compile it, but when i run the .exe it give:
"*** Access Error: cannot open: %xyz.red".
Is it possible to obtain one exe from many Red scripts?
Thanks
9214
15:30@Claudio08 #include %xyz.red. do %xyz.red invokes interpreter and requires file to be present at the specified path (in your case in the same directory with compiled executable).
greggirwin
18:00On OODBs and what to store, maps and blocks are great, of course, but it's also fine to use objects. There is still some design clarification to do because of overlap in those 3 main data structuring options. Each has strengths and unique behaviors (which can be subtle), meaning they aren't completely interchangeable.
jlhouchin_gitlab
20:06As I read the conversation. When would you prefer objects over maps or vice versa and why?

When you come from object oriented languages you tend to think in objects more than data structures per se. I am trying or wanting to learn to think in Red.

Also, naively I initially thought creating an object would also create a type but no.

instrument: object [
    name: "string"
    base: "string"
    quote: "string"
    ...
]

I thought it would create a type instrument' instead of simply object. Is it common or not common to create your own datatypes in Red? I haven't yet discovered or seen how to do so. Also in the example above is the instrument attribute quote a problem? I haven't tried but it doesn't seem as if it would conflict with quote` function.
Thanks.
pekr
20:16You can't create custom types, although there were some ideas of their addition into the language. However, your instrumentobject can be used to create a new one as a prototype: my-instrument: make instrument [something: "string"] ; -- will add a new word somethinginto an object
9214
20:20> When would you prefer objects over maps or vice versa and why?

object!s are essentially namespaces and are used for encapsulation (i.e. modules), they also serve as environments; map! is a key/value dictionary.

> naively I initially thought creating an object would also create a type but no

There's no way to create custom datatypes (not without extending runtime in Red/System), but it will be possible in the future.

> Also in the example above is the instrument attribute quote a problem? I haven't tried but it doesn't seem as if it would conflict with quote function.

That's not a problem. As I said, objects act as environments, and you can evaluate expressions in them. All words in them are encapsulated and don't affect other environments (including global one).
nedzadarek
20:29@jlhouchin_gitlab there is no easy way to create your own datatype. Here is [tutorial](https://github.com/BeardPower/red/wiki/How-to-create-a-new-datatype-for-Red) if you are still interested. Even you learn to create your own datatype I don't think you should create one without serious thoughts.

> object vs map

As far I remember there are only 2 cases where I would choice object:
- If my fields depends on other fields within an object (as in [previous message](https://gitter.im/red/help?at=5cfe48d0d4e3840c69615788))
- you want to bind something (bind doesn't accept a map!)

As for map:
- independent fields
- you want extend (add key-value pairs) it
- object! does not support all types of keys
20:33@jlhouchin_gitlab as noted in :point_up: [June 10, 2019 10:16 PM](https://gitter.im/red/help?at=5cfebaa3faac6439347385f3) the Red is more [prototype based OOP](https://en.wikipedia.org/wiki/Object-oriented_programming#Class-based_vs_prototype-based)
greggirwin
20:44Let's start with datatypes. They are implemented in Red/System, and you can add your own, though then you need to build a custom runtime (easy to do of course). The bigger issue is that nobody else will have them. They are more a solution for very specific needs, and making the most useful and general standard in Red. You shouldn't need to implement new types in Red, though it will be a good solution for some people.

What to do then? Use objects. The difference being that you don't have the same support for actions (help action!) as with native datatypes. If you have a specialized numeric or series type, and want add or append support, you need to make a new datatype.

Others beat me to answering, as I juggle chats. Thanks guys!
20:45While we say Red is all data, in map v. object, while there is overlap, think of maps more like data, and objects more like data+functionality.
jlhouchin_gitlab
20:46Thank you all for all the answers and advise.

@9214
Thanks for the information about objects being used for encapsulation. That is one way I was using one, but was not sure if I was being idiomatic.

I have multiple brokers. Each will be required to implement the exact same functions with the exact same names. The implementation is specific to the broker.

What I did was create a brokername.red file and inside created an object brokername which had all the functions. Then I can create and pass around the broker objects and call the desired function without caring who the broker is and how it implemented the functions. I also didn't want to polute the current namespace. I like things clean. :)

I don't have a requirement for creating my own datatypes necessarily. That is idiomatic in many other languages. So I wanted to inquire. I want to learn and write idiomatic Red.
9214
20:46Implementation-wise, map! internally hashes its keys and has faster lookup time, and has more relaxed rules for key datatypes, but more restricted semantics for values, as evident from the conversation you've read: basically, map! is a hybrid of block! and object! with construct semantics. You can freely update and remove key/value pairs in it.

object!, on the other hand, accepts only set-word! keys, and can store any datatype. You cannot remove keys, as that will wreak havoc on evaluation model, and you cannot (yet) add new key/value pairs (mainly because that makes live harder for compiler). object!s play an important role in reactivity framework and in Red evaluation model in general, as they store values indirectly refered by any-word!s, which act as "variables".
greggirwin
20:50@jlhouchin_gitlab as you learn more, you'll see that Red doesn't push OOP like many langs. So you can easily create hybrid systems that use objects to contain related functions, but those functions take parameters, rather than making them part of the object and making things implicit. The design of functions, which can be very rich and powerful, along with typesets and shared behavior, is a key element of Red's expressivity and small size.
jlhouchin_gitlab
21:19As I learn Red. I really appreciate many of the decisions that have been made. I like the simplicity it offers while yet being nicely featured.

For example one of the requirements I have is what is handled in other languages as a Duration or Interval object. You have Magnitude, Date, Time, DateAndTime, Duration, ... A plethora of types.

So I asked myself how do I handle the duration in Red. Well, the simple time object worked perfectly.

Duration seconds: 5 == 00:00:05 :) Very nice.

When requesting historical records of time series objects. You are limited to a certain number of items per request.

max-items: 5000
timeframe: 00:01:00
from: 2006-01-01
to: max-items * timeframe
end-time: now/precise/utc
;-- iterate from until end-time max-items at a time.


I am really liking Red. I do have my frustrating moments when I don't quite understand something and I am not finding the documentation. And I really, really hate imposing on y'all's (a legal word in Texas :) precious time for what seems simple things. But y'all are exceptionally friendly and helpful. And I am most grateful for you all.
21:26
prototype
based languages. And will take some time for my brain to wrap around some of the more advanced concepts. But right now that is not necessary to keep moving forward. Porting from other languages isn't straight forward and does take some thinking and a little iteration to get it reasonably right. I know some of my code will still be naive and will warrant a rewrite as I learn. But that is a part of learning and growing.

One thing I haven't seen yet is how to idiomatically document all of my Red code. Now I have not expressly looked for such documentation. If I have missed it my apologies.

For example in the code I am porting. I have extensive documentation in the module or at the file level of the code. I document my philosophy and why I made some of the decisions I made. This helps me as I write my code. And it would also help someone else when I open source it.

Again Thanks.>
greggirwin
22:07All questions are welcome. Others have them too. And hearing what isn't clear, along with moving answers to the wiki, are all helpful and not an imposition.
nedzadarek
22:09@jlhouchin_gitlab only this: http://www.rebol.com/docs/core23/rebolcore-9.html#section-3.1
greggirwin
22:27Documentation, commenting, and tests, all the ancillary data that relates to code isn't standardized, though we've talked about heredoc support, it's easy to include tests, and generate docs from code, and @giesse wrote a literate programming system in Rebol2. Because of help and source, just generating static docs isn't as helpful, but can still be useful. The most value comes from things like red-by-example, and having humans put their knowledge into a system.

jlhouchin_gitlab
00:47@greggirwin
Thanks.

What I have currently done is simply
Red[
 ... 
    Comment: "100 line string" ]

I am not concerned about generating documentation but rather simply documenting the code for those who are reading the code. Generating documentation would simply be a bonus. Even if it is simply ...

? file

Thanks.
ralfwenske
04:35My preference for Rebol/Red was and is that
* I know my app can run on any of Windows/Mac/Linux and more
* I don't need (mostly) worry about performance (Red even compiles and later on optimises)
* I benefit from the deep knowledge and dedication of all experts involved resulting in this clean development environment.

The more I get 'my hands dirty' the more I get to know and appreciate the deeper workings.

To get back to the maps and objects issue: I am exploring an 'objects.red' storage system that allows me to write and evolve an application quickly.
And it performs fast and I can code *to the (my :) point* .
Following code creates a crypto transaction store (%ledger.obj).
do  %libs/csv.red		; thanks @rebolek
do load %libs/objects.red
do load %coingecko.red

ledger: make objects [file: %data/ledger.obj]  ; CREATE ledger store
ledger/init [                    ; DECLARE object elements (FIELDS)
	date: [11 0]		 ; [column-width-align decimals] 
	facct: [14 0]
	famt: [-14 6]
	fcoin: [7 0]
	fpriceaud: [-14 6]
	fcost: [-14 6]
	tacct: [14 0]
	tamt: [-14 6]
	tcoin: [7 0]
	tpriceaud: [-14 6]
	tcost: [-14 0]
]

ta: csv/decode %data/import/transactions.csv
foreach l ta [
	if date? load l/1 [		;ignores header lines
 		ledger/object/date: load l/1
		ledger/object/facct: l/4
 		ledger/object/famt: to-float l/3
		...	; coingecko/getPricedAUD is also objects store based: 4494 objects
		ledger/object/fpriceaud: either ledger/object/fcoin = "AUD" [1][
			coingecko/getPriceAUD ledger/object/date ledger/object/fcoin
		]
		...
	]
        ledger/add ledger/object	;returns a unique (never reused) key (integer!)
    ]
]
ledger/save

the following code creates a sorted index based on the given fields. An update deletes all indexes.
(this index is used for binary search as well if fields match
eg. ledger/find ['date 11-Jan-2017 'facct 'binance 'famt 'any] returns a block with id's of matching objects
calling ledger/find ['facct 'binance 'date 'any] does the same but automatically creates a different sorted index
Red []
do load %libs/globals.red
do load %libs/objects.red
ledger: make objects [file: %data/ledger.obj]
if ledger/load [ 
	ledger/print/header/withid/fields 1 [date facct famt]  ;prints all if /fields is omitted
	repeat ix length? ledger/data [
		ledger/print/withid/fields ix [date facct famt]
	
	]
]

resulting in
id date        facct                    famt 
   1 11-Aug-2017 MC                  21.490000 
   2 11-Aug-2017 MC                 270.370000 
   ...

so to summarise: I find blocks, objects, maps allow a lot to do yourself - and thus learn
(of course this could be done using SQL or other tools - it's just enjoyable to do it all in RED!)

PS If you feel this was too long - please let me know. I just thought it might be interesting for some newcomers.
greggirwin
04:48Thanks for posting @ralfwenske. Always nice to see what people are doing with Red.
rebolek
05:58@ralfwenske
> do %libs/csv.red ; thanks @rebolek

You're welcome! BTW, CSV codec should be soon included in Red.
jlhouchin_gitlab
12:06I can create a date simply by
dt: 2019-01-01T00:00:00Z
dt: 2019-01-01T00:00:00.000000000Z

But I haven't seen a way to go from that dt back to the original. I have written a function that does so as it is necessary to use that form for the REST API.

I also haven't seen a way to take a string "2019-01-01T00:00:00Z" like I will receive in JSON and turn it into a date.

It isn't hard to write these functions. But if they already exist and I just don't know about them, then I would like to know that. Thanks.
rebolek
12:09@jlhouchin_gitlab
>> load "2019-01-01T00:00:00Z"
== 1-Jan-2019/0:00:00


AFAIK there's no to-iso-date-like func in Red, but I agree it should be part of Red. I use this:
to-iso-date: func [
        date [date!]
        /local align seconds zone hyphen colon
][
        align: func [value][next form value + 100]
        seconds: func [value][
                value: either value < 10.0 [form value + 10.0][form value]
                case [
                        6 > length? value [pad/with value 6 #"0"]
                        6 < length? value [clear skip value 6]
                ]
        ]
        zone: func [value][
                rejoin [
                        either negative? value [#"-"][#"+"]
                        align value/hour colon align value/minute
                ]
        ]
        hyphen: #"-"
        colon: #":"
        rejoin [
                date/year hyphen align date/month hyphen align date/day 
                #"T"
                align date/hour colon align date/minute colon seconds date/second
                #"Z"
                either date/zone [zone date/zone][""]
        ]
]
jlhouchin_gitlab
12:48@rebolek
Thanks. I would not have thought of load. I had tried to-date but that failed with error.
That is one of the hard things when the docs only say it takes a value. But don't say what value(s) it takes.
I guess I need to learn to think load when I have a string of some form of literal value.

This is what I had already written before I posted. But I thought, before I litter my code with calls to this function. I might inquire as to whether Red already has one builtin.

;-- No sub-seconds wanted here. I have another function /precise which includes sub-seconds, 9 digits.
format-datetime: function [dt [date!]][
    rejoin [dt/year "-" pad/left/with dt/month 2 #"0"
                "-" pad/left/with dt/day 2 #"0"
                "T" pad/left/with dt/hour 2 #"0"
                ":" pad/left/with dt/minute 2 #"0"
                ":" pad/left/with to-integer dt/second 2 #"0" "Z"]
]

In my app everything is UTC so I don't have to worry about zones. I will have to spend some time studying your code.

One thing I notice in your code is that you have the character #"Z" and then the zone. It is my understanding that the #"Z" terminates the string denoting UTC.

It could be I am not understanding your code correctly. But it seems there is a possibility of ...Z-04:00 or such. I don't know if that is allowed. I am far from knowledgeable on the subject.
rebolek
12:56...Z-04:00 is allowed. Western hemisphere timezones all start with minus sign.
12:57For UTC, my code will return string ending with Z as no zone returns empty string. It may probably check for 0:00 zone too.
jlhouchin_gitlab
13:02Okay. I just thought the Z would be unnecessary as all that I have seen are like this on the wikipedia page 2007-04-05T12:30-02:00 no Z.
My timezone currently U.S. Central is -05:00. Thanks for the education.
rebolek
13:06You're welcome.
Znot followed by anything denotes UTC time zone. It's not required, 2007-04-05T12:30-02:00 is valid too, but IMO it makes sense to add the Z separator.
nd9600
14:38Another interpreter question:
I'm trying to look at what the pc is, but it and the word!s the functions are all using are some type red-value! (which I can't see [here](https://static.red-lang.org/red-system-specs.html#section-4) by the way?), and when I type in a: 1, it prints out
code: 098A19F4
value:F65DDA6C
in eval-expression
pc: F65DDA6C
end: F65DDA7C

rather than a: 1 Is there some way of converting it to a string/ the actual thing I typed in? I guess it's sort of memory address? In the compiler, it would say something like pc: [a: 1]`
14:49Though no matter what I type in, their values are exactly the same everytime, for each 'session' in the console, so I'm not sure what it is
9214
15:30@nd9600 red-value! is a generic boxed structure for all Red values. It is, in fact, an [alias](https://github.com/red/red/blob/master/runtime/datatypes/structures.reds#L17) for cell! structure, which is [defined](https://github.com/red/red/blob/master/runtime/allocator.reds#L34) in memory allocator. Why you're searching for it in Red/System spec is a mystery to me.

PC is a Program Counter, a memory pointer which interpreter uses to track execution. In your example it points to the beginning of cell a:, which is 16 bytes in size. end points to the last cell in the expression, which is 1, and it is precisely address of a: plus size of the cell:
>> to-hex F65DDA6Ch + 16
== #F65DDA7C


> Is there some way of converting it to a string/ the actual thing I typed in?

I don't follow what you're trying to do here. Values that reside in memory can be molded and printed out, for that you need to call into appropriate datatype API (in this case [block/mold](https://github.com/red/red/blob/master/runtime/datatypes/block.reds#L684) on a [root block](https://github.com/red/red/blob/master/runtime/red.reds#L130)) and either pass it onto evaluation stack or inspect the string buffer directly.

> In the compiler, it would say something like pc: [a: 1]

Because compiler is written in Rebol and uses series index for program counter.
>> block: [a b c d e f g]
== [a b c d e f g]
>> next block
== [b c d e f g]
>> block: skip block 4
== [e f g]
>> block: skip block -2
== [c d e f g]
nd9600
15:52@9214
Thanks, that helps a lot!

> Why you're searching for it in Red/System spec is a mystery to me.

I was in a Red/System file, and it looked like a type, since it has an ! at the end, so I looked in the R/S spec to see if it was there

> I don't follow what you're trying to do here.

Basically, I wanted to see what inputted code the interpreter was looking at at each moment; so, if I typed
a: context [b: make op! function [x y][x + y]]
print 4 a/b 5

into the console, I wanted to see it go through the 2nd line, so I could see what I needed to change to get it work with the op! in the object, like I have [with the compiler](https://github.com/nd9600/red/blob/master/compiler.r#L1112) already

I was looking at the [CHECK_INFIX macro](https://github.com/red/red/blob/master/runtime/interpreter.reds#L13), because I thought I'll need to change it (maybe I'll need to change eval-infix instead), and I was trying to see what next and end actually were
9214
16:11@nd9600 unless you're doing it for self-education, I strongly suggest to discuss any changes you intend to do with core developers. op! call doesn't work with paths simply because infix check is already a costly operation, and adding to it a full path! analysis will induce extra overhead which is simply not worth it for such a rare use-case.
greggirwin
16:12@jlhouchin_gitlab my format dialect experiments have full date support: https://github.com/greggirwin/red-formatting
16:12So, yes, Red should make this really easy.
jlhouchin_gitlab
21:06@greggirwin
Thanks for the link. Will some of this stuff make it into official Red some day?

greggirwin
02:57That's the plan.

jlhouchin_gitlab
18:47Does Red allow or have a way to do default values for arguments to a function?
9214
18:49@jlhouchin_gitlab no. If you want optional arguments, or special-case arguments that override default values, use refinements.
jlhouchin_gitlab
19:00@9214

Ah. Okay. Thanks.
greggirwin
19:00@jlhouchin_gitlab people have tinkered up func wrappers to do so, but we haven't found it to be a win yet. A couple reasons for that are Red's free ranging evaluation, which means either not having a type spec for an arg, or including none! as an option. Then you have to pass none, which isn't always informative at the call site. Finally, using any [my-arg default-value] is a clear idiom you'll see.

@9214 is spot on with his suggestion as well. That's what refinements are for. Combine that with the above, and you may not need more. But wait!

If you want to set default values, why not have a function for it?
19:00Here are a couple experiments you can play with, and then tell us what you think.
19:01(I haven't tried to compile these, so the inner def may trip up the current compiler. Be warned.)
19:02
default: function [
	"Sets the value(s) one or more words refer to, if the word is none or unset"
	'word "Word, or block of words, to set."
	value "Value, or block of values, to assign to words."
][
	def: func [w "Word" v "Value"][
		; We're setting one word, so don't need to use set/only.
		if any [not value? :w  none? get w][set w :v]
		get w
	]
	; CASE is used, rather than COMPOSE, to avoid the block allocation.
	case [
		word?  :word [def word :value]
		block? :word [
			collect [
				repeat i length? word [
					keep/only def word/:i either block? :value [value/:i][:value]
				]
			]
		]
	]
]
default a 1
default [a b c] [2 3 4]
default f :append
;default [g h i j "k" #l m] [1 2 [3] 4 5 6 7]
;default [g h i j "k" #l m n o] [. . . . . . . .]
default [g h i j k l m] [1 2 [3] 4 5 6 7]
default [g h i j k l m n o] [. . . . . . . .]
19:03
; word(s)-value pairs interface.
default: function [
	"Sets the value(s) one or more words refer to, if the word is none or unset"
	input [block!] "word(s) value pairs"
][
	def: func [w "Word" v "Value"][
		; We're setting one word, so don't need to use set/only.
		if any [not value? :w  none? get w][set w :v]
		get w
	]
	; CASE is used, rather than COMPOSE, to avoid the block allocation.
	foreach [word value] input [
		case [
			word?  :word [def word :value]
			block? :word [
				collect [
					repeat i length? word [
						keep/only def word/:i either block? :value [value/:i][:value]
					]
				]
			]
		]
	]
]
default [a 1]
default [
	a 2
	b 3
	c 4
	[d e] -1
]
default compose [f (:append)]
default [g 1 h 2 i [3] j 4 k 5 l 6 m 7]
default [[g h i j k l m n o] '.]
print [a b c d e :f g h mold i j k l m n o]
jlhouchin_gitlab
19:52@greggirwin
I am really enjoying the freedom in Red. It took me a little while to be get used to it enough to read it well enough to move forward. It is different from the rest. But once you get to certain point that you can start to do things you begin to really like it.

I haven't necessarily had a real need for a default value in Red. But as I was working on something that I am porting I saw a default value. It wasn't a problem to work around. But was curious since I had not seen such.

I am really enjoying using refinements. I have much to learn but they are a very nice way to solve many problems.

I will have to take some time with your code and learn. Thanks.
GaryMiller
20:27Would it be possible to write a program that would translate standard RED script into Red system. I'm thinking like a precompiler that may stop and tell you what needs changed to be able to convert a troublesome part to RED System. I've been reading about the great speedup you get when converting code to RED System but there seems to be some drawback to like having to recompile everytime you make a change. My Lex times are up to 4 seconds but fairly instant when I compile. My compile times are over 4 minutes now with -r and my in program response times range from 3 to 13 seconds. So some additional speedup would be nice since I plan on doubling the size of the code in the next 6 months and expect my response time to rise proportionately. I'm really excited though about how slowly my executable size has been growing. I hope when the next major release comes out to break the program into MicroServices which each MicroService running a portion of my patterns and returning their best match back to the main program to display the results and accept another user input.
greggirwin
20:57@GaryMiller there is no optimizer or analyzer. You can use --red-only when compiling, but that's just going to overload you I think, and is more for internal debugging purposes. If you're able to just use -c, not -r, compiles should be very fast, as you're not rebuilding the runtime every time then. Using -e should also give you near instant compiles, but no speedup, as everything is still interpreted at runtime.

We have profile experiments, https://gist.github.com/greggirwin/908d44dc069ed84cf69f053e1308390d and https://gist.github.com/giesse/1232d7f71a15a3a8417ec6f091398811 that might help you identify bottlenecks.

It's hard to suggest much without knowing more details. But learning what is slow, and how people are using Red is incredibly valuable, so if you provide info, we'll dig into it.

nedzadarek
10:19@jlhouchin_gitlab collecthas "default" value using refinement as @9214 mentioned (collected word):
func [{Collect in a new block all the values passed to KEEP function from the body block} 
    body [block!] "Block to evaluate" 
    /into {Insert into a buffer instead (returns position after insert)} 
    collected [series!] "The buffer series (modified)" 
    /local keep rule pos
][
    ; ...
    unless collected [collected: make block! 16] 
  ; ...
]
10:33@greggirwin
> A couple reasons for that are Red's free ranging evaluation, which means either not having a type spec for an arg, or including none! as an option.

I don't think that's the problem. The problem is you have to pass exactly N number of arguments. So, as you said, you have to pass some value. One way is to use refinements or key-value store, something like @giesse [topaz' parse](https://github.com/giesse/Project-SnowBall/blob/master/topaz/types/function.topaz#L114):
test-skip/options [series: [1 2 3] amount: 1]

When you don't pass key: value pair, key will have default value.
viayuve
13:37"multiprocessing like python in red" what i want to do? like take process divide into small chunks after that distribute those chunks to cpu cores for processing. At end join all processed chunks and output it.
13:38any help will be appreciated thanks :)
nedzadarek
13:56@viayuve "something" like this is planned.
viayuve
13:59@nedzadarek prototype?
nedzadarek
13:59@viayuve I don't know.
Softknobs
14:05Hi, I see from the 0.6.4 release notes that http verbs but I have found neither examples of its usage nor documentation. Are there some example for get/post/put/delete available somewhere or is there some rebol documentation that is also valid for Red on this subject? Thanks.
9214
14:10@Softknobs https://github.com/red/red/wiki/[DOC]-Guru-Meditations#how-to-make-http-requests
14:11Or @rebolek's [http tools](https://github.com/rebolek/red-tools/blob/master/http-tools.red).
Softknobs
19:19@9214 Thank you! I had not seen that this was in the wiki. That page has really interesting information. http tools looks great too.

greggirwin
01:33@viayuve the map-reduce pattern isn't native to core Python, is it? I'm out of touch with it, for a long time, so maybe Twisted or something else influenced a new standard bit. In any case, the more specific you can be, the more help we can be, bearing in mind that Red is single threaded, and won't have full I/O until 0.7.0, for things like libuv does.

GiuseppeChillemi
20:56Is there a way to select using a lit-path as selector and key ?

>> s: ['tables/customers/minidata [code "c000010" delay 20]]
== ['tables/customers/minidata [code "c000010" delay 20]]
>> select s 'tables/customers/minidata
== none
>>


I had no success
greggirwin
21:10There are a couple things that come into play here, the auto-evaluation of paths, and the fact that they are a block type. For the first, you need to suppress evaluation somehow, e.g. with quote. For the second, use select/only.
>> s: ['tables/customers/minidata [code "c000010" delay 20]]
== ['tables/customers/minidata [code "c000010" delay 20]]
>> select/only s quote 'tables/customers/minidata
== [code "c000010" delay 20]
GiuseppeChillemi
22:04@greggirwin
Thanks, I have a block which rapresents some database tables and I need to put move some data externaly to have a more compact view when editing values.
My idea is to have a lit path as reference to the data moved externally.

This is an example of block with table data:

base: [
	tables [
			customers [
				fields [
					code "c000010" 
					delay 20
				]
			]
			articles [
				fields [
					arcode "A000222" 
					price 22 
					sizex 20 
					sizey 40 
					sizez 33 
					weight 145
				]
			]
		]
]


This is the block content I have moved externally:

extra: ['tables/customers/fields [code "c000010" delay 20]]


This is how it will be referenced in the main block:

base: [
	tables [
			customers 'tables/customers/fields
			]
			articles [
				fields [
					arcode "A000222" 
					price 22 
					sizex 20 
					sizey 40 
					sizez 33 
					weight 145
				]
			]
		]
]


Basically I'll need two select to retrieve it, the first on the main data block, the second on EXTRA

It would be really great to access it in a single select using a normal path in the main block:

base: [
	tables [
			customers extra/tables/customers/fields ;<<<<<<<------------
			]
			articles [
				fields [
					arcode "A000222" 
					price 22 
					sizex 20 
					sizey 40 
					sizez 33 
					weight 145
				]
			]
		]
]


But I have not found a way let it work.
Have you an idea ?
22:16(note, you should remove the last ] in the blocks above
greggirwin
22:25You're modeling data, so don't expect Red's standard evaluation rules to work across arbitrary structures, because it can't know how your referencing system works. You either need to build your own evaluator for that, or model your structures so Red's standard rules apply, perhaps with some helper funcs.

Think of it this way, your data model is like a dialect. The grammar for that dialect is your schema, which Red knows nothing about.
GiuseppeChillemi
22:44@greggirwin I have created a function which composes a block and its moved data but I had not the expected result:

base: [
	tables [
			customers [fields 'tables/customers/fields]
			]
			articles [
				fields [
					arcode "A000222" 
					price 22 
					sizex 20 
					sizey 40 
					sizez 33 
					weight 145
				]
			]
		]
 


extra: ['base/tables/customers/fields [code "c000010" delay 20]]

compose-blocks: func [the-block the-extras] [
	foreach [key value] the-extras [
		the-path: to-path key
		change/only reduce the-path copy/deep value
	]
]

compose-blocks base extra
probe base

Here is the output, please, take a look at the changed customers value:

>> do %cpath.red
[
    tables [
        customers [fields '[code "c000010" delay 20]/customers/fields]
    ] articles [
        fields [
            arcode "A000222" 
            price 22 
            sizex 20 
            sizey 40 
            sizez 33 
            weight 145
        ]
    ]
]
== [
    tables [
        customers [fields '[code "c000010" delay 2...
>>


Only the first element of the path has been changed !
22:45
customers [fields '[code "c000010" delay 20]/customers/fields]
22:47Without only in change/only I get even weirder results

customers [fields 'code/"c000010"/delay/20]

nedzadarek
00:13@GiuseppeChillemi

Well, change doesn't even mention what happens when value is a series (append & insert have (s) in a help).

> /only => Changes a series as a series.

In my opinion this description is not clear.
Let me explain then:
- With /only function treat a value argument as singular value (thing). If you are inserting or appending with /only then you will have series that has length larger by 1.
change/only will change 1 value with another value - length is the same.
- Without /only functions try to accommodate so they will "do x" as many times as needed. For example, if you are inserting or appending [a b c] then a resulting series will have length larger by 3 (length? [a b c]) - it will just add all values of [a b c] (a, b and c) to a series.

If only want to change part of a series, then use part - if range is a number then it will just delete N number of elements and insert something in that place.
00:20> weirder results

If you think '[...] is less weirder than 'something/"string"/something/23 then I guess you should check types of values at each step.
GiuseppeChillemi
04:59@nedzadarek I have considered a lit-path being a single value and having just used only in select my mind was continuing with that concept
05:02I have just tried clear on the direct path to the lith path:

>>> clear reduce the-path

...
customers [fields ']
...


Never seen an empty lit-path in my life. It's my first time.
05:07I am now confused. Having a path to a lit-path value, how do I remove the whole value instead of clearing the value series ?
05:11remove base/tables/customers/fields

Does not do it either.
greggirwin
05:13I don't know what you mean by "remove the whole value". But lit-paths are block values, so you need to think of them like that when using series operations on them.
>> p: 'base/tables/customers/fields
== base/tables/customers/fields
>> change p 'xxx
== tables/customers/fields
>> p
== xxx/tables/customers/fields
GiuseppeChillemi
05:19@greggirwin Now I have acquired other knowledge
But, having a path or a select, is there a way to remove the "container" and not the content inside the container ?

>> a: [y [z]]
== [y [z]]
>> remove a/y
== []
>> probe a
[y []]
== [y []]


I wish the output being

= [y]



greggirwin
05:20Does this do what you want?
base: [
    tables [
            customers [fields 'tables/customers/fields]
            ]
            articles [
                fields [
                    arcode "A000222" 
                    price 22 
                    sizex 20 
                    sizey 40 
                    sizez 33 
                    weight 145
                ]
            ]
        ]



extra: ['base/tables/customers/fields [code "c000010" delay 20]]

compose-blocks: func [the-block the-extras] [
    foreach [key value] the-extras [
        the-path: to-set-path key
        do reduce [the-path copy/deep value]
    ]
]

compose-blocks base extra
probe base
05:22If you do this:
>> a: [y [z]]
== [y [z]]
>> a/y
== [z]

You can see that remove is operating on [z], and has no concept of y at all. But you can do it like this:
>> head remove find/tail a 'y
== [y]
GiuseppeChillemi
05:241) Ok it works
05:282) I see there is no way to select the outher container using a path or a select methods.
greggirwin
05:28Correct.
nedzadarek
08:24@GiuseppeChillemi types from any-path! (list it by ? any-path!) are treated as non-singular values for /only refinement.

So for function like append, insert or change (with /only refinement):
- if a series is any-block and a value is any-block! **then** a function will treat each elements of a value as separate... value
- in other cases a value is treated as singular value

Is this correct?
GiuseppeChillemi
08:27When I try ti give a mental model to "select" or path selection, they position a cursor on a target where other commands could act. So while, for non series it is the element on a position, for series, it is not the element on that position but you have a series and the "cursor" is on the first elemen. So, the element you should have in mind is not the block/series in the selected position but another element contained in the selected item. This drives me to neuroconfusion !
08:43@nedzadarek I will read again your message later with a calmer mind.
endo64
09:05@GiuseppeChillemi

> I wish the output being
>
> = [y]
>


a: [y [z]]
head remove probe find/tail a 'y
; [[z]]
; == [y]
xqlab
09:18@GiuseppeChillemi
>> select s  ['tables/customers/minidata]
== [code "c000010" delay 20]

toomasv
11:35@GiuseppeChillemi One more offering:
base: [
	tables [
		customers [fields 'tables/customers/fields]
	]
	articles [
		fields [
			arcode "A000222" 
			price 22 
			sizex 20 
			sizey 40 
			sizez 33 
			weight 145
		]
	]
]

extra: [base/tables/customers/fields [code "c000010" delay 20]]

compose-blocks: func [the-block the-extras] [
    foreach [key value] the-extras [
        field: take/last key
		put get key field copy/deep value
    ]
]

compose-blocks base extra
probe base
xqlab
12:14@GiuseppeChillemi
>> a: [y [z]]
== [y [z]]
>> replace a [[z]] []
== [y]
>> a
== [y]

13:19And for your base

extra: [base/tables/customers/fields [[code "c000010" delay 20]]]
replace  base/tables/customers reduce reduce [extra/1]  extra/2

nedzadarek
15:38@xqlab @GiuseppeChillemi
He/she is not searching for [z]but for y so something like this:
a: [y [z] ]
; [y [z]]
  replace a [y [z]] 'y
; [y]
  a

but is [z] known? If no, then we could do this:
a
; [y [z]]
  parse a ['y ahead block! into [any-word!]] 
; true
  replace a ['y ahead block! into [any-word!]] 'yy
; [y [z]]

but it doesn't work.
jlhouchin_gitlab
16:58 When dealing with refinements to a function. Is there a way to short circuit the ifs and eithers to execute a default action if there are no refinements chosen?

myfunc: function [
    {my comment}
    /ref1
    /ref2
   /ref3
][
    if ref1 [print "ref1"]
    either ref2 [
        print "ref2"
    ][
        either ref3 [
            print ref3
        ][
            print "default"
        ]
    ]
]


I understand this maybe truly naive code and I possibly am not understanding how to do refinements well or even properly.

Any wisdom and understanding greatly appreciated.
greggirwin
17:03
if not any [ref1 ref2 ref3][
    ; return default
    ; or 
    ; default action
    ; exit
]
case [
    ref1 [...

or
case [
    ref1 [...]
    ref2 [...]
    ref3 [...]
    'else [...]
]
17:04Your code and use of refinements is fine though. One of the trickier things in Red is *propagating* refinements to inner function calls. When we add apply or another mechanism, it will help with that. In the meantime, we have mezz solutions to help with building dynamic calls that include refinements.
jlhouchin_gitlab
17:09@greggirwin

Thanks. That is exactly what I wanted if not any [...].
I will also log away the case style and see how it fits.
It just taking some time to wrap my brain around Red and how it does things.
However, as I do learn, it is increasingly beautiful. :)
Thanks.
greggirwin
17:09> When I try ti give a mental model to "select" or path selection, they position a cursor on a target where other commands could act.

@GiuseppeChillemi you need to adjust your mental model. :^) Find does that, and is the first part of a select operation. Select's help string should make it clear:

> Find a value in a series and return the next value, or NONE.
17:10@jlhouchin_gitlab happy to help. I won't post the refining mezzanines, as they're a bit advanced in concept.
jlhouchin_gitlab
17:11I am not ready for advanced yet. But I do have hope.
greggirwin
17:12You're doing great, and asking about idiomatic approaches is *really* good as you learn. Red is different enough that it's a big win to do that.
jlhouchin_gitlab
17:17For me I am a big believer in learning to think in the language I am using.
I don't desire to think Smalltalk or Python in Red syntax. I want to think Red when programming in Red.

I think it is okay to ask questions from the languages I understand as a point of reference. But I always desire the Red way of approaching the problem.
To me that is how to become proficient in a language. With the goals of Red being a full stack language. I don't see any other language that truly seeks that goal. I don't see any other language out there I would rather use. I know that at Red's current maturity it isn't fully there and there will be bumps. But that is okay. I am enjoying the journey. Red looks like a lifetime language.

greggirwin
17:29:+1: I've been Reboling/Reducing since 2001. Still, nothing else comes close for me.
xqlab
17:56@nedzadarek, I wanted to show that the (doubled) block is essential in order to find and replace. Compare the outcome of my **extra** and **replace** with the **compose-blocks: func** !
In the simple form it looks as in
>> a: [y [z]]
== [y [z]]
>> replace a  reduce [ a/y]  []
== [y]
>> a
== [y]
jlhouchin_gitlab
17:58I always enjoyed Smalltalk. It is very different also. But I want small, simple. There is currently too much in the Smalltalk image. And most are okay with that.

I wanted nice, clean, small apps. I want what my app requires and little more. I hadn't found the language I wanted. I was porting my code to Nim and trying out a reasonably nice system level language. I hadn't ever used a statically typed, statically compiled language before. The language I found to be reasonable. But I really dislike the lack of a repl or live programming experience. That is just so invaluable. The ability to explore within the code you write empowers so much. Red isn't quite as lively as Smalltalk. But I think it is not unreasonable far off. And I think if one was proficient one could do it better than I am. I also think in time with proper tooling that Red can approach its liveness without some of the problems that sometimes occur in Smalltalk.

I really like how I can code in my editor and in my repl do %mycode.red and it loads my code. And I can iterate and do this over and over. My changes show up. So much nicer than the way Python handles modules and module reloading. So much closer to Smalltalk.

I had never heard of Red until reading a thread in the Nim forum that someone mentioned comparing Nim and Red. And they mentioned that you really can't compare Red and Nim. Red isn't mature yet. And beside it has these fat executables approaching 1mb for hello world. Unacceptable. :)

I decided to explore, and am very happy I did so.

Currently Nim executables are incredibly fast. Red isn't close. I don't know if Red will ever approach Nim/C speeds or not. But Red does offer an incredibly productive language that is not unreasonable in performance currently and hopefully will improve greatly over time. I believe that once one begins to think in Red, ones productivity is really empowered.
18:03@greggirwin
I rewrote my function using case as you described above. It saved a couple of lines. But I think it made the code much cleaner and clearer.

The only examples I had seen using case had expressions evaluating some code. I also hadn't seen an 'else anywhere.

Thanks for sharing your knowledge and wisdom. :)
GiuseppeChillemi
18:24> @GiuseppeChillemi you need to adjust your mental model. :^) Find does that, and is the first part of a select operation. Select's help string should make it clear:

Yes I have to change the mental model.
This morning I have searched for the causes of this problem. I have taken some notes. Some of the regards not having a clear mental distinction between the item and the position of the item. Sometime you think you are working on the item but you are really working on the element n^th of the series.
18:26Also had to reread this part of [chapter 6](http://www.rebol.com/docs/core23/rebolcore-6.html) of rebol documentation on series:

"**There are many types of series in REBOL. A block, a string, a list, a URL, a path, an email, a file, a tag, a binary, a bitset, a port, a hash, an issue, and an image are all series** and can be accessed and processed in the same way with the same small set of series functions"
18:28I my mind there weren't other series than blocks and strings
greggirwin
18:43@jlhouchin_gitlab we have a few live coding demos:
- https://www.red-lang.org/2016/07/eve-style-clock-demo-in-red-livecoded.html
- https://github.com/red/code/blob/master/Showcase/livecode.red
- https://github.com/red/community might have one, but can't find it right now.
- https://gist.github.com/mikeyaunish/851a2d4822fa98f3f6a0f3437a76f2ce
- https://gist.github.com/DideC/85d60c99f97f2e4972a6f7b09a1fe630

I also have a quick port of an old R2 system browser (which did support live editing), that was inspired by Smalltalk.

- https://gist.github.com/greggirwin/91dc1c3971998e0babeedba9f7e60bc5
18:44@BeardPower is your Nim man in Red. To compare to Nim, you need to use Red/System.
18:45I use 'else as my "default" handler in case, but any truthy value will do. e.g. 'default would work the same.
dockimbel
19:11> I had never heard of Red until reading a thread in the Nim forum that someone mentioned comparing Nim and Red. And they mentioned that you really can't compare Red and Nim. Red isn't mature yet. And beside it has these fat executables approaching 1mb for hello world. Unacceptable. :)

As usual, many programmer don't even look deep enough in Red to understand what it is actually. If one want small executables for Hello World, a Red/System one is ~10KB.

> I don't know if Red will ever approach Nim/C speeds or not.

I can answer that easily: never. The reason is simple, Red and Nim/C don't live in the same abstraction layers, Red is way above them, providing very high level features and services to users, as part of the language. Because of that, it cannot be nowhere close to the speed of C. Fortunately, Red has a workaround when pure performance is needed by providing an embedded fast system programming dialect (Red/System), which currently runs about 4-8 times slower than optimized C, though Red/Pro will bring it at the same speed as C.

BeardPower
19:17@jlhouchin_gitlab I guess we red the same thread ;-) As already pointed out by others you have to compare Nim with Red/System. Nim is fast because it generates C code which is then fed to your favorite C compiler. It's similar to a transpiler. The Nim compiler has some features that are interesting like a configurable GC so you can choose between memory-safety or soft-realtime needs. Zig takes a similar approach but does not use any GC layer and is targeting C only. The Red/System compiler emits machine code directly. It's not optimized at all. You will get on par performance with Red/Pro. You are also able to generate small files with Red/System as well. Those small file-sizes are achieved by getting rid of any run-time.
pekr
19:27Is there any ETA of when we can cca expect more info on Red/Pro? Just curious, if it is going to be cloud based, pay per usage kind of licensing, or if on-premises one-off payments are going to be possible too? I guess I will have to be more patient, right? :-)
nedzadarek
20:44@jlhouchin_gitlab depending on what you want you don't have to use if not any [...] or other constructs. Your refinements' code can just *deny* an access to "no refinement part". Use exit or return:
if ref1 [
  print 'ref1
  exit
]
print 'no-refinement

either ref1 [
  set 'some-word 1
][
  set 'some-word 2
]
if ref2 [
  return some-word * 10
]
return some-word

GiuseppeChillemi
20:50@greggirwin @toomasv @jlhouchin_gitlab @xqlab @nedzadarek
Thanks everyone for you contribution and ideas.

My experiments with linked, externalized, data is continuing.
I have made a new version of select which takes into consideration and indirection link:


Red []

base: [
    tables [
            customers [fields :extra/customers-table-fields]
            ]
            articles [
                fields [
                    arcode "A000222" 
                    price 22 
                    sizex 20 
                    sizey 40 
                    sizez 33 
                    weight 145
                ]
            ]
        ]



extra: ['customers-table-fields [code "c000010" delay 20]]

select-up: func [the-series the-key] [
	either get-path? selection: select the-series the-key [reduce selection] [selection]
]


select-up returns the selected data. If it gets a get-path type, it returns the data stored externaly.


nedzadarek
20:50ps. you can use catch/throw but it's not as simple to use/debug as exit/return.
GiuseppeChillemi
20:52Run:

select-up base/tables/customers 'fields



20:52
== [code "c000010" delay 20]
>>
20:53(I remember a topic where using a path with a numeric selector reduces the picked element but I was not able to reproduce it or maybe I am wrong)


greggirwin
20:53get-path! is a nice match for that purpose @GiuseppeChillemi.
GiuseppeChillemi
20:53I like it too.
20:54Would like to use a path notation
21:05I have tried:

>> (base/tables/customers/fields)
== :extra/customers-table-fields


With no success...
jlhouchin_gitlab
21:12@greggirwin
Thanks for the links. I look forward to learning from them.
I do plan on learning Red/System. But I am yet too young in my journey.
I need to learn to make it work, make it right, then make it Red/System. :)
(the parts that are performance sensitive)

My initial comparison with Nim was my initial question about summing an array/vector. Nim was blazing fast. Even with @dockimbel 's write of sum-floats it didn't approach Nim.
About 6 minutes for Red vs. 30 seconds for Nim. I don't know if there is more performance for such on the horizon or not. However, I know that Red empowers me more. My goal isn't absolute best performance. But rather hopefully sufficient performance from the program and optimized performance from me on writing the program.

@dockimbel
Yes, I understand. I like that abstraction level of Red. I feel more empowered and productive with Red.
With Red's stated goals in its full stack language. There will be things that are enabled that aren't easy or even possible elsewhere.

Personally I don't think a ~1mb executable is bloated. I did not know that you could get it down lower. Lots to learn.

@BeardPower
Thanks. I think Nim is an interesting language. In general it lives a little lower than I want to be required to all the time. I do like with Red, that I can drop down to Red/System when I choose. It isn't only available option.

I am curious to learn more about this Red/Pro. When y'all are ready to release information. :)
I just hope it is affordable for us small guys too.
greggirwin
21:25> sufficient performance from the program and optimized performance from me on writing the program.

:+1:
nedzadarek
22:18@jlhouchin_gitlab there is a 3D game with sounds named [kkrieger](https://kkrieger.en.softonic.com/) that has 99kb. So 1Mb-hello-world is huge... but I don't care. Few mb is nothing nowadays (for "normal machines" at least; for embedding into something, this thing may be important).
dockimbel
22:18 @pekr Not yet, we haven't decided yet on the final payment model, several options are on the table. Standalone purchases should be possible, but don't expect them to be cheap.
22:21@nedzadarek HelloWorld can be ~10KB if small size is the goal. By default, Red comes with a _huge_ amount of features builtin. If those features are not needed at all, one can simply use Red/System and have binaries similar to C ones.
jlhouchin_gitlab
22:29@nedzadarek
Sure. I understand that 1 mb hello world can be large compared to certain real world apps. And sure Nim can produce a much smaller hello world. But the C can say we can do it smaller because we do manual memory management, while Nim in general does not.

But ultimately in 2019 1mb is inconsequential. Part of the decision process in my app was completely getting rid of zip files and simply working on regular non-compressed text files. Because the extra 10-100gb of space required was inconsequential to the time saved in iterating over those files 1000s of times and decompressing them every time.

Now in the era of 640k is enough. The space is important. But if you use Facebook, Spotify, Instagram, whatever ... today. Nothing Red produces will be noticed in size.

And so as you conclude your message and are absolutely on the money. You don't care. I don't care. Not many people will. :)
And hey. I think that Red is pretty lean and mean as it is. It just makes me cry to see how much cpu, space and memory a web browser consumes. :(
How much space and memory Python uses.

Why can't we have Red in the browser instead of JavaScript. :)
nedzadarek
22:35@dockimbel what if I want only some features (I don't know what features but let's assume this for simplicity)? Shouldn't *good* compiler *delete* from the executable features that I don't need?
22:52@jlhouchin_gitlab I think it was possible to run non-js code... but I cannot find the link.
I wonder how the Red would perform with the browser.
greggirwin
23:27JS is only one issue in the browser. It does a lot more, and other assets cause major memory use.

@jlhouchin_gitlab we also have the option to externalize the runtime, but still compile Red apps, so you can build a system where the runtime only exists once, and all your apps are tiny. That's also leveraged by the OS because the runtime is a DLL and shared.

@nedzadarek R2 had different prebuilt kernels, and we can do that too, but it may not buy you much. Modular compilation is planned, which will both speed compiling and reduce EXE sizes. The risk, however, is that your code may not use things, but have dynamic elements that won't work later if you omit datatypes to reduce size.
23:28The only time I used the stripped kernels in R2 was for CGI apps, that started faster. But that was long ago. We can easily optimize the wrong thing, which is why we have to choose carefully where to spend our time.

jlhouchin_gitlab
00:48@greggirwin
I would like to have small command line apps. I currently thought the best way was simply by compiling in dev mode red -c myapp.red and having the libs in the same directory. Is what you are mentioning something different? How do we do this? Thanks.
greggirwin
03:39-c is the way to go. When new releases come out, you then need to use -u to rebuild the runtime, or just delete it so it's rebuilt.
GiuseppeChillemi
04:43Is there a way for a function to have a list of all its arguments and refinements?
04:44(I mean names, not values)
pekr
05:38something like spec-of :func-name?
GiuseppeChillemi
06:40A function should know its name to use this solution.
rebolek
06:41@GiuseppeChillemi you mean from the function itself?
06:43There's probably more elegant way:
>> context [_: func [x][spec-of :self/_] set 'f :_]
== make object! [
    _: func [x][spec-of :self/_]
]
>> f 1
== [x]
GiuseppeChillemi
06:47yes, from the function itself
06:49my eyes are bleeding trying to understand you code !
rebolek
06:51@GiuseppeChillemi I define named function _ in anonymous context and then assign that function to fthat is available in global context.
06:51self in object access that object. So with this trick I can access the function specs.
06:53See? It's pretty easy.
06:54Here is version with named object and non-exported function. It works same, but instead of f, you need to call o/f:
>> o: context [f: func [x][spec-of :self/f]]
== make object! [
    f: func [x][spec-of :self/f]
]
>> o/f 1
== [x]
GiuseppeChillemi
07:14"Down in the rabbit hole I lost myself trying to figure out how to use self. Function seems to be there but the name can't be found anywhere. Trying to search for the exit, I am not ready, I'll do it tomorrow... that's my Brexit!"
toomasv
07:26@GiuseppeChillemi Some possibilities more:
b: reduce [func [x][spec-of first b]]
;== [func [x][spec-of first b]]
b/1 1
;== [x]
append b func [a b /local c][spec-of :c]
;== [func [x][spec-of first b] func [a b /local c][spec-of :c]]
b/2/local 1 2 last b
;== [a b /local c]
insert next b func [k [integer!] b [map!] /me c][spec-of :c]
;== [func [a b /local c][spec-of :c]]
b/2/me 1 #(that's: me) second b
;== [k [integer!] b [map!] /me c]
07:37Also
>> b: reduce [func [x][do something with x] func [a b /local k l m][whatever]]
== [func [x][do something with x] func [a b /local k l m][whatever]]
>> forall b [probe spec-of first b]
[x]
[a b /local k l m]
== [a b /local k l m]
GiuseppeChillemi
07:55@toomasv
...Trying to learn REBOL and RED I felt so brave but now it's too much I will end in a grave !...
08:06(thanks, I am currently at work. Study material has piled...)
BeardPower
08:23@nedzadarek The Kernel I am working on does not use any run-time and is stripped from all the functionality Red offers. The same was done for the tiny Nim executables (getting rid of the C runtime, removing everything which is not needed besides printing out "Hello, world!", using system calls, rudimentary ELF files etc.). The R/S binary, which is also just printing, "Hello, world!" is about 1KB, the startup-code about 3KB. The final Kernel binary (startup code, "hello world", ELF format etc.) is about 9KB.
08:24You could bring it down even more by using addional optimisations.
08:25A raw binary using system calls to print "Hello, world!" just needs close to 150 bytes.
08:30@nedzadarek kkrieger's logic does not take much of space but it needs tons of memory as every texture and asset is generated procedural.
08:3195-98% of a game is assets.
nedzadarek
09:03@greggirwin I see, I agree and I understand.
09:06@GiuseppeChillemi
:point_up: [June 18, 2019 8:40 AM](https://gitter.im/red/help?at=5d088756fbcc305cc4933663)

No, check this:
spec-of function [a /ref1 b /ref3] []
; == [a /ref1 b /ref3]
09:15@BeardPower
Nice.
150 - is it only for -nix systems? I have found one with ~250 for windows (up to 7, not tested on 8+).
As for kkrieger: I just wanted to show that 99kB is enough for a game so ~10kB for *Hello world* is not very impressive.
dockimbel
09:29@nedzadarek kkrieger is highly optimized handcrafted assembly code, it is not the output of a compiler. You are still comparing apples with oranges.
nedzadarek
10:11@dockimbel there is [werkkzeug1](https://web.archive.org/web/20120204065859/http://www.theprodukkt.com/werkkzeug1) which I can create my own scene. Is it still "comparing apples with oranges"?
Oldes
10:11@nedzadarek I'm living in a world, where common SDK has around 1GB, so 10kB is not that bad.
nedzadarek
10:15@Oldes Yes, as I said before, few MB for executables are not bad. 10kB for *Hello world* is not impressive but it is not that every user needs very small applications (let's say < 1 kB).
Oldes
10:16I was trying to get the smallest _Hello world_ using GCC on windows and was not able to make it smaller than 2048 bytes (and it was using assembly)
nedzadarek
10:19^^ nice
Oldes
10:23Still believe that it does not matter if program has 2kB or 500kB, if it works. At least if you are not in a demo scene.
rebolek
10:24*Hello world* may be a "working" program, but I would doubt its usefulness.
nedzadarek
10:30@rebolek *Hello world* is meant to show if and how a programming languages works. However, I do not think it is far from something useful, for example, add input and you can calculate [the cumulative probability of multiple events](https://www.quora.com/How-do-I-calculate-the-cumulative-probability-of-multiple-independent-events-For-instance-if-the-probability-of-getting-X-is-35-per-event-how-can-I-know-the-cumulative-probability-of-getting-X-in-two-trials-in-three-trials-etc)
10:31I wonder if there is comparison of "more useful" programs.
BeardPower
10:35@nedzadarek Yes. The system calls for Windows would be different but if used it would give you the same results.
https://hookrace.net/blog/nim-binary-size/

You need to compare a 150 byte "Hello, world!" to the 99kB of kkrieger because it uses similar tricks. It's not your "usual" executable.
dockimbel
10:36@nedzadarek
> @dockimbel what if I want only some features (I don't know what features but let's assume this for simplicity)? Shouldn't *good* compiler *delete* from the executable features that I don't need?

Your question presupposes several properties (from system programming languages) that are not true in Red and many other high-level languages:

a) C's runtime library is extremely small (a few hundred bytes to a few KB). C language features can be mapped to hardware units (CPU/FPU) more or less directly, because it was designed with that goal in mind. Red/System has similar properties. OTOH, Red has high-level semantics that do not map to existing CPUs, therefore a runtime library code is required for the language to run.

b) For a supposedly "good" compiler to be able to understand which features are needed and which are not, the language itself needs to be fully statically analyzable. That is true for C, Nim, Red/System and many other languages, but simply not true for Redbol language family. It is trivial to write code in Redbol that no compiler can understand (e.g. do "load %script.red"), therefore the compiler cannot know which core languages features are really needed and which are not.

c) The vast majority of features used by programmers in C-like languages are not in the language but in libraries. In Redbol world, most of the daily used features are part of the language itself. That is a deliberate design choice aiming at making the language easier to use, and dare I say, also smaller (less methods/functions to remember). No need to remember thousands of function names, or in which library lies a given function. Deep integration of libraries into the language types and semantics (e.g.: the date! type with all the built-in date calculation without the need of library of extra functions). The consequence is a pretty much insecable core runtime. Even when modules will be there, only a small portion of current runtime code could be split from the rest. But, given b), removing *any* feature from the runtime would put you at risk of not been able to run the user code.

d) One feature that Red is not yet implementing compared to Rebol is embedding the console into each and every executable. Why? Because we want users to be able to drop into the console after running some code if they want to. That feature alone would make removing anything from the core runtime code a no-go.

As you can see, we are very far from C/Nim, it's a different realm.
10:37Moreover, Hello World in R/S is way smaller than in Nim according to the following graph: https://nim-lang.org/assets/img/features/binary_size.png
nedzadarek
10:42@BeardPower I see
@Oldes Yes, if my exe has few MB then it's fine.
dockimbel
10:44We also have a lot of room to decrease the current typical Red app binary size:
* The current code emitter for R/S is far from producing the fastest and smallest code. If you UPX a typical 1MB compiled Red app, the size will go down to ~300KB. I expect Red/Pro to bring us closer to that.
* Compiled Red functions are having a much bigger binary footprint that packed functions in text format (then loaded at runtime, as Rebol does). So we could move some of the most heavier Red mezz code into compress strings, and unpack that at runtime. Just a different set of trade-offs as usual.
10:46BTW, I wonder what D, Haskel and Go are putting into their runtime code to be *that* big...
pekr
10:47Well, nice and educative stuff, guys ... but, but, but - could we get 0.6.5 out of the door, please? :-) -- just joking around, to be clear here ;-)
nedzadarek
10:47@dockimbel It is very informative, thank you.
Oldes
10:47@nedzadarek btw... to publish an application in MS Store, you need from 1 to 5MB of just icons (banners) used for various resolutions. The same is with iOS and Android. It is real true what said @BeardPower . Assets takes over 90% (for games).
nedzadarek
10:50@Oldes for games, lots of developers goes with higher resolution/quality etc.
pekr
10:50btw - in some recent commits, there is a struct by value stuff - was it just added to the ARM backend, or new to R/S in general?
Oldes
10:50@nedzadarek because it is a must these days with 4K displays more and more common.
BeardPower
10:51@nedzadarek As @dockimbel already pointed out, it's convenience vs. size/performance. You can get rid of the runtime, optional ELF/PE headers, system-calls (you could just use CPU opcodes for printing "Hello, world!" and produce a raw binary).
You can do that with R/S as well.

http://timelessname.com/elfbin/

I suggest to move to chit-chat ;-)
dockimbel
10:52@pekr Just adding proper support for that to armhf targets.
nedzadarek
10:54@Oldes responded in chit-chat, as asked by @BeardPower
dockimbel
10:54@BeardPower I believe it should be possible to write a HelloWorld using [COM format](https://en.wikipedia.org/wiki/COM_file) for DOS in less than 20 bytes. ;-) Ah, someone [did it](https://wyding.blogspot.com/2009/04/helloworld-for-16bit-dos-assembly.html) of course. Just assemble that in a .com file, and you're done.
BeardPower
10:58@dockimbel Back to the roots ;-)
dockimbel
11:00@BeardPower
> You can get rid of the runtime, optional ELF/PE headers, system-calls (you could just use CPU opcodes for printing
"Hello, world!" and produce a raw binary).
> You can do that with R/S as well.
> http://timelessname.com/elfbin/

We did it a long time ago already (162 bytes): https://www.red-lang.org/2011/03/having-fun-with-redsystem.html
> I suggest to move to chit-chat ;-)

I'm not part of chit-chat by convention (it's supposed to be a non-moderated room). ;-)

GiuseppeChillemi
11:03<God Mode On>
>> I'm not part of chit-chat by convention (it's supposed to be a non-moderated room). ;-)

<God Mode Off>

:-)
BeardPower
11:07@dockimbel What is this witchery ;-) We should mentioned that somewhere: Nim: 150bytes with voodoo&magic; Red: 162bytes out of the box
11:07@dockimbel It was just a suggestion to not "spam" the /help channel with /pose content ;-)

jlhouchin_gitlab
00:59I am struggling with some code attempting to make an http request.

write/info candles-url [
    GET
    [
        Authorization: "Bearer  mytoken"
        Content-Type: "application/json"
    ]
]

;-- I get this error
*** Script Error: GET does not allow block! for its word argument
*** Where: GET
*** Stack:

Any help greatly appreciated.
9214
01:14@jlhouchin_gitlab what's the output of ? candles-url? It looks as if you aliased it with evaluating function, e.g. do or reduce.
jlhouchin_gitlab
01:19@9214
>> print candles-url
https://api-fxtrade.oanda.com/v3/instruments/EUR_USD/candles?price=M&from=2019-06-09T22:00:00Z&to=2019-06-13T09:20:00Z&granularity=M1
>>
>> type? candles-url
== url!

9214
01:22Cannot reproduce. What about write/info probe candles-url [...]?
greggirwin
01:23I get this:
[401 #(
    Content-Length: "65"
    Content-Type: "application/json"
    Access-Control-Allow-Headers: {Authorization, Content-Type, Accept-Datetime-Format, OANDA-Agent, ETag}
    Access-Control-Allow-Methods: "PUT, PATCH, POST, GET, OPTIONS, DELETE"
    Access-Control-Allow-Origin: "*"
    Access-Control-Expose-Headers: "ETag, RequestID"
) {{"errorMessage":"Insufficient authorization to perform request."}}]
01:24Ah, because your post has fake token. :^\
jlhouchin_gitlab
01:24It is produced as such.

candles-url: rejoin [account/url "instruments/" instrument/name "/candles?price=M" query-args]


You can't reproduce it unless you have an account and a real account token. I substituted for the real token.
greggirwin
01:24Do they have a test account?
01:26Are you sure you're not reducing the block first?
9214
01:26@jlhouchin_gitlab does it run ok if you use 'get rather than get?
greggirwin
01:26e.g.
>> reduce [
[        GET
[        [
[            Authorization: "Bearer  mytoken"
[            Content-Type: "application/json"
[        ]
[    ]
*** Script Error: GET does not allow block! for its word argument
*** Where: GET
*** Stack:
01:26Same thinking as @9214.
9214
01:29Another thing to do is to use url! value literally, i.e.
write/info http://api-fxtrade-yada-yada [...]

Or, write/info :candles-url [...], in that case write will choke on its first argument if it's a function.
jlhouchin_gitlab
01:50I believe they have demo accounts.
03:18In a brand new terminal window with fresh red instance.
Repeated several times.

The first example I think demonstrates that the problem is not the candles-url. At least in my naive understanding.

Thanks for any help figuring this out.

>> account: copy broker-oanda-trade/account
== make object! [
   ...
>> instrument: instruments/all/eur-usd
== make object! [
    base: "eur"
    quote: "usd"
    name: "EUR_USD"
    fullname: "EUR/USD...
>> query-args: "&from=2019-06-09T22:00:00Z&to=2019-06-13T09:20:00Z&granularity=M1"
== {&from=2019-06-09T22:00:00Z&to=2019-06-13T09:20:00Z&granularity=M1}
>> candles-url: rejoin [account/url "instruments/" instrument/name "/candles?price=M" query-args]
== https://api-fxtrade.oanda.com/v3/instruments/EUR_USD/candles?price=M&from=2019-06-09T22:00
>> 
>> write/info candles-url "Not A GET Block!"
== [405 #(
    Access-Control-Allow-Headers: {Authorization, Content-Type, Accept-Datetime-Fo...

>> write/info candles-url [
[                GET
[                [
[                    Authorization: "Bearer 8534d1f6644e4b83eeef98a1b5a316a7-0ad4b58c0054ce19858b74373f97a369"
[                    Content-Type: "application/json"
[                ]
[            ]

*** Runtime Error 1: access violation
*** at: 0805E397h

9214
03:41@jlhouchin_gitlab can you type about in console and paste output here?
rebolek
04:45Access violation means that you are passing header data as something other than string!. It's a know bug that would be fixed with IO rewrite. But looking at your code I can't see what can be wrong with it.
04:47Reproduced:
04:47
>> write/info candles-url [GET [Authorization: "Bearer 8534d1f6644e4b83eeef98a1b5a316a7-0ad4b58c0054ce19858b74373f97a369" Content-Type: "application/json"]]

*** Runtime Error 1: access violation
*** at: 0805E382h
greggirwin
04:48Thanks for following up team! Let's get this in a ticket.
04:48I'm sure you're going to do some more R&D on it as well @rebolek since you *just* reproduced it.
rebolek
04:48There is ticket for it, but I wonder what's going on here, this should work IMO.
greggirwin
04:49Ah, so it's the same thing, not a new one. Hmmmm.
04:49@jlhouchin_gitlab what does the output look like, when used successfully from CURL, etc.?
rebolek
04:51@greggirwin Actually, it *may* be something new. I'll try some older Red.
04:59So the request is send successfully, it crashes on received data.
05:10I'm not sure what's going there, if I change the token, I can get 401 error instead of crash, but if try this same url and token with curl, I get the same 401 error too.
05:30
>> write/info candles-url [GET [Authorization: "Bearer 8534d1f6644e4b83eeef98a1b5a316a7-0ad4b58c0054ce19858b74373f97a369" Content-Type: "application/json"]]

*** Runtime Error 1: access violation
*** at: 0805C934h


When I change just one character there (last 9 to 8) I get 401 instead:

>> write/info candles-url [GET [Authorization: "Bearer 8534d1f6644e4b83eeef98a1b5a316a7-0ad4b58c0054ce19858b74373f97a368" Content-Type: "application/json"]]
== [401 #(
    Access-Control-Allow-Headers: {Authorization, Content-Type, Accept-D...


With curl, both requests return 401. This is some black magic voodoo stuff.
Oldes
06:59Works here (on Windows with somehow older Red version):
>> candles-url: https://api-fxtrade.oanda.com/v3/instruments/EUR_USD/candles?price=M&from=2019-06-09T22:00
== https://api-fxtrade.oanda.com/v3/instruments/EUR_USD/candles?price=M&from=2019-06-09T22:00
>> write/info candles-url [GET [Authorization: "Bearer 8534d1f6644e4b83eeef98a1b5a316a7-0ad4b58c0054ce19858b74373f97a369" Content-Type: "application/json"]]
== [200 #(
    Content-Length: "66568"
    Content-Type: "application/json"
    Vary: "Accept-Encoding"
    Access-Control-Allow-Headers: {Au...
07:05@rebolek try it with the debug build so you can see where the crash is.
toomasv
07:27Works for me too (W10, built 21 May).
rebolek
07:29
>> write/info candles-url [GET [Authorization: "Bearer 8534d1f6644e4b83eeef98a1b5a316a7-0ad4b58c0054ce19858b74373f97a369" Content-Type: "application/json"]]
root size: 2885, root max: 4600, cycles: 0, before: 2991664
*** Runtime Error 1: access violation
*** in file: /home/sony/Code/red/runtime/allocator.reds
*** at line: 455
***
***   stack: red/update-series F63D6F5Ch 355752 1360
***   stack: red/compact-series-frame F6362004h 09D823C8h
***   stack: red/cross-compact-frame F6362004h 09D82280h
***   stack: red/collect-frames 1
***   stack: red/collector/do-mark-sweep
***   stack: red/collector/do-cycle
***   stack: red/alloc-series-buffer 1048576 1 0
***   stack: red/expand-series F64AC274h 1048576
***   stack: red/alloc-tail-unit F64AC274h 14855
***   stack: red/binary/rs-append 09DA36D4h 09DC5480h 14855
***   stack: red/simple-io/get-http-response 09DC5480h 1 14855 09DA36D4h
9214
08:41@rebolek now try it with GC turned off.
rebolek
08:58@9214 so it's GC. Should have think about it first.
dockimbel
09:23@qtxie ^--- another GC bug to look into.
qtxie
09:32@dockimbel Good. Maybe this one will give me some light. It's hard to find the causes in other 2 GC issues.
09:42Add a ticket for it. #3920
rebolek
09:43:clap:
GiuseppeChillemi
11:12In rejoin, is there a defined destination dataype or is it regulated from some kind of logic ?
rebolek
11:14let's try it!
>> rejoin [<a> #b #c]
== <abc>
>> rejoin ["a" #b #c]
== "abc"
>> rejoin [a@b #b #c]
== a@bbc
GiuseppeChillemi
11:19Is there way to enforce the second one ?
rebolek
11:29The resulting datatype is based on first value. So for example you would need to insert empty value of same type as second value. Something like this:
>> second-rejoin: func [value][rejoin head insert value to type? second value copy ""]
== func [value][rejoin head insert value to type? second value copy ""]
>> second-rejoin [<a> "b"]
== "<a>b"
11:30Or do the conversion afterwards:
>> second-rejoin: func [value][to type? second value rejoin value]
== func [value][to type? second value rejoin value]
>> second-rejoin [<a> "b"]
== "ab"
jlhouchin_gitlab
11:43My apologies. I let a real toke live into the wild. It has been revoked.

jimmie@squirrel:~/Dev/Red/redtrader$ red
--== Red 0.6.4 ==-- 
Type HELP for starting information. 

>> about
Red 0.6.4 for Linux built 17-Jun-2019/9:18:51-05:00 commit #7a2900d

rebolek
11:47@jlhouchin_gitlab I think we couldn't reproduce it without real token.
dockimbel
11:55@jlhouchin_gitlab @rebolek Could we at least capture the output from that HTTP request so we could simulate it using a local web server?
jlhouchin_gitlab
11:57@rebolek
I can help. I have switched my code to a practice account. It is still linked to my live account. But it has no information of my live account and contains no IDs.
A token alone will allow access to a portion of the API which is not account oriented. ie: you can get prices and such. But not balances.
I will revoke the token periodically as desired or necessary.

This is an actual token and request with the current practice account token.

>> write/info https://api-fxpractice.oanda.com/v3/instruments/EUR_USD/candles?price=M&from=2019-06-09T22:00:00Z&to=2019-06-13T09:20:00Z&granularity=M1 [
    GET [Authorization: "Bearer 757302104546640350fcd0874ce4a0d7-184a182bde8c67df7845aaa4db1cef66" Content-Type: "application/json"]]
>>
*** Runtime Error 1: access violation
*** at: 0805E397h

 ;-- If I break the token making it invalid I get this.

== [401 #( "application/json"]]
    Access-Control-Allow-Headers: {Authorization, Content-Type, Accept-Datetime-Fo...


rebolek
11:59@jlhouchin_gitlab I can confirm crash with this token (757...f66). If you can keep it alive for @qtxie during debug, it would be of great help.
jlhouchin_gitlab
12:02Success looks like this.
All of my tests have been in completely new terminal windows with new instances of Red.

>> write/info candlesurl broker/req-get
== [200 #(
    Access-Control-Allow-Headers: {Authorization, Content-Type, Accept-Datetime-Fo...
>> print write/info candlesurl bbroker/req-get
200 Access-Control-Allow-Headers: {Authorization, Content-Type, Accept-Datetime-Format, OANDA-Agent, ETag}
Access-Control-Allow-Methods: "PUT, PATCH, POST, GET, OPTIONS, DELETE"
Access-Control-Allow-Origin: "*"
Access-Control-Expose-Headers: "ETag, RequestID"
Content-Length: "632666"
Content-Type: "application/json"
RequestID: "60590061107220539"
Vary: "Accept-Encoding" {"instrument":"EUR_USD","granularity":"M1","candles":[{"complete":true,"volume":65,"time":"2019-06-09T22:00:00.000000000Z","mid":{"o":"1.13284","h":"1.13311","l":"1.13280","c":"1.13290"}},{"complete":true,"volume":17,"time":"2019-06-09T22:01:00.000000000Z","mid":{"o":"1.13289","h":"1.13290","l":"1.13281","c":"1.13286"}},{"complete":true,"volume":4,"time":"2019-06-09T22:02:00.000000000Z","mid":{"o":"1.13285","h":"1.13290","l":"1.13285","c":"1.13290"}},{"complete":true,"volume":16,"time":"2019-06-09T22:03:00.000000000Z","mid":{"o":"1.13292","h":"1.13298","l":"1.13290","c":"1.13298"}},{"complete":true,"volume":18,"time":"2019-06-09T22:04:00.000000000Z","mid":{"o":"1.13296","h":"1.13296","l":"1.13284","c":"1.13285"}},
12:03@rebolek
Not a problem. I can let it run for a while. I just don't want to leave it indefinitely. All day today, this week is not a problem.
rebolek
12:07Great, let's hope @qtxie can come up with fix soon :smile:
jlhouchin_gitlab
12:08Just a note. The success above was from a previous session. I still had the terminal open. I haven't been able to reproduce it. :(
This is what the req-get is in the success.
broker/req-get: function [][
        compose/deep [
            GET
            [
                Authorization: "Bearer 757302104546640350fcd0874ce4a0d7-184a182bde8c67df7845aaa4db1cef66"
                Content-Type: "application/json"
            ]
        ]
    ]
rebolek
12:09I'm able to get successful reply after recycle/off:
>> write/info https://api-fxpractice.oanda.com/v3/instruments/EUR_USD/candles?price=M&from=2019-06-09T22:00:00Z&to=2019-06-13T09:20:00Z&granularity=M1 [
[        GET [Authorization: "Bearer 757302104546640350fcd0874ce4a0d7-184a182bde8c67df7845aaa4db1cef66" Content-Type: "application/json"]]
== [200 #(
    Access-Control-Allow-Headers: {Authorization, Content-Type, Accept-D...
jlhouchin_gitlab
12:28I can confirm that. I will try with my other code later. I don't know what recycle does. But it sounds GC.
rebolek
12:29Right, it's GC stuff, recycle/off turns GC off, recycle/on turns it on.
qtxie
12:50 @jlhouchin_gitlab @rebolek Thanks. I'm investigating it.
16:27I found a simple way to reproduce the bug.
GiuseppeChillemi
19:55@rebolek It would be good to add a refinement to rejoin like /target and specify the target datatype.
20:08I have made a slight modification to my learning experiment nad I am having an unexpected result:

base: [
    tables [
            customers [fields 'tables/customers/fields]
            ]
            articles [
                fields [
                    arcode "A000222" 
                    price 22 
                    sizex 20 
                    sizey 40 
                    sizez 33 
                    weight 145
                ]
            ]
        ]



extra: ['tables/customers/fields [code "c000010" delay 20]]

compose-blocks: func [the-block-name the-extras] [
		the-block: get the-block-name
    foreach [key value] the-extras [
		the-block-name: to-path the-block-name
        the-path: rejoin [the-block-name key]
        probe the-path
        do reduce [the-path copy/deep value]
    ]
]

compose-blocks 'base extra


I am passing a word to the block. My ultimate goal was to make the path relative without a base word and rejoin it later.

The debug output is not what I expected:

base/'tables/customers/fields


I supposed to create

base/tables/customers/fields

nedzadarek
20:13> @rebolek It would be good to add a refinement to rejoin like /target and specify the target datatype.

@GiuseppeChillemi is this really necessary?
First, you can use first argument. Secondly, there are as and to functions.
toomasv
20:31@GiuseppeChillemi extra: [tables...
greggirwin
20:32@GiuseppeChillemi as @nedzadarek said, there is no need for /target.

One of the hardest things about language design is taking the time to extrapolate and weigh the options, so you don't solve what seems to be an immediate inconvenience but create issues that are no better, or even worse.

A good metric is, anytime you think "We should add X", look at the various ways it could be done *without* adding anything. And if the idea is strong. In this case--and I'd like you to really do this @GiuseppeChillemi-- mock up some examples of what your idea looks like, in actual calls using /target. I'm doing that just in my mind, and already see some issues. If we walk through it here, it will be a good design exercise.
20:34We don't want to discourage new ideas, but we also want to make sure people are putting effort into their suggestions, and that we all do this as a community, because vetting ideas and thinking through them is a *lot* of work.
20:41An interesting idea might be to have associated design docs, which could be tagged for specific funcs, etc. We have plans for extended docs, beyond what we can generate programmatically, with info like red-by-example has, including open contributions and examples. Design notes could detail not only the thinking behind elements, but also things we decided *against*, so we don't keep rehashing things. And those entries could point to idiomatic solutions, in a virtuous circle.
nedzadarek
20:42Is there something like CSS for vid?
greggirwin
20:43Yes layout/styles and @rebolek's stylize yet to be merged.
nedzadarek
20:48@greggirwin is layout/styles somewhere documented beside [doc redlang](https://doc.red-lang.org/) because it's not available at the moment.
greggirwin
20:51I didn't know doc.red-lang was down. Hmmmm. @x8x any ideas on that?
GiuseppeChillemi
20:56@rebolek
a difference: If the first datatype is word, everything is converted to string....

an incoherence:
But words have different rules when converted to string than lit-paths.

A lit-path maintain its ' while a word does not. It it seems not coherent to me. (Or maybe I am doing something wrong)

>> x: quote 'a
== 'a
>> type? x
== lit-word!
>> y: ['b/c/d]
== ['b/c/d]
>> probe rejoin [x y]
"a'b/c/d"
== "a'b/c/d"
21:02@toomasv , I have removed ' but it does not work.

base: [
    tables [
            customers [fields 'tables/customers/fields]
            ]
            articles [
                fields [
                    arcode "A000222" 
                    price 22 
                    sizex 20 
                    sizey 40 
                    sizez 33 
                    weight 145
                ]
            ]
        ]



extra: [tables/customers/fields [code "c000010" delay 20]]

compose-blocks: func [the-block-name the-extras] [
			foreach [key value] the-extras [
				the-block-name: to-path the-block-name
				the-path: to-set-path rejoin [the-block-name key]
				probe the-path
				do reduce [the-path copy/deep value]
    ]
]

compose-blocks 'base extra

The script modified from @greggirwin give me an error. (I remember having faced this problem in the past)

base/tables/customers/fields:
*** Script Error: cannot set none in path base/tables/customers/fields:
*** Where: do
*** Stack: do-file


The path is there but it does not work.
21:04(Note, I have fixed script indent and added a missing line just now)
nedzadarek
21:06@GiuseppeChillemi but y is not lit- type, but a block!. A block! inside a block! will stay the same:
y: to-lit-path [a b c]
; 'a/b/c
  bl-y: append/only copy [] y
; ['a/b/c]
  rejoin [y bl-y]
; 'a/b/c/['a/b/c]
GiuseppeChillemi
21:06@greggirwin @nedzadarek its good to use to and as in place of target. It makes everything simple. (I remember having read that somewhere)
nedzadarek
21:07first word is reduced (tag!):
t: <tag:> rejoin [t 'foo]
; <tag:foo>
GiuseppeChillemi
21:07try this: probe rejoin [x first y]
nedzadarek
21:08^^ what's wrong with this?
GiuseppeChillemi
21:09@nedzadarek , this... what ?
nedzadarek
21:09what's wrong with :point_up: [June 19, 2019 11:07 PM](https://gitter.im/red/help?at=5d0aa41c8e050f62aa593862)?
GiuseppeChillemi
21:11
>> x: quote 'a
== 'a
>> y: ['b/c/d]
== ['b/c/d]
>> probe rejoin [x first y]
"a'b/c/d"
== "a'b/c/d"


first y is lit-type and no more a block.
nedzadarek
21:14Yes, because it's reduced... is there a problem with this?
greggirwin
21:17> its good to use to and as in place of target. It makes everything simple.

@GiuseppeChillemi please still do the experiment I suggested.
GiuseppeChillemi
21:17both seems reduced but the lit-word is reduced to word and the destination string has the tick stripped , lit-path is reduced to lit-path and the destination strings maintains its tick.

>> z: first y
== 'b/c/d
>> probe rejoin [x z]
"a'b/c/d"
== "a'b/c/d"
>>

21:18Tick is maintained in one conversion to string, and removed in another conversion. If you try to extrapolate tick removing in rejoin you end up without a common rule.
21:19(And you expect this)
21:21Maybe it is voluntary but beware: it normal to expect common rules in such situations.
21:22Someone else could expect tick is removed instead of tick being maintained. But we both expect to behave in the same way, either removing or maintaining it.
nedzadarek
21:29@GiuseppeChillemi
It seems it only affect -word types.
21:30And the culprit is (I think) form in the rejoin source. mold is better in this case.
dockimbel
21:35
remold: func [value][mold reduce :value]
greggirwin
21:36This is something we should document, and we can revisit the design rationale, but it is also a Rebol compatibility issue. Mold is not the right answer here. @nedzadarek do a quick mockup using mold, and post the results. I think you'll see quickly that they aren't very useful.
dockimbel
21:37@greggirwin IIRC, there's a ticket about that already.
greggirwin
21:38The goal of rejoin is to create useful results, based on the first value as a primary hint. Paths are a bit complicated here, and there is no perfect solution.
21:38I don't see any rejoin tickets @dockimbel.
dockimbel
21:39About the forming of lit/get/set-words.
greggirwin
21:39Got it: https://github.com/red/red/issues/3409
dockimbel
21:42So we should keep the decoration when FORMing any-words!, or undecorate FORMed any-path! for sake of consistency.
greggirwin
21:50Form should omit decorations, and mold should include them. Form is already lossy for many types.
nedzadarek
21:53@greggirwin I'll do that tomorrow.
GiuseppeChillemi
21:58Glad to have been useful. Good night everyone.

x8x
00:01Docs are back 😃
greggirwin
01:38Great! Do we know what the issue was?
01:38And if you did something to fix it, thanks!
toomasv
03:12@GiuseppeChillemi

> I have removed ' but it does not work.

Of course it doesn't work, as you have removed part of your previous compose-blocks func too. :wink:
rebolek
05:16@GiuseppeChillemi rejoin is specifically for any-string! types, not for path!
toomasv
06:11@rebolek Why not? It works well with any series. But non-series first elements are formed and string results.
>> x: to-path 'a
== a
>> y: 'b/c
== b/c
>> rejoin [x y]
== a/b/c
>> rejoin [x 'b 'c]
== a/b/c
>> rejoin [to-lit-path 'a 'b 'c]
== 'a/b/c
rebolek
06:13@toomasv You're right. Too soon for me, not enough coffein yet :tea: :coffee: :sleeping:
toomasv
06:13:smile:
06:33@GiuseppeChillemi
:man: : My program A' B' C' doesn't work!
:person_with_blond_hair: : Change A' to A.
:man: :fast_forward: :capital_abcd: :leftwards_arrow_with_hook: :collision:
:man: : Doesn't work! :disappointed:
:person_with_blond_hair: :weary:
GiuseppeChillemi
07:24> Of course it doesn't work, as you have removed part of your previous compose-blocks func too. :wink:

It's not my original script but the one from Greg with a simple modification: it acceps a word instead of a block and use it as base for the path. It should be complete and functional but if you see a missing part please point it as I can't se which one.

toomasv
07:34@GiuseppeChillemi The [code you posted](https://gitter.im/red/help?at=5d0a962be527d95add117242) works if you just delete the single ' as [indicated](https://gitter.im/red/help?at=5d0a9b91faf70031f9521ee9).
nedzadarek
08:55I haven't found anything about layout/styles in the docs - does anyone has some examples?
toomasv
10:02@nedzadarek
view layout/styles [mystyle "An example of style usage: CSS"][
    mystyle: [template [
        type: 'base 
        color: brick 
        size: 700x200 
        font: make font! [size: 36 name: "Edwardian Script ITC" style: 'bold]
    ]]
]
10:03[![image.png](https://files.gitter.im/red/help/dJ3m/thumb/image.png)](https://files.gitter.im/red/help/dJ3m/image.png)
12:25In addition: actors are given as block!, not as object!, and init may be added besides template:
view layout/styles [mystyle][
    mystyle: [
        template: [type: <obligatory> ... actors: [<add some actors>]] 
        init: [<initialisation code>]
    ]
]
nedzadarek
12:29@toomasv how do I set offset and things like below or across?
rebolek
12:30In a style?
nedzadarek
12:32@rebolek Yes.
12:33As for offset: I have tried both in template and init (init: [face/offset: 200x150] without face/ too) but it doesn't work).
rebolek
12:34@nedzadarek can you show how would you do it in normal layout, without /style ?
nedzadarek
12:34
view [base red at 150x40 base blue]
view [below base base]

@rebolek
rebolek
12:35@nedzadarek but you're not defining new style here
nedzadarek
12:44@rebolek Well... I'm not very good with styles. I've tried view [style b: base with [color: red offset: 200x20] bb: b] bb/color bb/offset but it doesn't seems to set offset.
rebolek
12:46@nedzadarek that's because things like offset or drawing direction (below/across) aren't part of style, but part of layout.
nedzadarek
12:46@rebolek so *positioning* of elements is not possible with styles?
rebolek
12:47think about it, if you create button, that has always same offset, all buttons would be placed over themselves and you'll end up with one button actually.
toomasv
12:47You can set all facets of a face. But orientation is not a facet. However in certain situations you can set orientation:
view layout/styles [b b b][b: [template [type: 'base size: 20x20 color: red] init [axis: 'y]]]
nedzadarek
12:48@rebolek if it was *relative offset* but I don't know if it's possible in the Red.
rebolek
toomasv
12:50Yes:
view layout/styles [b b b][b: [
    template [type: 'base size: 20x20 color: red] 
    init [spacing: 30x30 axis: 'y]]
]
rebolek
12:51This yes is still no.
nedzadarek
12:55That's bad, thank you @rebolek :point_up: [June 20, 2019 2:49 PM](https://gitter.im/red/help?at=5d0b80cad4535e477a6958b0)
@toomasv axis & spacing seems nice, maybe with panels I could reduce *positioning elements* from my code. Thank you.
toomasv
12:58@nedzadarek You are welcome. You can also set at-offset ininit.
Example of relative positioning:
do %diagram-style.red
view dia [size 300x200 at 50x50 base connect hline 50 base]
12:58[![image.png](https://files.gitter.im/red/help/Fes7/thumb/image.png)](https://files.gitter.im/red/help/Fes7/image.png)
13:01
view dia [size 300x200 at 50x50 base connect hline 50 to top-left base]
13:02[![image.png](https://files.gitter.im/red/help/oubV/thumb/image.png)](https://files.gitter.im/red/help/oubV/image.png)
13:05
view dia [size 300x250 at 50x50 base connect hline 50 from bottom-right to top-left base]
13:05[![image.png](https://files.gitter.im/red/help/rgtl/thumb/image.png)](https://files.gitter.im/red/help/rgtl/image.png)
nedzadarek
13:06@toomasv I guess I can manage positioning with at-offset and with some code:
last-offset: 2x0
view layout/styles [b1: b b2: b b3: b][b: [
    template [type: 'base size: 20x20 color: red] 
    init [at-offset: last-offset: last-offset + 0x30 axis: 'y]]
]
toomasv
13:15@nedzadarek :+1:
But why not use something simpler (if your styles will not be complex)?
Similar result with:
view [origin 2x30 below style b: base 20x20 red b1: b b2: b b3: b]
nedzadarek
13:23@toomasv this can change but I think I will have:
- 3 columns
- each column maybe higher/lower
- 2nd row will have 2 or more elements.

So I want to separate a positioning and a code.
toomasv
13:27OK, if you have very complex layout. Although you can build quite interesting things with usual VID too, e.g.:
view layout [
    origin 2x30 below 
    style b: base 20x20 red 
    b b b return b b b b return pad 0x20 across b b b
]
nedzadarek
13:49@toomasv I might over engineer it a little but I very like simplicity of CSS + HTML comobo.
rebolek
13:54Simplicity of CSS?
nedzadarek
13:56@rebolek yes... although I haven't build bigger website so I don't know how CSS behaves at larger scale.
toomasv
13:59And, there are also divided panels:
view [
    backdrop beige 
    style b: box red 20x20 
    panel linen 3 [
        b b b 
        b b panel [origin 0x0 b b] 
        b b b 
        box 20x20 b
    ]
]
rebolek
14:00@nedzadarek we probably have different definitions of simplicity, because things like float and flex are very confusing to me.
14:03or centering something in CSS
nedzadarek
14:16@rebolek I have just read w3school articles for [float](https://www.w3schools.com/Css/css_float.asp) and [flex](https://www.w3schools.com/css/css3_flexbox.asp). I think it is very simple.
In general I find it simple that you can take any element (by a type, an id or a class), apply some styles (text size/color, margin etc) and put everything into separate file.
14:21@toomasv I do not remember that I could *divide* panels. Thank you.
toomasv
14:23@nedzadarek You are welcome!
Still playing:
board: [origin 0x0 space 0x0] 
view append/only [
    backdrop beige 
    style b: box brown 20x20 
    style w: b linen 
    panel 8
] repeat i 32 [
    append board either i - 1 % 8 + 1 > 4  [[b w]][[w b]]
]

[![image.png](https://files.gitter.im/red/help/F7b1/thumb/image.png)](https://files.gitter.im/red/help/F7b1/image.png)
nedzadarek
14:26If it is going in that direction then we will be able to play chess soon.
dockimbel
14:39An alternative approach:
#macro chessboard: does [
	collect [repeat row 8 [loop 4 [keep pick [[w b][b w]] odd? row] keep 'return]]
]

do/expand [
	view [
		backdrop beige 
		style b: box brown 20x20 
		style w: b linen 
		panel 8 [origin 0x0 space 0x0 chessboard]
	]
]
BeardPower
14:40What is this witchery? :thumbsup:
toomasv
14:42@dockimbel Nice! But why doesn't return cause error?(https://github.com/red/red/blob/master/modules/view/VID.red#L632)
BeardPower
14:46Do I need the latest version of Red?
*** Script Error: VID - invalid syntax at: [chessboard]
*** Where: do
*** Stack: view layout layout cause-error
nedzadarek
14:47@BeardPower
That's good question I got similar::
do/expand [
    #macro chessboard: does [
        collect [repeat row 8 [loop 4 [keep pick [[w b][b w]] odd? row] keep 'return]]
    ]
        view [
            backdrop beige 
            style b: box brown 20x20 
            style w: b linen 
            panel 8 [origin 0x0 space 0x0 chessboard]
        ]
]
*** Preprocessor Error: Syntax error
BeardPower
14:50It does not worl with the latest version from git.
dockimbel
14:53@toomasv Good point, I didn't notice the divide mode, it should have errored out indeed.
14:53For the Syntax Error, I have no clue, I'm using a GUI console built yesterday with latest commits...
BeardPower
14:56@dockimbel Are the 8 childs needed (panel 8)?
dockimbel
14:56Recompiled a new console, I get the error too now. My previous console was compiled in debug mode.
14:57@BeardPower Not in my version, but it would be better to keep it, and remove the 'return injection.
BeardPower
14:58But why only 8 and not 64?
dockimbel
14:588 columns. It's a panel divider option, to switch to a "grid-like" mode.
14:59
lisp
>> do/expand [chessboard]
== [w b w b w b w b return b w b w b w b w return w b w b w b w b return b w b w b...
>> do/expand [[chessboard]]
== [chessboard]
BeardPower
14:59Alright but by loop 4? 8 columns but only 4 rows?
14:59Never mind. Because of 2 squares ;-)
dockimbel
BeardPower
15:03No if we only could make it work :-)
15:18@dockimbel Is it a bug or by design that the content inside the [] is not recognized by the draw DSL/VID?
toomasv
15:44Can't play without figures:
15:44[![image.png](https://files.gitter.im/red/help/Jb23/thumb/image.png)](https://files.gitter.im/red/help/Jb23/image.png)
jlhouchin_gitlab
16:18@qtxie
Let me know when you no longer need my token to debug the problem. I will revoke it so that it is no longer usable.
Thanks for helping with the problem.
BeardPower
16:19@toomasv Number of players: ZERO ;-)
toomasv
16:19 :cry:
BeardPower
16:20@toomasv Don't you know the movie "WarGames"?
toomasv
16:20Nope
BeardPower
16:21https://www.imdb.com/title/tt0086567/
16:21The boy enters "ZERO" so the computer will play against itself -> machine learning ;-)
16:21Ooops, SPOILER ALERT!
qtxie
16:41@jlhouchin_gitlab Thanks. No need now.
jlhouchin_gitlab
17:28@qtxie
Great. Thanks.
dockimbel
17:35@BeardPower Which []are you referring to?
17:38I have messed up my tests with the macros above, with latest console, I get the expected behavior:
>> do/expand [
[        #macro chessboard: func [] [
[            collect [repeat row 8 [loop 4 [keep pick [[w b][b w]] odd? row] keep 'return]]
[        ]
[            view [
[                backdrop beige 
[                style b: box brown 20x20 
[                style w: b linen 
[                panel 8 [origin 0x0 space 0x0 chessboard]
[            ]
[    ]
*** Script Error: VID - invalid syntax at: [return b w]
*** Where: do
*** Stack: view layout layout cause-error  

>> 
>> do/expand [chessboard]
*** Script Error: w has no value
*** Where: do
*** Stack:  

>> do/expand [[chessboard]]
== [w b w b w b w b return b w b w b w b w return w b w b w b w b return b w b w b...
17:41So the correct code is:
do/expand [
    #macro chessboard: func [] [
        collect [repeat row 8 [loop 4 [keep pick [[w b][b w]] odd? row]]]
    ]
    view [
        backdrop beige 
        style b: box brown 20x20 
        style w: b linen 
        panel 8 [origin 0x0 space 0x0 chessboard]
    ]
]
toomasv
17:43Works OK here! :+1:
dockimbel
17:44I thought does macro constructor was implemented, but not yet, so I'm adding it right now.
BeardPower
17:45@dockimbel The [] inside panel
panel 8 [origin 0x0 space 0x0 chessboard]

>> do/expand [chessboard]
== [w b w b w b w b return b w b w b w b w return w b w b w b w b return b w b w b...
>> do/expand [[chessboard]]
== [chessboard]
17:45It does not evaluate correctly because of the w b sequence being inside [].
dockimbel
17:46@BeardPower It works fine in my last test above. I'm not sure what I messed up with the macros in my console before.
BeardPower
17:50@dockimbel Works here as well.
Well, the difference was
does vs. func
, return vs no return and putting it in the do/expand block vs. outside of it.
17:55It does not work if the does/func is outside of the do/expand block.
17:56So why is it not working when the does/func is outside the do/expand block?
dockimbel
17:57IIRC, the console does not expand macros by default.
BeardPower
17:58Even if you remove #macro it does not work.
17:58So it's not even expanding a func?
dockimbel
17:58@BeardPower That's not a feature of VID. You can already achieve something similar using compose/deep on the VID block.
BeardPower
17:59Alright. That's what I wanted to ask about (my question about the [] inside the VID (panel [... [chessboard]])
18:00Should it be a feature?
dockimbel
18:00
lisp
chessboard: does [
	collect [repeat row 8 [loop 4 [keep pick [[w b][b w]] odd? row]]]
]
view compose/deep [
	backdrop beige 
	style b: box brown 20x20 
	style w: b linen 
	panel 8 [origin 0x0 space 0x0 (chessboard)]
]
18:01Probably good enough in this case to not resort to macros. As I said when we released macros in Red, there are not many cases where macros are a win, as the regular Red language is already flexible enough to do meta-programming easily.
BeardPower
18:01Yeah, that's how I do it in my charting code.
18:03:thumbsup:
GiuseppeChillemi
21:56> > Of course it doesn't work, as you have removed part of your previous compose-blocks func too. :wink:

Ok Toomas, I have understood your point but my question now has changed: what is this "path must start with a word" when I run this code ?

base: [
    tables [
            customers [fields 'tables/customers/fields]
            ]
            articles [
                fields [
                    arcode "A000222" 
                    price 22 
                    sizex 20 
                    sizey 40 
                    sizez 33 
                    weight 145
                ]
            ]
        ]



extra: [tables/customers/fields [code "c000010" delay 20]]

compose-blocks: func [the-block the-extras] [
			foreach [key-path value] the-extras [
				the-path: to-set-path probe rejoin ['the-block "/" key-path]
				probe the-path
				do probe reduce [the-path copy/deep value]
    ]
]

compose-blocks base extra
probe base



21:57
"the-block/tables/customers/fields"
the-block/tables/customers/fields:
[the-block/tables/customers/fields: [code "c000010" delay 20]]
*** Script Error: path must start with a word: the-block/tables/customers/fields:
*** Where: do
*** Stack: do-file
22:30

>> probe type? probe first the-path
base
word!
== word!
>> probe type? probe second the-path
tables/customers/fields
path!
== path!


Above we have a path composed of 2 elements: a word and a path.

Here, the analyzed path has 3 elements, all are words.

>> a: [b [c 1]]
== [b [c 1]]
>> probe type? probe first to-set-path 'a/b/c
a
word!
== word!
>> probe type? probe second to-set-path 'a/b/c
b
word!
== word!
>> probe type? probe third to-set-path 'a/b/c
c
word!
== word!


So RED has paths made from nested words/paths...>
nedzadarek
23:11@GiuseppeChillemi in general -path types are containers that can have different elements in it (even other -path) but in order to evaluate it it should start with a word. Depending on a word it will do [different things](https://doc.red-lang.org/en/datatypes/path.html#_evaluation_steps). In your code you make a mistake by calling to-set-path with elements not separated by space (in case of string, not sure what other characters could count as delimiters... yes new line too). It took whole string and put it into first element of the path.
>> first to-path "a b"
== a
>> first to-path "a/b"
== a/b

9214
01:06> I thought does macro constructor was implemented, but not yet, so I'm adding it right now.

@dockimbel IIRC there are related ticket to this (does and has support in macros) that can be closed.
GiuseppeChillemi
05:32If you refer to this line:

the-path: to-set-path rejoin ['the-block key-path]


I have tried to change it to:

the-path: to-set-path reduce ['the-block key-path]


But I get:

*** Script Error: cannot set none in path the-block/tables/customers/fields:
*** Where: do
*** Stack: do-file


05:50I am not finding a way to join a word and path
rebolek
05:52
>> head insert 'b/c 'a
== a/b/c
GiuseppeChillemi
06:50@rebolek I will stick it in front of my table "never use reduce or rejoin on blocks with something and paths to build a path"
rebolek
06:52it's simple, path is is series, treat it as one
GiuseppeChillemi
06:54Yes, but I have tought I could manipulate it easily with rejoinings.
rebolek
06:56you can
06:56
>> rejoin ['a/b 'c]
== a/b/c
toomasv
06:59@GiuseppeChillemi :point_up: [June 21, 2019 12:56 AM](https://gitter.im/red/help?at=5d0c0127bc834f76a4afcd05)
Simplified your function:
compose-blocks: function ['block extras] [
	foreach [key value] extras [
		path: head insert copy key block
		set path copy/deep value
	]
]
GiuseppeChillemi
06:59For some reason it doesn't work here:

the-path: to-set-path rejoin ['the-block key-path]
07:03@toomasv

What are you doing here ?

function ['block extras] [


How is this 'block interpreted ?
toomasv
07:05Compare these two. They are functioning similarily:
compose-blocks: function ['block extras] [
	foreach [key value] extras [
		probe path: head insert copy key block
		set path copy/deep value
	]
]

compose-blocks base extra

compose-blocks: function [block extras] [
	foreach [key value] extras [
		probe path: head insert copy key block
		set path copy/deep value
	]
]

compose-blocks 'base extra
GiuseppeChillemi
07:06@rebolek
>
> >> rejoin ['a/b 'c]
> == a/b/c
> 
>


Maybe I am wrong but I feel there is a binding problem in my way of using rejoin to create a path inside a function... maybe... I do not know if elements of paths have contexts.
07:27@toomasv , your answer needs a deep investigation. In the first one it seems you are passing the BASE block SET the word BLOCK to it. In the second one it seems you are passing the word BASE and assign to BLOCK word but it surely isn't working this way. You are passing BASE content to a SET instruction and BLOCK word is set to it...
toomasv
07:37@GiuseppeChillemi See "Functions with one or more arguments" section (2.1) in short [explanation](https://github.com/red/red/wiki/%5BDOC%5D-Function-Evaluation).
nedzadarek
08:40@GiuseppeChillemi :point_up: [June 21, 2019 8:50 AM](https://gitter.im/red/help?at=5d0c7e535bc3210bb76c7e37) it's not a problem with reduce/rejoin but with -paths types *ability* to hold any type (as fair I remember) so you can have a path holding another (or even the same) path.
p: 'a/b
; a/b
  p/a
; b
  p/a: p 
; a/...
  p/a
; a/...
  p/a/a/a
; a/...
13:04You can create, for example, linked list: https://gist.github.com/nedzadarek/d922de8c049e88de37a570c730732711
GiuseppeChillemi
14:47@toomasv my eyes are opening
14:47@nedzadarek later this evening I will work on it.
nedzadarek
15:00@greggirwin as for :point_up: [June 19, 2019 11:36 PM](https://gitter.im/red/help?at=5d0aaacdfbcc305cc4ada9dd) mold seems fine here: https://gist.github.com/nedzadarek/126da5fa8cb92a9ce4b9e2665c17817b ... but adding to some type (maybe types) like url! is not very good in my opinion (it should add / before any addition and maybe / between every element in a block) but other people may think it's good.
15:03@GiuseppeChillemi :+1:
GiuseppeChillemi
18:44Everything started becouse I have not found a way to do this without reducing. My wish was to use a path to get the element read from another path stored in a block.

>> y: [a b c [z/m] d]
== [a b c [z/m] d]
>> z: [j k l m 99 o]
== [j k l m 99 o]
>> probe y/c/1  ;<<----not doing what I want
z/m
== z/m
>> probe reduce y/c/1;<--doing what I want but with reduction
99
== 99
18:45So, is there a way to build a path which does this ?
18:46Also, could a nested path reach the same result ?
19:51Note: y: [a b c z/m d] is another option. You select y/c and get value stored in z/m
dockimbel
20:01Not sure what you really want to achieve, but this is could be one way to have a direct reference to z from m block:
>> z: [j k l m 99 o]
== [j k l m 99 o]
>> y: compose/only [a b c (next find z 'm) d]
== [a b c [99 o] d]
>> 
>> probe y/c/1
99
== 99
>> y/c/1: 33
== 33
>> probe y/c/1
33
== 33
>> ?? z
z: [j k l m 33 o]
GiuseppeChillemi
21:13@dockimbel yes: something like this but without reducing/composing:

Actually you have used compose

z: [j k l m 99 o]
y: compose/only [a b c (head z) d]

>> y/c/j: 22
== 22
>> probe z
[j 22 l m 99 o]
== [j 22 l m 99 o]
>> probe y
[a b c [j 22 l m 99 o] d]
== [a b c [j 22 l m 99 o] d]


I was thinking about using a path like notation to create a relation to a position of a "pointed" series.

z: [j k l m 99 o]


Imagined solutions

y: [a b c >z d] ;head of  Z
or
y: [a b c >z/m d] ;m in Z
or 
y: [a b c >(z/m) d];m in Z


Or anything which could be used for this purpose.
dockimbel
21:16@GiuseppeChillemi
> I was thinking about using a path like notation to create a relation to a position of a "pointed" series.

You don't need to use an intermediary path for that, you can use a direct reference to the series directly. And you can achieve it without compose:
z: [j k l m 99 o]
y: [a b c _ d]
y/4: next find z 'm

probe y/c/1
y/c/1: 33
probe y/c/1
?? z
GiuseppeChillemi
21:17How ?
21:23My imagination has gone on multiple path "jumps" too:

y: [a b c >z/m d]
z: [j k l m >a/b o]
a: [b 22 gg 44]

Probe y/c
>>22


21:25(oops I have seen your example just now, reading it !)
21:38@dockimbel
Well, I have read your solution:
I like it and and answers my needs but one requirement: this way the block does not have the direct reference encoded into it, the reference is created via code so it can't be saved/loaded. It would be good to create this reference inside the block via some kind of notation lite the one proposed above. This way you can have mutiple blocks relating together and you can also save and load them later.

toomasv
05:28@GiuseppeChillemi Why redesign the language, not use it?
>> y: [a b c [z/m] d]
== [a b c [z/m] d]
>> z: [j k l m 99 o]
== [j k l m 99 o]
>> get y/c/1
== 99
>> set y/c/1 33
== 33
>> get y/c/1
== 33

>> y: [a b c z/m d]
== [a b c z/m d]
>> z: [j k l m 99 o]
== [j k l m 99 o]
>> get y/c
== 99
>> set y/c 33
== 33
>> z
== [j k l m 33 o]
05:41And your last problem:
y: [a b c z/m d]
z: [j k l m a/b o]
a: [b 22 gg 44]
mget: func [p][either path? p [mget get p][p]]
mget y/c
;== 22
GiuseppeChillemi
10:07"Why you want to redesing a langage ?". I don't want it, I have an idea floating in my mind since the last year: using the result of a function stored in a block as series to be used for prosecution for the remaining part of a path.

Let's start

The idea needs this notation:

y/c[]


Mean: reduce the data picked from C and use the reduced data as base for the remaining part of the path.

Having

y: [i b c  xx d] 
XX: [h j k]


Then:

y/c[] -> [h j k]


If picked data is a function:

y: [i b c  func[][read %filename] j k l]


Then:

y/c[]


Would return the file read



If the function has parameters:


y: [i b c  func[a][read a] j k l]


You will provide them using this notation so:

y/c[%filename.txt]


Would return the content of the filename you pass

If %filename.txt content is:

[data "my string" value 22]


Continuing the path

y/c[%filename.txt]/data


Would return

"my string"

This idea of executing a function getting parameters from the path intersecates with the idea that you can have a relative path where

y: [i b c  xx d] 
XX: [h j k]


And

y/c[]  -> [h j k]


Also this led to the concept of RELATIVE PATH: a path with no heading word:

y: [i b c  j/delta d] 
XX: [h j [delta 22] k]


And you use them this way:

y/j[xx]  -> 22
Or, as alternative
y/[xx]J


If you have:

y: [i b c  j/delta d] 
XX: [h j [delta [gamma 33] k]


Then:

y/j[xx]/gamma

33



Last but not least, the proposed path to have JUMP/LINK element so the path does not need to be forged in the new way:

Lets use > to mean "its an element to be reduced".

y: [i b c >xx/j/delta d] 
XX: [h j [delta [gamma 33] k]


So can express as usual but you have full links implemented:

>> probe y/c/gamma
=33


toomasv
11:54[![image.png](https://files.gitter.im/red/help/meNq/thumb/image.png)](https://files.gitter.im/red/help/meNq/image.png)
:flushed:
GiuseppeChillemi
12:07😁😁😁
13:15@toomasv more time I think about x/y[arguments or word]/z/...more I like it. You execute the function stored in the block providing arguments and continue from result, or provide another serie and continue from there . I see an easy way to access a dynamic datasets in a serialized form. Please take again a look at it and and tell me what you think. You can send Killer birds again if you want !




toomasv
14:37@GiuseppeChillemi I cooked a func working along the lines you wished, with syntax similar to yours but slightly diffferent. Advantage is that it works without redesigning the language :wink: (except the jump/link)
do %mget.red
y: [i b c  xx d] xx: [h j k]

mget y/c/()
;== [h j k]

write %tmp [data "my string" value 22]
change find/tail y 'c func [][read %tmp] y
;== [i b c func [][read %tmp] d]

mget y/c/()
;== {[data "my string" value 22]}

change find/tail y 'c func [f][load f] y
;== [i b c func [f][load f] d]

mget y/c/(%tmp)
;== [data "my string" value 22]

mget y/c/(%tmp)/data
;== "my string"

y: [i b c j/delta d] xx: [h j [delta 22] k]
mget y/c/(xx)
;== 22

y: [i b c j/delta d] xx: [h j [delta [gamma 33]] k]
mget y/c/(xx)/gamma
;== 33


Here is mget. Works for above examples, otherwise not tested:
mget: function ['p][
	switch/default type?/word p [
		path! [
			either found: find p paren! [
				p: get copy/part p found
				either any-function? :p [
					either empty? f: first found [p][
						f: to-block f
						blk: do compose [(:p) (f)]
						either 1 < length? found [
							remove found
							p: select blk found 
							mget :p
						][blk]
					]
				][
					par: take found
					if not empty? par [
						case [
							all [word? r: first par path? p][p: back insert copy p r]
							all [word? r: first par word? p][p: to-path reduce [r p]]
							all [path? r: first][p: append r p]
						]
					]
					if 0 < length? found [
						case [
							path? p [p: append copy p found]
							word? p [p: back insert copy found p]
						]
					]
					mget :p
				]
			][get :p]
		]
		word! [
			get :p
		]
	][:p]
]

GiuseppeChillemi
14:59@toomasv the book of RED lessons from you has another page full of teachings.
15:01Thanks for the time spent answering my questions, and a special thanks again for your Drawing Dialect.
toomasv
15:17@GiuseppeChillemi You are welcome!
18:16[gist](https://gist.github.com/toomasv/bdc164798f48ed2287c67eddabf7e04f)

laturk
02:13Where does the license.key file have to be located for rebcmd to work with all features enabled?
02:37Can red send email?
toomasv
05:08@GiuseppeChillemi Now [mget](https://gist.github.com/toomasv/bdc164798f48ed2287c67eddabf7e04f) works with your dreamed syntax (without jump/link):
do %mget.red
y: [i b c xx d] xx: [h j k]
y/c[]
;== [h j k]

write %tmp [data "my string" value 22]
y/c: func [][read %tmp]
y/c[]
;== {[data "my string" value 22]}

y/c: func [f][load f]
y/c[%tmp]
;== [data "my string" value 22]

y/c[%tmp]/data
;== "my string"

y/c: func [d f][load append d f]
y/c[%./ %tmp]/value
;== 22

y: [i b c j/delta d] xx: [h j [delta 22] k]
y/c[xx]
;== 22

y: [i b c j/delta d] xx: [h j [delta [gamma 33]] k]
y/c[xx]/gamma
;== 33
GiuseppeChillemi
05:28I have just opened my eyes and I am stuck in from of my phone. Five minutes have passed and my mouth is still open. G R E A T!
05:28Thanks
05:32I'll try it in few minutes just after I recover from sleep induced coma state.
toomasv
06:09:smile:
GiuseppeChillemi
07:25@toomasv It's working at path level, no need for mget !!!!!!!!
07:27Black magic is here:

system/lexer/pre-load: func [src][
	chr: complement charset {/[ "#}
	path: [some chr #"/" some chr]
	mpath: [some path change #"[" "/(" to #"]" change skip #")" any [#"/" mpath]]
	
	parse src [any [s: mpath e: (insert s "mget " e: skip e 5) :e | skip]]
]
07:29Is somewhere documented this low level working of RED ?
07:30Just a question: is there any drawback caused by the modification of standard path syntax ?
toomasv
07:36It hides the usage of mget, inserting this at load-time where appropriate. You can't use this path-syntax inside blocks, otherwise mget will be inserted into blocks too, distorting these. In other words, only normal paths in blocks.
9214
07:38@laturk
> Where does the license.key file have to be located for rebcmd to work with all features enabled?

In the same directory as encap program, according to [SDK intro](http://www.rebol.com/docs/sdk/sdkintro.html).

Just FYI, you don't need Rebol SDK to use Red, it's only required to encap toolchain in a single binary. No to mention that RT stopped selling keys since a long while.

> Can red send email?

Not yet, but should be possible after ports and SMTP scheme are implemented (0.7.0).
GiuseppeChillemi
08:04@toomasv you mean: do not use this special path as element it in a block contained in another block?
toomasv
GiuseppeChillemi
09:08> No to mention that RT stopped selling keys since a long while.

When piracy becomes legit.
09:46Reading the lexer has been trycked to modify path syntax I have a question: is it possible in RED to know how the following code will be/have been loaded ?

Let me explain:

print ["hello word!] 
(word) (block)

print ["hello word!] 
(function) (argument)


b: func [arg] [print arg]
(set word) (word) (block) (block)

b "Hello word"
(function) (series (argument))

10:32Well, thanks to your help I am starting to convert tables from multiple indents strucuture to a single indent/flat one.
They far more readable to my eyes.

Before:



10:32[![image.png](https://files.gitter.im/red/help/kHA7/thumb/image.png)](https://files.gitter.im/red/help/kHA7/image.png)
10:33After:
10:34[![image.png](https://files.gitter.im/red/help/3lot/thumb/image.png)](https://files.gitter.im/red/help/3lot/image.png)
10:35[![image.png](https://files.gitter.im/red/help/usNZ/thumb/image.png)](https://files.gitter.im/red/help/usNZ/image.png)
10:36The last one is the base structure where all tables will be composed.
10:36Thanks again everyone !
10:38Note: The bigger part of editing take place on second image data. Having all the tables on a single ident level makes it just a breeze !
toomasv
12:22@GiuseppeChillemi I would suggest testing it on some sample data before restructuring all your files :wink:. Probably some issues will pop up.
12:27> Let me explain:
> print ["hello word!]
> (word) (block)...

I understood nuthin'.
GiuseppeChillemi
12:38@toomasv yes, this will be the first to search for any issue. Actually, I will work this way on code built from now on. No conversion of code from the past.
12:39>> I understood nuthin
12:43I am trying to creare a command which is able to describe how a code block will be loaded. I mean the type of each element. I suppose load and the lexer could have all the needed mechanism.
laturk
13:42@9214 Thank you. I have the problem of rebcmd not accepting my license.key file. Works fine with enface.
13:46Would someone please tell me how to get send so send email. I need all the details for SSL/TLS security.
9214
14:47@laturk IIRC R2's send is broken and outdated.
GiuseppeChillemi
17:08@toomasv I think I have found the solution. I'll work on it back at home.
toomasv
19:49:+1:

Oldes
09:04@laturk as you probably already noticed, most current SMTP servers requires TLS/SSL connection. The easies way is probably using Curl to send a mail: https://stackoverflow.com/a/16069786/494472
09:06There is also Graham's [SMTP protocol for Rebol3](https://github.com/gchiu/Rebol3/blob/master/protocols/prot-smtp.r) but I never tried it, so don't know how and if it is working. It is most probably not working now, as it also does not support TLS/SSL.
09:06You may also find this: https://kinsta.com/knowledgebase/free-smtp-server/ helpful.
GiuseppeChillemi
20:53@Oldes good to know. Thanks !

ralfwenske
02:18On the roadmap it says that GUI support for OSX backend is done 98%.
On my machines (2) when I run view I get this message (also right-click or menus don’t work):
NSSoftLinking - The ShareKit framework's library couldn't be loaded from /System/Library/PrivateFrameworks/ShareKit.framework/Versions/A/ShareKit.
Is this part of the missing 2% or do I have to somehow to install something that is missing on may macs?
This message exclusively shows when running red/view.
dockimbel
10:56@ralfwenske Which macOS version are you using?
pimgeek
23:22is there more than one popular dialect to define a gui window? i noticed that both view [ size 300x200 ] and view make face! [ type: 'window size: 300x200] will work 🤓
justjenny
23:41Hi, been trying to add a few links here: https://github.com/red/red/wiki/%5BLINKS%5D-GUI-Programming 'Red ide projects from the community' - but they are removed every time ? - not sure why - Vladimir Vasilyev edits the page - the links I try to add are without question quality examples, so why are they being removed ? - would like to know why. thanks Jenny.
endo64
23:41@pimgeek In the first one you are using VID dialect, in second one there is no dialect you are creating and displaying the face object directly. See the view function's source code (?? view) if the spec argument is a block it simply calls the layout function which creates a face object from VID dialect.
23:45Hi @justjenny , Vladimir and a few others (including me) are trying the keep the wiki pages clean & organized (as a contractor), we recently realized that there are more than one link to http://www.mycode4fun.co.uk web site, preferably it should appear only once.
23:51It appears in below pages:
[LINKS]-Learning-resources.org
[LINKS]-Unofficial-Tutorials-and-Resources.md
[ARCHIVE]-Original-Home.md
[DOC]-Sandbox.md
Examples.md

justjenny
23:53I see what you mean, but surely everyone should see what can be done with 'drag and drop' he has developed a full drag and drop solution - the best red example there is, without exception - so why not show it ?
23:56apologies - I know him and rate him highly

justjenny
00:20So why is it a problem if there are more than one link ?
pimgeek
01:07@endo64 Thank you so much for explaining~ very clear and informative. 😊
ralfwenske
01:50@dockimbel On MacMini: Mojave 10.14.5 and on MacBook Sierra 10.12.6
01:51@dockimbel A rather complex app works fine on both but only on Mojave puts this out:
/BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.200.3/Common/ChunkCompression.cpp:49: Error: unsupported compressor 8 /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.200.3/Libraries/CompressData/CompressData.c:353: Error: Unknown compression scheme encountered for file '/System/Library/LinguisticData/Latn/Dict2.dat'
greggirwin
04:40@justjenny we'll try to do better about telling people why we change things, but you're not active here or @9214 might have done that directly in chat. An issue, from my perspective, is that there's no way to link directly to specific examples on @virtualAlan's site. You worked around it with your "scroll down..." comment in the link, which helps. If we can link directly to it somehow, because it fits that context, we can add it back in.
05:13To that end, if there's anyone in the community that would like to head up wiki maintenance and moderation, that would be great. @gltewalt, @9214, and @endo64, along with others, do what they can, but we keep them busy with other work too.
05:13You don't have to be an expert, and we're always just a message away if you need support.
viayuve
05:48"camera" face (webcam tried and it works) any way to connect to network camera and record stream?
9214
05:58@justjenny wiki is a curated (and moderated) knowledge-base, not a newsletter or ad board. We already feature most of the existing community projects (including @virtualAlan's work) on multiple wiki pages, including the ones (3 of them IIRC) that you updated with duplicate entries. Moreso, you added the aforementioned drag-n-drop GUI mockup app to the "Community IDE projects" category, which is misleading at best (and previously the same attempt was made by @Sunnypt).

We already discussed this in our internal chat, and agreed that featuring top-level link to Alan's website on multiple wiki pages is more than enough to promote his Red-related work.

> the best red example there is, without exception

That's a bold claim. I know of at least 4 other "drag-n-drop GUI" projects - @mikeyaunish's [direct code manipulation tool](https://github.com/mikeyaunish/direct-code), @endo64's [mockup designer](https://github.com/endo64/mockup), @planetsizecpu's [forms](https://github.com/planetsizecpu/forms) and perhaps @toomasv's [layout editor](https://github.com/toomasv/layout-editor). None of them were mentioned by you (and _that_ would be wholeheartedly encouraged - creation of a dedicated wiki page that features all existing GUI-building tools) - instead you used your editing rights to promote your friend's work exclusively (even though Red team was _already_ generous and helpful enough to feature his work); that's a noble goal, I appreciate the intent, but such downplay of other community members and pitching of another one won't be tolerated by me, as an (informal) moderator of Github wiki.

That said, wiki is designed for information gathering, to facilitate decision-making and to help everyone navigate the plethora of resources that gets accrued over time. To serve its purposes, it should remain as _objective_ as possible. You appended new entries to wiki - that's OK, but you did so with _subjective_ goal in mind (as you said yourself) - that's IMO not quite OK; not to mention that double entries make navigation harder and ambiguous.

I believe there are far more suitable media channels that Alan (and you) can use to promote his hobby projects, but Github wiki is not one of them, and was never intended for such purposes.
greggirwin
06:10@9214 let's take this to team chat for review and analysis.
viayuve
06:18@greggirwin hello sir I was using ffmpeg to get frames and record video from ip cam in one of my small app after that I was combining all clips in single video with ffmpeg to make this process fast I have tried python multiprocess and subprocess management. It kind of worked with lots of load on system. So I thought about reduction and red to help so I asked that something similar to multiprocessing question here. Also if i can record ip cam with just using red or something in conjunctions would be nice.
9214
06:33@justjenny I tend to be heavy-handed, and apologize in advance if what I said came down too hard on you, that wasn't my intent.

Understand that everyone wants to be acknowledged, and it's our goal to give all community members their share of fame and glory, avoiding favoritism if possible.

So, please try to stay as objective as possible, and help us to keep this community a welcoming place for everyone to stay.
06:39@viayuve you need to either implement stream processing in Red/System by yourself, or wait for 0.7.0 with full I/O... or ask Bo (@Respectech), who IIRC worked with web camera feeds in the past. Red doesn't have concurrency support yet, it's scheduled for 0.9.0 release.
viayuve
06:53"PORTS" I am already waiting for 7 need it for lot of database stuff.
qtxie
08:32@ralfwenske The debug information output by macOS vary among different versions of the OS. We doesn't use any functions in AppleFSCompression, needs to investigate more about it.

I'm not sure if the APPs built by XCode has that too. By default, no output to the terminal at all. (Is there a way to enable it?)
justjenny
14:50@9214 it was just a simple question, nothing more. Gregg answered it for me. There was no need for any more. Thank you for your apology.
greenmughal
19:42Hi guys, im still on pursuit to writing a simplified red interpreter in python, I have some questions.
1. How much red is interpreted and how much of it is compilable?
2. Is the red VM a Register, Stack or Tree based?
3. Is it possible to convert Red code into Python/AST so it can be taken care of by standard python implementations? Or you think Red must also need a RUNTIME interpreter?
I believe writing an interpreter for Red shouldnt be more difficult than Scheme/LISP, the problem is I had trouble understanding the semantics of Red lang, so I played with its REPL to understand how fundamentals work.
How can I convert following code to python AST/source?
>> "a string" getage NAME 35
So it should eval every possible item, but returns only 35 as per rule. the function getage gets evaluated possibly with sideeffects. Is it true that it will
19:44produce following code.
>> eval("a string")
>> eval(getage (NAME))
>> return eval(35)
19:47Lets say I wan to seemlessly call python functions from Red, and if dont the how many params they might expect in advance! how im sure how many arguments to pass in block/series Red lang does not inforce parentheses for calls
19:49Does red lang has closures?
How does red lang scoping rules compare to python ?
AlexanderBaggett
20:21What is the difference between #include and do with regards to multi-file projects? If I use do on a file that has an #include , will the files it references get included as well?
dander
20:33@AlexanderBaggett when you compile, #include implies that the file is embedded into the executable, but if you use do it reads and interprets the file at runtime. When you are interpreting, I believe #include is interpreted the same as do.
greggirwin
20:39@AlexanderBaggett as @dander said, do is a runtime construct and has no effect on compilation. You also have do/expand. The best way to understand things in Red is to play. Create a small project, structured in a way that will answer your question, and document the behavior. We can add that to the wiki as well.
AlexanderBaggett
20:46@greggirwin , @dander , Thank you both very much for the explanation.
20:48I have a tricky bug I am trying to figure out. When I run a file as a script on its own, it works fine. But when I try to include it I get an error. I may just set that on the backburner for later.
greggirwin
20:48@greenmughal

'1. It's not "how much" but "what kind of code". The more dynamic your code, the harder it is to compile. If you write Red with no dynamic aspects (binding, loading, path manipulation, etc.), it can be compiled.

'2. Stack

Closures: We have various mezzanine level (user func) experiments, which means you can write your own, but expect there will be a closure! type in the future.

Scoping: There is no comparison, as there is no scoping in Red. It *looks* like it, but that's just a trick to keep your mind from exploding when you start out. ;^)

'3. Answered out of order, because now is when I say you really need to spend time with Red, to understand it, before going too far. You can surely "fly blind" and write an interpreter without doing that, but I think you'll make your life a lot more difficult in the long run. Also, since you're writing an interpreter, why not look at the Red source code itself, to see how it works?

Regarding function arity, in Red we can do that reflectively. Here's one example: [arity-of](https://gist.github.com/greggirwin/53ce7d1228422076e142fa5a061e7649)
AlexanderBaggett
21:13I am not sure if this is a bug or by design but do when used from VID does not write to system/console/history. An example: view [t: area button "interpret" [ do t/text probe first system/console/history]] . I would expect this print hello on 2 lines in the console. Instead it just continues to print hello and then view [t: area button "interpret" [ do t/text probe first system/console/history]]
21:24In any event, I don't see a way of capturing console input or output as of yet. I have seen rebol implementations of this with system/ports/echo but I don't see anyway to do this in red as of yet.
greggirwin
21:25Ports will come with full I/O in 0.7.0. Do doesn't have any knowledge of the console. How could it, as the console may not exist in all cases where do is used.
21:27But if you think outside the box a bit...
>> head insert system/console/history "Haha!"
== ["Haha!" {head insert system/console/history "Haha!"} "system/console/history" ...
AlexanderBaggett
21:27ahahah
21:28Thank you for that. That cheered me up.
greggirwin
21:29To get around output capture is a bit more work, but think about how you could do it by wrapping print/probe in your own funcs and capturing the output of do yourself.

9214
05:19@greenmughal you're putting the cart in front of the horse. Implementing any language requires thorough understanding of it, so you should start by learning, and, eventually, mastering Red. It's not gonna be a "oh it's just a Lisp / Python but with different syntax" one-off weekend project.

I've tried to summarize key implementation points [here](https://github.com/red/red/wiki/%5BNOTES%5D-How-Red-Works---A-brief-explanation), see if it helps. And [here](https://github.com/red/red/wiki/%5BHOWTO%5D-Build-an-interpreter-for-Red-lang) is a short course of action which I recommended you to take some time ago, in case you've forgotten. All 3 questions of yours can be answered by examining Red's codebase and playing in REPL.

viayuve
07:31how to make window and all face inside transparent
endo64
11:14Currently transparency is not supported, you can use Win32 APIs to achieve that (if you're on Windows)
justjenny
22:02Hi, yes, I thought Red once did have this transparency feature - Was there a reason for its removal ?
dockimbel
22:03@justjenny You can make faces transparent, but there is no direct support in Red for transparent windows.
justjenny
22:08just thought some time ago, early days transparent windows were supported in Red - might have been mistaken
dockimbel
22:12@qtxie might remember better than me if someone did a demo for that once, using Win32 API?
justjenny
22:23thanks Nenad
greggirwin
22:28I believe that was the case. You couldn't just set the color to transparent.
justjenny
22:33but it was possible to get a transparent window ?
greggirwin
22:35Using Windows APIs, yes...we think so. That's how we used to do it with R2.
justjenny
22:39yes, read so much -sometimes one thing melts into another, so have to be careful i get it right
22:42Where can i find help on making API calls from within Red
greggirwin
23:13https://github.com/red/code/tree/master/Library has a lot of examples, but you can also look at the Red source for the Windows platform itself. You have to use Red/System today, but we'll have an FFI in Red soon as well.
justjenny
23:19thanks Gregg and Nenad - will take a look tomorrow - after midnight here so time to sleep.

qtxie
04:16@justjenny @dockimbel I remember @hiiamboris did some work for that.
hiiamboris
18:15@justjenny https://gitlab.com/hiiamboris somewhere there. It's boring to load gitlab via 2G. I'm sure you'll find it :)
endo64
19:18Here it is https://gitlab.com/hiiamboris/red-alpha
hiiamboris
20:07:+1:
dockimbel
20:46@hiiamboris Thanks, that's the one, I searched in your gists but forgot about your Gitlab repo.
20:48@justjenny You'll have to compile that code to make it run (red -c ), it cannot work from the Red console, as it contains Red/System parts. Once we add support for importing C functions from Red itself, it will be possible to rewrite such code in pure Red.
justjenny
23:31Thanks @dockimbel @hiiamboris @qtxie @endo64 - all good, what a team, I will try it - also @viayuve I think this answers your question.

nedzadarek
19:43Little off-topic: is such transparency (not rectangular shape) possible on other OSes (Mac & Linux/Unix)?
@hiiamboris Is it Windows' bug that a little black area on the [Ring system](https://en.wikipedia.org/wiki/Ring_system) is treated as transparent place? I have checked it using [some online editor](https://www.peko-step.com/en/tool/imageeditor.html) and the black area is indeed not transparent.
hiiamboris
19:48It's just how Red base rendering is done on W8+.
nedzadarek
20:15Shouldn't the Red *fix* it?
20:15*in the future releases

viayuve
08:14@hiiamboris @justjenny @dockimbel @qtxie @endo64 thanks for the example. user32.dll https://www.codeproject.com/Articles/4473/Making-any-application-transparent-in-Windows did some reading here nice hack @hiiamboris
11:00write/binary %a.gif read/binary http://admin:admin@192.168.0.50:8080/onvif/device_service
*** Access Error: cannot connect: http://admin:admin@192.168.0.50:8080/onvif/device_service reason: timeout
*** Where: read
*** Stack:
endo64
13:10@viayuve Can you connect via web browser or using cURL or wget?

viayuve
07:23in browser onvif does not work but this works http://admin:admin@192.168.0.54:8080/shot.jpg what it does is fetches the latest frame.@endo64
07:23I thought may be it is because of limited codec support so I tried this too
07:24write/binary %a.png read/binary http://admin:admin@192.168.0.54:8080/shot.jpg
*** Access Error: cannot connect: http://admin:admin@192.168.0.54:8080/shot.jpg reason: timeout
*** Where: read
*** Stack:
07:24@endo64
07:29load http://admin:admin@192.168.0.54:8080/shot.jpg
== none
07:29but when i open it in browser it shows me latest frame from camera
endo64
07:54@viayuve Can you check this doc: https://github.com/red/red/wiki/%5BDOC%5D-Guru-Meditations#how-to-make-http-requests
07:55It could happen because of the User-Agent, some servers response only to browsers.
07:59You can try to send the necessary headers using write/info
write/info http://yourhost/ [
    GET
    [
		Content-Type: "text/html; charset=utf-8"
		Authorization: "Basic YWRtaW46YWRtaW4=" ;<-- means admin:admin, 
		User-Agent: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36"
		Accept: */*
	]
    ""
]
viayuve
08:00so you basically broken down curl info and fill it in! let me try
endo64
08:03Yes :)
08:07Content-Type could be removed as you don't send anything
viayuve
08:11nop not working console close itself
08:13let me give you complete situation "IPWebcam" app in android and trying to access image/video over wifi to my pc @endo64 ffmpeg can do both.
08:15I think I will just wait for ports to complete.
endo64
08:16Does it work with cURL?
08:17You might compare the network traffic using EtherSnoop, Wireshark or Fiddler.
viayuve
08:18not my cup of tea dear but will try
AlexanderBaggett
20:53view [ drop-list data [ "chicken" "beef" ] on-select [face/selected: 1] ] for me, the first time I pick beef it reverts to chicken, but subsequent times it stays beef, until I pick chicken again.
20:53I guess I am confused by the inconsistent behavior. I expected it to either work 100% of the time or 0% of the time.
20:54view [ drop-list data [ "chicken" "beef" ] on-select [face/selected: 1 do-events] ] , this however does what I expect it to.
dockimbel
21:31@AlexanderBaggett The second time you select the same option, and IIRC View drops the event in such case. You should not use do-events in that way, you are creating a new global event loop on each selection, and that will not end well. ;-)
21:31@qtxie ^--- We might want to reconsider this event dropping (if confirmed).

toomasv
03:20Confirmed on W10. on-select drops event on second selection, on-change works as expected.
qtxie
15:17@AlexanderBaggett This is a tricky case. I pushed a fix, should be fixed now. ;-)
AlexanderBaggett
16:03@dockimbel , @qtxie , Thank you guys so much for the quick response! I didn't expect this would get the immediate attention it did.
justjenny
22:30Hi, I know there are a lot of ways to add sound , but will sound be soon to be part of Red ?
greggirwin
22:47I wouldn't say soon. It will come after ports, but the sound design isn't set, and it's a low priority right now.

There are a few notes [here](https://github.com/red/red/wiki/%5BDOC%5D-Audio-R&D).
justjenny
22:55yes, thanks - concurrency
23:09I know the Red plan, but, developers could catapult Red into new realms if a few things were in place - one is sound , and it is crucial - (sorry my opinion, got to say it)
greggirwin
23:11Opinions are fine, but *why* is it crucial? Understand that we talk about features and priorities a *lot*, and what value they might add.
23:13We also look at history, particularly Rebol's, and note what didn't help it succeed.
23:14We should move to red/red though, to continue on this topic.
justjenny
23:16Gregg, It is only crucial to a developer - who needs that feature - the difference between the best and the rest. Sound is important
loziniak
23:18@justjenny you probably could develop sound using external libraries from Red.
23:18For example Alsa or PulseAudio if you use Linux
greggirwin
23:19There are already some in https://github.com/red/code/tree/master/Library
justjenny
23:22Gregg, thanks

Softknobs
15:50Hi, is code compiled with -c argument supposed to work the same way as with the -r argument? For example if I compile the following code with -c it will not output anything when run:
Red [		
]	
#system [
	print-line "Message from R/S"
]
print "Message from Red"

When compiled with -r both messages are displayed. Using -c and -d doesn't help either. This is unfortunate as I get compilation times of 30 to 90 seconds with -r when it lasts a few seconds with -c. And "print" is mostly useful to me for debugging not in release mode. Thanks.
endo64
16:37IIRC -d works only on Linux and does nothing on Windows (if you are on Windows).
I just compiled your code with -c and both messages appeared:
D:\Projects\Red\red\build\bin>test.exe
Message from R/S
Message from Red
16:39Your executable and libRedRT.dll library are in the same folder, right? When you compile with -c that dll (the Red runtime) is dynamically loaded during the run time, so both file should be in the same folder. -r compiles everything (your code and the runtime) into one executable so no need libRedRT.dll.
Softknobs
22:41@endo64 Thanks. I understand now why -d has no effect. This behaviour is when using git-bash. Using cmd or powershell gives another result, i.e. only the Red/System print-line is displayed, here is a screen capture:
![alt](https://www.softknobs.com/dl/red-print.gif)
This is really weird because I did this script to try to pinpoint the problem but I get more different outputs with the scripts I am working on:
- a red system script compiled with -c option outputs both print-line commands and "cout" from a bound dll
- the same red system code embedded in a red script (with #system) compiled with -c only outputs the result of "print-line" commands (not the bound dll cout)
- the same red script with embedded red/system code won't output the red "print" commands unless -r is used (just like the capture above)
- and I get different output variants using either CMD or git-bash ... ok git-bash is third party and could be buggy but CMD and Powershell are part of Windows so I would expect the code to work in the same way no matter if it is compiled with -c, -r, or if it is embedded red/system or not.
Is my installation corrupt? Is there a way to fix this? In that particular project, I ended up creating a binding to some C code that logs things to a file as I could not trust "print" and "print-line" commands.

dockimbel
23:44@qtxie ^---
23:51@Softknobs I cannot reproduce your issue on W10 using CMD, tried with -c and -r, and I always get the same output:
Message from R/S
Message from Red
23:53-d compiles in debug mode, which activates assertions, adds extra debugging functions and full stack traces on runtime crashes. On Linux, it includes an extra STABS section for third-party debuggers.
abdllhygt
dockimbel
23:57Powershell also prints correctly the two messages here in both -c and -r modes. Same for git-bash, no issue here.
abdllhygt
23:58how can i keep last char of string? best way?
23:58i found, sorry
23:59
last str

abdllhygt
00:04but another question
00:04
ruby
a = [1,2,3]
a.include?(2)

in ruby
dockimbel
00:05@Softknobs Try renaming your print.exe to something that does not clash with the existing print command-line tool, that eventually might be the cause of your troubles.
abdllhygt
00:05can i do it without foreach?
Respectech
01:33@abdllhygt Please explain what a.include?(2) is supposed to do in your example above.
abdllhygt
01:48it means that; is there 2 in array a
01:52and return true or false
toomasv
03:29@abdllhygt
a: [1 2 3]
to-logic find a 2
;== true
abdllhygt
03:34what's the difference of to-logic and to logic!?
toomasv
03:36
?? to-logic
to-logic: func ["Convert to logic! value" value][to logic! :value]
abdllhygt
03:37@toomasv thank you
toomasv
03:37You are welcome!
03:42@abdllhygt Also, to check if series has any of a set of values, use intersect:
a: [1 2 3]
not empty? intersect a [3 4 5]
;== true
not empty? intersect a [4 5 6]
;== false

abdllhygt
03:45oh that's good one too, but for except numbers
03:45thanks again!
toomasv
03:45
includes?: func [a b][not empty? intersect a b]
includes? a [3 4 5]
;== true
includes? a [4 5]
;== false

includes? "abc" "agh"
;== true
includes? "abc" "gh"
;== false
abdllhygt
03:48i think to make one by mix of intersect and find
03:50but first argument have to run like or
03:50for example
03:51
red
>> include? [1 2] [1 3 5]
== true
toomasv
04:28You mean something like this?
includes?: func [a [series!] b [any-type!]][
    either series? :b [
        if not same? type? :a type? :b [b: to type? :a :b] 
        not empty? intersect a b
    ][to-logic find a b]
]
includes? [a b c] 'a                ;true
includes? [a b c][a g]              ;true
includes? [a b c] make hash! [c d]  ;true
includes? [a b c] #"a"              ;false
includes? "abc" #"a"                ;true
includes? "abc" "a"                 ;true
includes? "abc" [#"a" #"f"]         ;true
includes? "abc" [#"g" #"f"]         ;false
abdllhygt
04:32yes it's
04:32so good!
04:33can i add it to my library with your name?
04:33for using and improving
toomasv
04:34Of course!
abdllhygt
04:35thank you
nedzadarek
09:50@toomasv @abdllhygt I was going to ask
> why not just find

... but then I find this: find "abc" [#"b" #"c"] ; none

@toomasv I think includes? needs some kind of typeset! value (e.g. intersect doesn't work on a image!).
godwinburby_twitter
11:31Hi, non programmer here. I had created a simple red program as windows client todo.txt. I am using it in my dekstop and in my android phone i'm using SimpleTask app which syncs to Dropbox. So my question is how do i download the todo.txt file from my dropbox account to windows desktop using red code ?
GiuseppeChillemi
12:29@godwinburby_twitter the most obvius answer is: load it using the local dropbox store directory
godwinburby_twitter
12:59@GiuseppeChillemi the problem is i don't want to install the dropbox software in my company dekstop ;-)
nedzadarek
14:39@godwinburby_twitter I wonder if there is a way to read it using a custom http header. [Here are a documentation](https://www.dropbox.com/developers/documentation/http/documentation) and [here](https://dropbox.github.io/dropbox-api-v2-explorer/#files_download) is specific "command".
14:41ps. I think you need authorization key, which I don't have, so I cannot check it (even I can).
Softknobs
21:53@dockimbel Thank you for investigating. This behaviour seems related to the libRedRT files. Mine were created the day I started using Red. I run all my scripts in the same folder. Are these files script specific? They don't look like they are. Removing all the libRedRT files fixed the problem when new files were created. This created an "extras" file that was missing. Now both Red and R/S print commands are output...
21:58@dockimbel However I still don't understand why printing to the console from a bound dll only works for pure R/S scripts and not Red scripts with #system (no include).
I created the following Gist to show the problem: https://gist.github.com/Softknobs/0fa89ece49feae6912d71d13c775f063
dockimbel
22:58@qtxie ^---
GiuseppeChillemi
23:46I am on REBOL stucked on a problem: it seems that lit words picked from a block become words. I have found no way to manage them (inserting in another block, change a value of another block.)
23:47Here is an example posted on the RED channel :
23:47>> foreach [val] [a 'b] [probe val]
a
b
== b
>>
RED
23:49Am I doing something wrong? Second, third, pick, all give me the same behaviour!

toomasv
05:09@GiuseppeChillemi Try
foreach [val] [a 'b] [probe :val]
giesse
05:50@Softknobs did you perhaps update Red without rebuilding the libRedRT files?
godwinburby_twitter
06:58@nedzadarek thank you. I'll check it out.
Softknobs
07:50@giesse This is good to know in the future but 0.6.4 is the only Red I installed so far. Thanks.
nedzadarek
08:50@GiuseppeChillemi
>> foreach [val] [a 'b] [probe val]
a
'b

It works fine for me. I am using Red 0.6.4 for Windows built 19-Jan-2019/14:54:56+02:00 commit #4880ddb but let me check a newer version. What version are you using (about)?
09:09Yes, works fine with Red 0.6.4 for Windows built 5-Jul-2019/18:00:59+02:00 commit #446550a. Are you sure you are not running any code before foreach (e.g. some function in the system/lexer/pre-load)?
toomasv
09:49@nedzadarek Question was about REBOL, IIUC.
nedzadarek
09:58@toomasv I see. My mistake. I am not used on strictly Rebol question on the Red's room.
GiuseppeChillemi
11:04@toomasv Thanks Toomas,I have been stuck in this hole for 2 full days. I have switched from a foreach approach to a forall/forskip one. I have used "set" "pick" "first" in all manners with absolute no success.
toomasv
11:07@GiuseppeChillemi You can also use quote
GiuseppeChillemi
11:19@toomasv I have found the source of the problem. What you think about it ? Am I making a mistake or it is a REBOL problem ?

>> x: [a b 'c d] forall x [probe first x]
a
b
'c
d
== d
>> x: [a b 'c d] forall x [a: first x probe a]
a
b
c
d
== d
>>

11:19It's the assigment to another WORD the problem.
11:19a: first x
11:22And I suppose it comes from the SET command

>> x: [a b 'c d] forall x [set 'a first x probe a]
a
b
c
d
== d

toomasv
12:02@GiuseppeChillemi Without delving too deep into this, I tend to simply accept small differences between REBOL/Red without making much fuss about it. They are (quite) similar, not same. Nevertheless, good to note differences.
Anyway, get-word works same in your case:
;REBOL
>> x: [a b 'c d] forall x [set 'a first x probe :a]
a
b
'c
d
;Red
>> x: [a b 'c d] forall x [set 'a first x probe :a]
a
b
'c
d
9214
13:05This R2 bug is known for nearly 5 years https://github.com/red/red/issues/734
abdllhygt
13:29@nedzadarek find is ok too, but it's not enough, i guess
GiuseppeChillemi
14:13Also I have spotted some differences in SET description:

*REBOL:*

>> help set
...
ARGUMENTS:
     word -- Word or words to set (Type: any-word block object)
     value -- Value or block of values (Type: any-type)

REFINEMENTS:
     /any -- Allows setting words to any value.
     /pad -- For objects, if block is too short, remaining words are set to NONE.


*RED:*

>> help set
...
REFINEMENTS:
     /any         => Allow UNSET as a value rather than causing an error.
     /case        => Use case-sensitive comparison (path only).
     /only        => Block or object value argument is set as a single value.
     /some        => None values in a block or object value argument, are not set.


/PAD does not exist in RED
/CASE addition to RED
/ONLY addition to RED
/SOME addition to RED

They are not noted here:
https://github.com/red/red/wiki/%5BDOC%5D-Differences-between-Red-and-Rebol#copy-object

Also, as REBOL is not so specific to /any

*RED* /any => Allow UNSET as a value rather than causing an error.
*REBOL* /any -- Allows setting words to any value.

I don't know if they refer to the same working
nedzadarek
14:27@abdllhygt I see.
endo64
15:03@GiuseppeChillemi You can add those changes in the wiki page. /pad is the default behavior in Red.
15:06And you can have similar effect using /some:
>> ==: >>: none
>> o: context [a: b: 0]
>> b: set o [x]
>> o
== make object! [
    a: 'x
    b: none
]
>> o: context [a: b: 0]
>> b: set/some o [x]
>> o
== make object! [
    a: 'x
    b: 0

GiuseppeChillemi
22:21I remember a rule about wiki pages editing is permitted only to red team members

rsheehan
05:39Hi from a very new Red person. I would like to add a field to an object using a name stored in a string variable. I can do it like this:
name: "x"
o: object []
o: make o compose [(to set-word! name) 4]

But I was wondering if there was a better or more idiomatic way of doing this? Thanks
endo64
06:25> I remember a rule about wiki pages editing is permitted only to red team members

@GiuseppeChillemi Only the Home page, you can freely add/edit other pages, we just need to keep it clean.
toomasv
07:23 @rsheehan There are few ways to do this, e.g.:
o: make o head insert [4] to-set-word name
o: make o append to-block to-set-word name 4
o: make o reduce [to-set-word name 4]

but they all use to set-word! or to-set-word. You might achieve this without explicit conversion with:
load append name #":"

but I would not say it is more idiomatic. Also, if name will be used in other places it should be copied.

And be aware that make creates new object from prototype o, it does not extend the original one.
rsheehan
08:37@toomasv Thanks for that. It is truly helpful.
toomasv
08:38@rsheehan You are welcome!
9214
08:41@rsheehan have you considered using map! instead?
rsheehan
08:42@9214 Yes. And that is what I will probably do, but I still wanted to know other ways. Thanks
nedzadarek
11:31@rsheehan as you are new to the Red let me ask you few question. Why have you chosen an object!? Do you have some reasons or is it just "because it is key-value container"? If it is the second then there might be other types more suitable for your task. Let me summarise it for you:
- object!: keys are words, you cannot extend (at the moment) it, fields can depend on other fields:
o: object [a: 1 b: does [print a * 10]]
o/b ; 10
o/a: 2 o/b ; 20

- map!: keys can be other types (e.g. any-string! or number!) but some are not allowed (e.g. object! or map!), you can extend it, fields cannot depend on each other\*
- block!: to make it simple: you can use any value as a key\**, you can extend it (you cannot use block/key: value for non existent keys but you have to use something like append block [key value]), fields cannot depend on each other*, block can be used for more complex data structures\**

\* you can hack it by writing whole path e.g. m: #(a: 1) m/b: does [m/a * 10]
\** blocks are just collection of values but when you type bl/some-word, the Red want to find next value after some-word (more [here](https://doc.red-lang.org/en/datatypes/path.html#_evaluation_steps))
GaryMiller
15:32Will the sound lib include speech when it is released? I know that it's not for a while and I have an external program that works for now but so far as I know,no languages currently have built-in speech so it might be a first if you could pull it off. A talking chess program would be an awesome demo!
nedzadarek
18:23@GaryMiller I guess you mean only text-to-speech. It might be nice for visually impaired people (e.g. when you do ctrl + click it will read face's text).
ps. as you mentioned text-to-speech I want to ask: what about speech recognition (English and other languages)?
GaryMiller
19:33Both text to speech and speech recognition are very useful not only for the handicapped but to create more immersive games. Even games like chess can be made more fun and easier to master when the computer analyzes your moves and tells you about your opening or coaches you throughout the game. I feel though that voice recognition is a lot harder technology than text to speech and you may be better going out to a cloud API for voice recognition rather than trying to train your voice recognition neural net yourself. If takes so many thousands of hours of speech with various genders, accents and varying voices to recognize a broad range of humans with a high degree of accuracy. I've not looked for any Open Sourced pre-trained voice recognition nets but I see there are a few out there now. https://fosspost.org/lists/open-source-speech-recognition-speech-to-text
19:38Language learning/translation programs to teach pronunciation are also an excellent area that voice recognition can be exploited to test a user's pronunciation. There are a few commercial programs on the market that use your microphone to validate you are pronouncing words and sentences correctly.
rsheehan
21:41@nedzadarek I originally chose an object because of the fact that fields can depend on other fields, but I may be able to use a map as a field of an object for the functionality I require. That was a very useful summary about why you might choose different types.
23:58Another simple question. In order to compute a series I have a couple of nice ways to do it:
>> a: collect [repeat i 10 [keep i]]
== [1 2 3 4 5 6 7 8 9 10]

or
>> repeat i 10 [append a: [] i]
== [1 2 3 4 5 6 7 8 9 10]

Is one of these more "red" like (I prefer the collect version)? Are there other approaches people would recommend?

greggirwin
02:48@GaryMiller it's not likely that we'll include text to speech as a standard component, as it will add significant size, and not be used in many projects. However, from an accessibility perspective, it would be good to make it easy to include. That's the goal for all modules and packages, once we get to that feature.
02:53@rsheehan neither of those is more idiomatic. Both are fine. We may add a range func in the future, but it needs design decisions to be made (people will then talk about lazy evaluation, etc.).

For small series, you won't notice a difference, but for really large series (tens of thousands of items), it's more efficient to allocate the series, then insert items into it. e.g. blk: make block! 10'000 and then append to that, or use collect/into. Just an advanced trick.
02:54We are still also considering an array func, as R2 had. e.g.
;?? Think about how to pass indices to generating funcs. Needs accumulator.
array: function [
	"Makes and initializes a block of of values (NONE by default)"
	size [integer! block!] "Size or block of sizes for each dimension"
	/initial "Specify an initial value for elements"
		value "For each item: called if a func, deep copied if a series"
][
	if block? size [
		if tail? more-sizes: next size [more-sizes: none]
		size: first size
		if not integer? size [
			; throw error, integer expected
			cause-error 'script 'expect-arg reduce ['array 'size type? get/any 'size]
		]
	]
	result: make block! size
	case [
		block? more-sizes [
			loop size [append/only result array/initial more-sizes :value]
		]
		series? :value [
			loop size [append/only result copy/deep value]
		]
		any-function? :value [
			loop size [append/only result value]
		]
		'else [
			append/dup result value size
		]
	]
	result
]
;array 3
;array [2 3]
;array [2 3 4]
;array/initial 3 0
;array/initial 3 does ['x]

For a simple job like the one you posted, using that with an incrementing function is more work.
toomasv
10:39[![array](https://toomasv.red/images/Diagram/array.png)](https://toomasv.red/images/Diagram/array.png)
pekr
10:45So cool 😎
AiguyGary_twitter
10:52So would large arrays of objects then be more efficient to process sequentially because the memory was allocated at one time and have adjacent memory locations resulting in more efficient caching within the processor caches called "locality of reference" https://www.csetutor.com/locality-of-reference-in-cache-memory. I have also seen cases in other languages where even if you do not know the maximum size of the array you can specify that it allocate new free space 100 (user definable) array elements chunks at a time as needed reducing new memory allocations and increasing speed. Hard to keep good locality of reference with garbage collection going on unless your garbage collector takes it into account when it sweeps and attempts to maintain that locality.
dockimbel
10:55@toomasv Very nice! Link for the source code?
toomasv
10:57Thanks! [diagram-style](https://github.com/toomasv/diagram/blob/master/diagram-style.red)
do %diagram-style.red
view dia [
	title "Gregg's array func"
	diagram 620x700 border 1 [
		space 30x30
		pad 0x20 node ellipse "Start"
		connect cond1: node diamond "block? size"
		connect hline label start "Yes" dia2: diagram width 380 add 0x10 border 1 silver [
			space 30x30
			cond2: node diamond 120x70 {      tail?^/more-sizes:^/   next size}
			connect hline label start "Yes" n1: node {more-sizes:^/    none}
			connect vline 30 from [bottom :cond2] "No" n2: node {   size:^/first size}
			connect from [bottom :n1] hint vertical to [right :n2]
			connect vline 30 from [bottom :n2] node diamond 80x70 {    not^/integer?^/    size}
			connect hline 30 label start "Yes" node {     cause-error script 'expect-arg^/  reduce ['array 'size type? get/any 'size]}
		]
		origin 10x320
		dia3: diagram width 460 add 0x10 border 1 silver [
			space 30x30 pad 35x0
			at 10x10 text bold "case" 
			cond3: node diamond 100x70 {    block?^/more-sizes^/  }
			connect hline 30 label start "Yes" node {  append/only result array/initial more-sizes :value}
			connect vline 30 from [bottom :cond3] to top label start "No" cond4: node diamond 100x70 {series?^/:value}
			connect hline 30 label start "Yes" node {  loop size [append/only result copy/deep value]}
			connect vline 30 from [bottom :cond4] to top label start "No" cond5: node diamond 100x70 {  ^/any-function?^/       :value}
			connect hline 30 label start "Yes" node {  loop size [append/only result value]}
			connect vline 30 from [bottom :cond5] to top label start "No" node {  append/dup result value size}
		]
		connect hint [vertical 210] from [bottom :cond1] to [top -80x0 :dia3] label start "No" 
		connect from [bottom :dia2] to [top -80x0 :dia3] hint [vertical 20]
		connect from :dia3 hint horizontal to top origin 500x550 node "result"
		connect vline 30 from bottom to top node ellipse "End"
	]
]
dockimbel
10:58So, the diagram description code is hand-written, I thought you had a tool for analyzing code and generating it?
toomasv
11:00Not yet. I'll try first several small cases to hand-write. Then, hopefully, with better understanding what it takes, can start generating it.
dockimbel
11:02The algorithms and heuristics for calculating a proper layout are certainly not easy to design. There should be some literature online on such class of algorithms.
11:04@toomasv Do you have that code above in a gist or on github, so I could link it from a tweet?
toomasv
11:11@dockimbel Yes, I need to study these algorithms. Recently played with [force-based layout](https://gitter.im/red/sandbox?at=5d1f58db77c54c13e60469fa).
I put this code in [gist](https://gist.github.com/toomasv/e1dd2b9c6f3e882387d6de988c9c585c)
jlhouchin_gitlab
12:43 If you do not have a prebuilt series of values, but are receiving data from a source and writing into a vector!.
Can you pre-allocate for a vector! of specified length and type?
Or must you always use append vec value ?

I am creating a vector! of maybe 100 million values (float) or so. It seems like it would be better to pre-allocate if I have an idea of the number of values.
Thanks.
endo64
12:50> Can you pre-allocate for a vector! of specified length and type?

>> v: make vector! [float! 32 10]
== make vector! [float! 32 [0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0]]
12:51@dockimbel In case you've missed this, here are a bunch of cool works of @toomasv
https://toomasv.red/Two-years.md.html
9214
12:57@jlhouchin_gitlab you can pre-allocate any amount of cells / bytes in a series with make . @endo64 showed you vector! constructor format, covered in detail [here](https://doc.red-lang.org/en/datatypes/vector.html).
jlhouchin_gitlab
13:01@endo64 and @9214
Thanks.
I had forgotten to look at the official docs. I didn't see it elsewhere or I missed it.
I tried it.
>> v: make vector! [float! 64 100000000] 
== make vector! [0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ...
>>

It worked beautifully. My console immediately shot up to 772mb of ram. :)
9214
13:02@jlhouchin_gitlab you can periodically call garbage collector with recycle, if memory consumption causes you troubles.
jlhouchin_gitlab
17:19@9214
No I am okay with the memory. Seems plenty reasonable and comparable to other platforms.
In this particular use case, if memory was a constraining issue, I would load only a portion of the data and operate on it. Then load the new data in its place. But I would rather load it all into memory and iterate over it a thousand times rather than hitting the hard drive a thousand times and save memory. I prefer better performance and shorter iteration cycles.

Now when I first tried this and I loaded it into a block! instead of a vector! then I was surprised by the memory. And that was with only 44million float! values.
nedzadarek
17:20@AiguyGary_twitter in my opinion text-to-speech chess might be nice but I prefer list of suggestion in the form of text. It's easier to navigate and read at your own peace.
Pronunciation - nice example.
@rsheehan :+1:
9214
17:22@jlhouchin_gitlab yes, block! is more memory costly than vector!, because it stores all values as uniformly boxed structures (16 bytes). vector!, on the other hand, uses as many bytes as needed to store data of a particular type (float64 in your case).
greggirwin
20:08I imagine we'll see a combination of @toomasv's experiments, where an auto-layout tool works for simple things, and does *try* for more complex diagrams. But rather than spending tons of effort on those, let the user drag things around once it's generated. The ultimate, then, would be to incorporate data from what a user did to help the layout engine learn.
20:11@AiguyGary_twitter don't try to think about low level optimizations in Red. Think about clarity and intent. There will be a few hints and tricks, like preallocating, but really we want all that hidden from the user for most code.
GaryMiller
20:32Yes, but corporate customers care about scalability too. And I'm assuming that's who the Pro target audience will be. Even game developers care about efficient garbage collection and eventually somebody will benchmark Red and then we hope they knew enough Red internals to make the Red benchmark translations as efficient as they can be.
greggirwin
20:36Scalability is a broad term, and almost exactly the opposite of micro-benchmarks. The big picture is what matters, and using Red's features appropriately. Choose based on your needs.
20:37We don't want to go head to head in feature wars, but to show our strengths and advantages, and attract those who value them.
GaryMiller
20:49One hot buzzword now with corporate customers is low-code solutions. Most of these low-code solution available now are cloud based so they eliminate most of the small customers who don't want a monthly cloud bill that costs and arm and a leg. If Red created enough dialects to deal with typical type low-code problems like database, workflow, forms, CRM, Inventory, Payroll, HR type applications. Red Pro users could customize their low-code solution and you'd practically have that niche all to yourselves.
20:50Congrats on the new Red Wallet by the way!
greggirwin
21:17Yes, the low-code market is high on our radar.
GiuseppeChillemi
22:13@greggirwin I like "low-code" term ! And yes, its where RED and REBOL shine !

OneITI37
01:17I have a question.
01:17Is there any way to update an element in a Red window?
01:18I mean, JavaScript has its way to access and manipulate an HTML element’s visual style and attributes actively.
01:18Does Red have that kind of function?
01:19Just like this: https://www.w3schools.com/js/tryit.asp?filename=tryjs_dom_animate_3
01:21Even after a window is loaded, an element(in the window)’s attribute or position should be able to be changed through user interface actions and processing.
dander
02:01@OneITI37 have you seen this blog post? It has a bunch of simple demos and is a good introduction to reactive programming in Red: https://www.red-lang.org/2016/06/061-reactive-programming.html
endo64
05:34@OneITI37 Also check the test scripts in the repo: https://github.com/red/red/tree/master/tests especially the view/vid/react ones.
dockimbel
10:48@OneITI37 Red's GUI engine relies on an object tree, similar in concept to the DOM, but with a new simpler model. You can build GUIs by creating such tree manually, or by using the VID frontend DSL that compiles your GUI description to an object tree.

View engine with face objects: https://doc.red-lang.org/en/view.html
VID DSL: https://doc.red-lang.org/en/vid.html
Big example of manually constructing a face tree: https://github.com/red/red/blob/master/tests/view-test.red
10:50A simple example of changing a face properties at run-time:
view [b: base button "Change" [b/color: random white]]
greggirwin
15:05There are also a number of resize experiments, and a foreach-face function to iterate over faces in the tree.
abdllhygt
16:44hey!
16:45is it a bug?
>> "i" = "ı"
== true
>> "o" = "ö"
== false
toomasv
16:49@OneITI37 This JS example is in Red *much* simpler:
view [
    below button "Click Me" [b/offset: 10x50 b/rate: 30] 
    at 10x50 a: box yellow 400x400 
    at 10x50 b: box red 50x50 on-time [
        if (face/offset: face/offset + 2) + 50 = (a/offset + a/size) [face/rate: none]
    ]
]
9214
16:56@abdllhygt seems to be. Can you post it in /bugs room please?
toomasv
17:17And draw-based alternative:
view [
    below button "Click Me" [b/2: 0x0 t: 0 a/rate: 30] 
    a: box yellow 400x400 
        draw [pen off fill-pen red b: translate 0x0 box 0x0 49x49] 
        on-time [either (t: t + 1) < 176 [b/2: b/2 + 2][a/rate: none]]
]
abdllhygt
21:17@9214 okay

OneITI37
00:50@dander @endo64 @dockimbel @greggirwin @toomasv Thank you for your response! I found Red more intuitive than JavaScript.
nedzadarek
08:34@toomasv @OneITI37 It depends on what kind of library you are using. For example in p5.js ([examples](https://p5js.org/examples/)) you can make [slider dance](https://editor.p5js.org/dano/sketches/Hk8firTC). Maybe they have similar examples like Toomas' but I do not have much time to look for. You can check examples or click File>examples in the slider dance website.

nedzadarek
15:41In the [handle.html#abstract](https://doc.red-lang.org/en/datatypes/handle.html#_abstract) it says:
> Handle! values represent opaque integers that are used for interacting with the operating system.


What it means *opaque integers*? Is it something similar to [opaque integer resources](https://stackoverflow.com/questions/42330074/how-to-understand-the-opaque-integer-resources-in-kubernetes-resource-model)?
9214
16:45@nedzadarek https://en.wikipedia.org/wiki/Handle_(computing)

nedzadarek
17:40@9214 thank you
GiuseppeChillemi
19:35Hi, I need to know how a *block* of code is loaded in RED. I wish to read each element of it and know if it is a word assigned to a function or a value, a lonely string, a comment, and so no. How could it be done ? I have tought some approaches but none of them works.
nedzadarek
19:42@GiuseppeChillemi I wonder if recompiling the Red from the source is the only way.
ps. you can use system/lexer/pre-load to read source and change it but you have to give it rules.
greggirwin
19:46First, there are no such values as comments.

You can look at the help source to see how it identifies and dispatches based on value types.

A loaded block is not evaluated by default, so you can just use foreach, check the type of each value, and if it's a word, use get to see what type of value that word refers to.
nedzadarek
20:14@greggirwin I think he meant a "normal" block of code (part of a source code) not a value of a type block!... but I may be wrong.
GiuseppeChillemi
20:38Ned, I suppose it is not possible to access the loaded source and the pointer to the current evaluation position in the source. So I suppose providing a block of code is the only way.
20:41Also I have just noted that RED LOAD does not seem to accept a block but REBOL accepts it.
21:05@nedzadarek I have seen using system/lexer/pre-load recently from Toomas but I do not know where to find documentation

nedzadarek
04:16@GiuseppeChillemi I have found this https://www.red-lang.org/2017/03/062-libred-and-macros.html
It just run some function that can change a source code before you load the source code.
04:20> the current evaluation position in the source

I think he made something like this using pre-load.
toomasv
05:30@GiuseppeChillemi @nedzadarek Yes, I used that as my guide.
But you might also consider load/next to see loaded code by pieces. A simplistic example:
>> hack: function [str][while [not empty? str][elem: load/next str 'str either block? elem [probe <start-block> hack mold/only elem probe <end-block>][probe elem]]]
== func [str /local elem][while [not empty? str] [elem: load/next str...
>> str: read %parse-expr.red
== {Red []^/do %../rich-text/info.red^/do %diagram-style.red^/context [^/^...
>> hack str
Red
<start-block>
<end-block>
do
%../rich-text/info.red
do
%diagram-style.red
context
<start-block>
cnd:
none
skp-obj:
<start-block>
skp:
-3
<end-block>
...
nedzadarek
17:22@toomasv nice, btw.could you link to it? I don't have the link bookmarked.
toomasv
17:58@nedzadarek Sorry, link to what?
nedzadarek
19:31@toomasv The guide...
> the current evaluation position in the source

I thought you used someone's code. The code that shows line numbers and evaluated code.
toomasv
19:41@nedzadarek There is some misunderstanding. I used as guide the examples you linked to above. :smile:
nedzadarek
20:03@toomasv then, I am sorry.
toomasv

abdllhygt
10:19how can i find by number?
10:20find works:
>> find ["a" "b"] "a"
== ["a" "b"]
10:20i want:
>> find ["a" "b"] "a"
== 1
10:29i found a way:
>> (length? ["a" "b" "c"]) - (length? find ["a" "b" "c"] "c") + 1
== 3
toomasv
10:33@abdllhygt
>> index? find ["a" "b"] "a"
== 1
>> index? find ["a" "b" "c"] "c"
== 3
abdllhygt
10:38@toomasv thank you
toomasv
10:38You are welcome!
endo64
11:12@abdllhygt Just remember, if find cannot find it returns none hence index? fails:
>> index? find [a b] 'c
*** Script Error: index? does not allow none! for its series argument


You can check the value first or ignore the error:
>> attempt [index? find [a b] 'c]
== none
>> if p: find [a b] 'c [index? p]
== none

toomasv
12:09Yup, forgot that. Thanks for clarification, @endo64 !
abdllhygt
21:17@endo64 thank you, i try to make a library about these: [easy way](https://github.com/abdllhygt/qaja/blob/master/lib/eway.red)

mikeparr
08:17The use of 'context'. I've been looking at several (excellent) demo programs by various authors, and am uncertain about the reasons for using 'context'. Is is possible to identify situations where 'context' is a good idea?
pekr
08:28Isn't context .ostly a sbortcut to make object! ?
mikeparr
08:43@pekr - thanks - so *why* would I want to make a complete program into an object?
9214
08:46@mikeparr if you want to encapsulate your program into a "module".
mikeparr
08:58@9214 Thanks! This is a 'programming in the large' reason, then. Any other uses of context?
AiguyGary_twitter
10:45This just started happening recently under fully updated Windows 10. When I go to execute my Red programunder Powershell console. I get the line Compiling Red GUI console... So it seems like something is being sensed to make it recompile the GUI console. Is there any automatic updates or anything happening in the background that could cause this? It doesn't happen all the time. But it just started a few days ago after a major Windows 10 update.
9214
10:55@AiguyGary_twitter it happens each time you download a new toolchain binary. GUI console is compiled and placed somewhere in AppData/Red IIRC, so, next time you launch Red toolchain it will pop up automatically. Be aware that W10 Defender can block this compiling process and delete console binaries, in such case you need to whitelist them.
AiguyGary_twitter
10:58I thought I had it whitelisted before since I haven't been getting any more antivirus warnings but maybe the last Windows update caused the Whitelist to be ignored. I'll re-whitelist ans see if it goes away.
toomasv
11:16@mikeparr You can use it as .. well, context for you func, e.g.
context [fi: #(0 0 1 1) set 'fib function [n][either out: fi/:n [out][fi/:n: (fib n - 1) + (fib n - 2)]]]
9214
11:23@mikeparr, what @toomasv describes is called a [closure](https://en.wikipedia.org/wiki/Closure_%28computer_programming%29). But don't confuse contexts and objects - context is a "namespace" that any-object! and function! values provide to enclose their *internal* definitions from *external* world. So, the most common use case, like I said, is encapsulation. With contexts you can also leverage bind to build dialects and high-level functions (e.g. collect).
abdllhygt
11:29someone wrote a library about strings, do you remember? like that;
before:
["he" "she" "it" "they"]
11:29after:
"he, she, it and after"
toomasv
11:38@abdllhygt [Here](https://gist.github.com/toomasv/fd651f24e18d7bc85d05204cc5f828d2)
>> concat ["he" "she" "it" "they"][[", "] " and "]
== "he, she, it and they"

(How do you get {after: "he, she, it and after"} I don't know :smile:)
11:50@mikeparr One practical use of context is to encapsulate words in view and e.g. share some words between actors:
context [
    b: ofs: none 
    view [
        size 500x500 
        b: base 
        at 0x0 box 500x500  0.0.0.254 all-over 
            on-down [ofs: event/offset] 
            on-over ['local [df] if event/down? [
                df: event/offset - ofs 
                b/offset: min 490x490 max -70x-70 b/offset + df 
                ofs: event/offset
            ]]
    ]
]
abdllhygt
11:57@toomasv sorry i mean "they" not "after" haha
11:57thank you!
toomasv
11:57@abdllhygt You are welcome!
abdllhygt
11:59@toomasv can i add concat to eway?
toomasv
12:00@abdllhygt Yes.
abdllhygt
12:00thanks again
toomasv
12:01:smile:
abdllhygt
12:05[added!](https://github.com/abdllhygt/qaja/blob/master/lib/eway.red)
mikeparr
13:09@9214 and @toomasv - context - thank-you, very informative answers!
toomasv
13:58:+1:
greggirwin
19:09@mikeparr while you can't really hide things in Red contexts/objects, you can use them, as @9214 said, as ad hoc modules until we get the real thing. The concept of name spaces and information hiding are at the core of modular development, and can get you a long way.

In Red's case, set-words in an object have to be accessed "through" that object, using path notation or binding. But if you use set, e.g. object [a: 1 set 'show-it does [print a]], show-it is "exported" to the global namespace, so you can call it directly. In this example, I didn't set a word to refer to the object, so it's anonymous, which makes it much harder to get at a and mess with it. Not impossible, but a way to protect things a bit more.
GaryMiller
19:25Is the current planned concept of modules to compile separately to Dynamic Libraries and be callable at runtime or are they just comipleed seperately and linked into the larger single executable during the linker last phase of generating the executable. Or are those facets of the architecture still undecided?
mikeparr
19:38@greggirwin - re context - much appreciated.
nedzadarek
22:23@toomasv :point_up: [July 19, 2019 1:38 PM](https://gitter.im/red/help?at=5d31abafec5abe7bbc0f864a) I think you should add some kind of license or "can/cannot/warranties list".
ps. good code
greggirwin
22:34@GaryMiller the latter. Modular compilation and overall structuring for PitL is the goal. Dynamic libs are a separate target or project type, as they are today.

dander
06:07I'm trying to figure out how to manipulate the loading/parsing code without re-compiling. I thought that all I would have to do is replace the existing function with a new version like this (using a tweaked version of the transcode source).
>> system/lexer/transcode: function [
[        src	 [string!]
[        dst	 [block! none!]
[        trap [logic!]
[        /one
[        /only											
[        /part	
[            length [integer! string!]
[        return: [block!]
[        /local
[            new s e c pos value cnt type process path
[            digit hexa-upper hexa-lower hexa hexa-char not-word-char not-word-1st
[            not-file-char not-str-char not-mstr-char caret-char
[            non-printable-char integer-end ws-ASCII ws-U+2k control-char
[            four half non-zero path-end base base64-char slash-end not-url-char
[            email-end pair-end file-end err date-sep time-sep not-tag-1st
[    ] bind [
[        probe ["customized 'transcode'"]
[    ] :system/lexer
== func [
    src [string!] dst [block! none!] trap [logic!] /one 
    /o...
>> load "whatever"
== whatever

But load still uses the old transcode. Any ideas about what is going on?
9214
08:30@dander
>> system/lexer/transcode: func spec-of :system/lexer/transcode [print "new transcode"] ()
>> load "1 2 3"
== [1 2 3]
>> load: func spec-of :load body-of :load ()
>> load "1 2 3"
new transcode
*** Script Error: result: needs a value
*** Where: result
*** Stack: load
nedzadarek
08:32@dander some code (compiled as fair I remember) will still refer to old bindings. So you changing system/lexer/transcode does not change the fact that load still thinks that system/lexer/transcode is some function in some place.
ps. as ^^ said:
load "foo"
; == foo
load: func spec-of :load body-of :load 
load "foo"
; ["customized 'transcode'"]
; == []
abdllhygt
14:34hey!
14:34@toomasv i have a problem with concat
14:34
>> u [(ia [word: "mamazo" adjective: ""])(ia [word: "mamaxo"])]
== "ayah, ibu"
>> u [(ia [word: "mamazo" adjective: ""])(ia [word: "mamaxo"])(ia[word:"hama"])]
== "ayah, ibu dan makanan"
>>
14:35the code:
concat newblock[[", "] " dan "]
14:36it doesn't work for array which have two member
dander
16:36@9214 @nedzadarek thanks to you both! That is very helpful
9214
16:43@dander depending on the use-case, you might want to use system/lexer/pre-load instead.
dander
16:51@9214 I want to collect source positions of the loaded values. I know that transcode already has some stuff for keeping track of line numbers. I'll take a look at pre-load too when I get a chance
greggirwin
17:56@dander there's a little more info about what @9214 mentioned [here](https://github.com/red/red/wiki/%5BDOC%5D-Guru-Meditations#compiled-versus-interpreted-behaviors)
toomasv
19:30@abdllhygt It's hard (read: impossible) to say anything without knowning what is u, or ia or newblock.
abdllhygt
19:44@toomasv
>> concat ["a" "b" "c"] [[", "] " and "]
== "a, b and c"
>> concat ["a" "b"] [[", "] " and "]
== "a, b"
19:45if first argument have 2 member, it doesn't work like i want
19:45i want the result is "a and b"
toomasv
19:46@abdllhygt OK, I understand. Will look into it.
abdllhygt
19:47@toomasv thank you!
toomasv
19:58@abdllhygt Had to recall:
>>  concat ["a" "b" "c"] [[", "] " and "]
== "a, b and c"
>>  concat/last ["a" "b" "c"] [[", "] " and "]
== "a, b and c"
>> concat/last ["a" "b"] [[", "] " and "]
== "a and b"
abdllhygt
20:00did you upgrade concat.red?
20:01
>> concat/last ["a" "b"] [[", "] " and "]
*** Script Error: concat has no refinement called last
*** Where: concat
*** Stack: concat
toomasv
20:04Sorry, checked from my local copy from April. Now [gist upgraded](https://gist.github.com/toomasv/fd651f24e18d7bc85d05204cc5f828d2).
abdllhygt
20:10@toomasv thank you!
toomasv
20:10You are welcome!
abdllhygt
20:10can i ask; when/why did you add MIT license?
toomasv
20:11Just now :point_up: [July 20, 2019 1:23 AM](https://gitter.im/red/help?at=5d3242f99851416687330c1a)
abdllhygt
20:13hmm okay
nedzadarek
20:31@abdllhygt In my opinion it's good to add some kind of license so you don't waste your and his/her precious time with simple questions like: Can I use/modify it?
toomasv
20:33@abdllhygt Is this a problem?
abdllhygt
20:44I'm building a library for using in my project. And i copied it to the library. I thought that we can decide the license together later.
nedzadarek
21:41@abdllhygt as fair I can see the MIT license allows you to use your own license but you just need allow to use @toomasv 's work for other people. So, aside from few basic things (like you have to add license text), you don't have to worry about it.
21:43ps. some licenses are like this: allows you to do almost everything but they just *protect* the original author.
abdllhygt
21:50I just was surprised and asked it. And about original authors;
Red [
  title: "Easy Way Lib For Easy Way"
  author: [
    "Abdullah Yiğiterol"
    "Toomas Vooglaid"
  ]
]
nedzadarek
23:24@abdllhygt In my opinions it's better to add something like "used libraries", e.g.:
title: ...
author: "Abdullah Yiğiterol"
used-code: [
   concat: http://github.com/path/to/gist/or/repository
   foo: [
     author: ...
     link: ...
     license: ...
  ]
]

this way you show that **you** made/collected the code and made some decisions.

AiguyGary_twitter
14:32I filed another report with Microsoft asking that they fix Windows Defender to not delete file: C:\ProgramData\Red\gui-console-2018-11-22-8164.exe They still believe it is infected with Trojan:Win32/Fuery.C!cl and rate the warning Severe. After the last Windows update though you can only temporarily whitelist it and then it deletes it again after a short period of time. And thee real time error detection re-enables itself also after a short period if you disable it. Any feel for whether this problem will disappear soon on the Red side or will we need to wait on the Pro Version for that to happen?
greggirwin
16:38It's likely Red/Pro will be the answer to that. With constantly changing heuristics, we can't try to work around them all the time.
AiguyGary_twitter
18:16I was thinking maybe a password encrypted .exe where the password was generated randomly and it would decompress into memory as it executed. This might add a second or so to compilation time/load time so could be managed as a compile option for those users who needed it. But it could also reduce the .exe size even further for those who took advantage of it. https://en.wikipedia.org/wiki/Executable_compression
greggirwin
20:02UPX does help, but is still not a perfect solution.

AiguyGary_twitter
00:02I think UPX give Microsoft and other antivirus makers the ability to decode the compressed .exe so if there's a signature in C:\ProgramData\Red\gui-console-2018-11-22-8164.exe then they'd be able to read the uncompressed .exe anyway and still see the signature. But if any of the .exe compressors are open source and you varied the password used to encrypt then every executable would be different it would just have to know how reconstruct the key from a registry entry or the computer name or something.

loziniak
18:10Hi! I wonder why it's not working:
body: [print self/a]
o: object [
    a: 15
    f: function [] body
]
o/f ;-- expected to print "15" but gives error
greggirwin
18:13Because body is defined outside your object spec, so the words in it are not bound to the object.
loziniak
18:14I thought words are bound only when block is evaluated.
greggirwin
18:14
self: [a "this is a test"]

body: [print self/a]
o: object [
    a: 15
    f: function [] body
]
o/f ;-- note that it works, even though `self` is just a block in this case.
18:16Words always have a binding.
18:17This relates to what is meant by *definitional scoping*, where the word is defined (not set) determines its initial binding.
18:18Let me see if I can find the classic, mind-bending example.
loziniak
18:22I'm surprised. It's totally new to me.
greggirwin
18:24It's not in [this](https://github.com/red/red/wiki/%5BNOTES%5D-How-Red-Works---A-brief-explanation), but it's a good read. Still looking.
18:27I have to move to other things right now. If nobody else finds it, or recreates it, I'll do it later.
18:28@9214 has done at least one version, I'm sure.
loziniak
18:28Ok, thanks for explanation.
greggirwin
18:30More than you ever want to know can be found [here](https://en.wikibooks.org/wiki/Rebol_Programming/Advanced/Bindology)
toomasv
18:57@loziniak As Gregg said - you have to bind body to self:
body: [print self/a]
o: object [
    a: 15
    f: function [] bind body self
]
o/f
;15
9214
19:39@greggirwin are you looking for [this](https://gist.github.com/9214/cf24ff767f6167ab16203b77b06e2a82)? It's rather old and at some places even misleading (as I wrote it being a newbie myself), but should illustrate the concept well.
greggirwin
19:46This is one of the "stepping off the shallows shelf and into the deep water" moments in Red. It may seem strange at first, but it's part of what makes Redbol langs different, and it's crucial to their design. You can still forget about it most of the time, but when something strange happens, or you *want* to do something out of the norm, remember that words carry their context with them, i.e. their binding. It's set by default, where they are defined, or when you use bind, but they remember it.

For example, do @toomasv's example, then add this after it:
o-2: object [
    a: "Aaaaah!"
    f: function [] body
]
o-2/a
o-2/f

As with your initial example, body is *not* rebound when o-2 is made.
19:46
blk: copy [x]		; x hasn't been set yet
x: 1
c: context [x: 'b]	; `object` and `context` are alias funcs
append blk in c 'x	; `in` gets a bound word from a context
o: object [x: 'Oooh  append blk 'x]	; `x`'s context is known
blk			; Are all X's created equal?
print blk

Functions also have a context, but it only exists while they are being evaluated.
19:47Yes, @9214, that was the one.
19:47Couldn't think of what is was called. ;^)

gavr123456789_gitlab
14:53Hi, I would like to use as much compact red compiler as an additional tool for another language as usually do with lua. Can I somehow pass red code to compile without creating a file? Like ./red print "hello" and get hello to stdout. Or would it be better to open the red process as a REPL by contacting him via pipes?
9214
15:02@gavr123456789_gitlab what you describe in your example is evaluation of expression from command line with *interpreter*. We don't have such feature yet, but it should be trivial to add, e.g. with --do flag as in R2.
gavr123456789_gitlab
15:02I wanna something like -c flag on Python https://stackoverflow.com/questions/27157683/how-to-use-the-c-flag-in-python
15:02Can you tell me more what is R2?
9214
15:04@gavr123456789_gitlab Rebol2.
gavr123456789_gitlab
15:06I do not know anything about Rebol, and Redland discovered recently, but I was surprised by its presentation, DSL for all is a great idea. So what exactly do I need to do with this --do flag?
9214
15:14@gavr123456789_gitlab nevermind. Rebol2 is (or rather *was*) a predecessor of Red, and used --do flag to evaluate expressions from console the way you want.

You can use here-documents (at least on *nix) to work around it, with the caveat that console will display the Red banner and you need to end session with q and delimiting identifier:
$ ./red-cli << EOF
> print "test"
> probe 1 + 2
> q
> EOF
--== Red 0.6.4 ==-- 
Type HELP for starting information. 

test
3
gavr123456789_gitlab
15:23@9214 Ty, то есть редланг еще не полностью написан на самом себе? И стоит ли мне создавать issue в git для добавление возможности аналогичной флагу -c из python?
9214
15:29@gavr123456789_gitlab we rely on Rebol2 for bootstrapping phase, yes, but only Red/System toolchain and Red compiler are written in it, the rest is pure Red and Red/System.

You don't need to open an issue, we can squeeze that feature into 0.6.5 release (or someone can submit a PR for it).

ralfwenske
04:25Red 0.6.4 for macOS built 24-Jul-2019/5:51:39+10:00 commit #613d71c

This program works fine in interpreter. However when I attempt to compile it I get:
*** Compilation Error: undefined word objects 
*** in file: /Users/ralfwenske/Dropbox/red-crypto5/prepare-ledger.red
*** near: [objects [file: %data/ta-priced.obj]

this is the extracted code which might show what I'm doing:
%libs/objects.red:
...
objects: context ["object-values store allowing keyed access by any field"
    name: ""
    file: %.
    obj-id: 0           ;key of current obj
    last-id: 0
    object: context []  ;access, update object values via this object
    params: context []  ;holds column-width decimals for print
    extra: context []
    ixs: copy #()       ;holds indexes for access by sorted field(s)
    data: copy #()      ;holds values of objects - key is unique integer! (obj-id)

    init: function [
        "declare keys in object (do not after load!)"
        object-def [block!] "key: [width decimals] eg. [ fldA: [10 0] price: [-12 2] ]" 
    ][
        self/params: make object! object-def
        set self/object: copy self/params none
        ...
    ]  
    ...
]

%prepare-ledger.red:
do load %libs/objects.red
    ...
    ta-priced: make objects [file: %data/ta-priced.obj] 
    ta-priced/init [          
        id: [6 0]
        date: [11 0]
        ...
    ]

Any hints as to what might cause this error?
toomasv
04:47@ralfwenske use #include instead of do load for compilation
ralfwenske
07:55Thank you @toomasv . I had to change a number of object words ( like /object or /forall ) which the compiler complained about.
Would it be difficult for the interpreter to reject object/keys which the compiler will not digest?
A naive user (like myself) might expect that if it runs in the interpreter it should also compile as is…
or is this because we are still in alpha?

Another issue I have now (when compiling) is that the compiler says that an object-key (word) is not defined. It has been created via a set command (see init above - I now changed /object to /obj ). And as said before the interpreter has no problem. Is that expected at this stage (or ever)?
toomasv
08:07@ralfwenske Someone more at home with compiler should explain these issues. But #include %file should be safe to use instead of do %file as told in [this](https://www.red-lang.org/2017/03/062-libred-and-macros.html) article.
ralfwenske
09:10Thanks @toomasv yes I have replace all do loads with #includes and the interpreter still works.
greggirwin
13:34> Would it be difficult for the interpreter to reject object/keys which the compiler will not digest?

@ralfwenske, it won't solve the problem in general, because new keywords may be added in the future, which may cause old code to break. This is an issue with all languages. But if you can post small examples, we can use those to see where it goes awry, which *might* provide a general solution.

On set, that's dynamic code only a JIT compiler could understand. There will always be cases that can't be compiled, and why Rebol never had a compiler at all. We had to choose if supporting the many cases that can be compiled is worth the extra effort, and how to deal with the fallout. There are two options for that. Use -e when compiling, which causes *all* your code to be interpreted at runtime, so it *will* be 100% interpreter compatible, at the cost of some performance. The second trick is to wrap your dynamic code in do [...], which will force it to always be interpreted. That way you can mix and match at will.

ralfwenske
00:56Thank you @greggirwin , I am not so much concerned about speed but rather than to be able to create an app for the different platforms which can be delivered in one piece and is simple to install. So I will experiment with both the options you have given.
02:34Happy: …got it to work ( -e option) after trying various file parameters for the #include instruction.
Only an absolute file path was recognised by '#include'. Is it possible to have relative paths for #include?
Also I had to initialise the app with change-dir %./ for it to find it’s way around...
06:19Is there a simple way how to organise folder structure for a 'view app?
I found accessing folders/files with relative path %./.... didn't work after compiling.
Do I have to have a global file-var pointing to my root-folder?
-and hand that in to #included sources- ?

I started a simple view app (%what-dir.red) and compiled and started it in varying ways (on OSX):
Red [needs: view] p: form what-dir view [size 300x100 text p]

Under interpreter it shows the folder where what-dir.red is located.
Compiled with -t macOS -r and console-started it shows where 'what-dir.app' is located
Compiled with -c and console-started it shows where what-dir is located.
Compiled with -t macOS -r and double-click it shows /
Compiled with -c and double-click it shows /User/username/
Is there a reliable way to find out from where the app starts up?
I wonder how to best do this when also considering Windows/Linux as a target (and non-programmers as users).
nedzadarek
09:15@ralfwenske what about get-current-dir?
09:15^^ you start an app when the executable is.
09:20> I found accessing folders/files with relative path %./.... didn't work after compiling.
Do I have to have a global file-var pointing to my root-folder?

If it doesn't work then maybe you can use environment's variables? Not sure about OS' other than the Windows but on the Windows you set it once and you can read it via get-env.
ralfwenske
09:58@nedzadarek I checked with get-current-dir - unfortunately the same results.
9214
10:29> Only an absolute file path was recognised by '#include'

That's not true. Both absolute and relative paths work fine.

> I found accessing folders/files with relative path %./.... didn't work after compiling.

Because binary's location and process' working directory are not the same thing.

> Is there a reliable way to find out from where the app starts up?

Depends on what you mean by "where the app starts up".
11:18Perhaps system/options/boot is what you're looking for.
normalize-dir to file! system/options/boot

Should give you an absolute path to executable.
abdllhygt
11:36hi!
how can i know that a variable is declared or not?
11:44i use this: error? try [variable]
nedzadarek
11:46@abdllhygt
>> a
*** Script Error: a has no value
*** Where: catch
*** Stack:  

>> value? 'a
== false
>> a: 42
== 42
>> value? 'a
== true
abdllhygt
11:48@nedzadarek thank you!
nedzadarek
12:07:+1:
abdllhygt
14:00how can i delete a value?
toomasv
14:15@abdllhygt Like this?
>> a: 1
== 1
>> unset 'a
>> a
*** Script Error: a has no value
abdllhygt
14:16@toomasv yes, thank you!
toomasv
14:16:+1:
nedzadarek
14:25@toomasv @abdllhygt for simple cases this might be enough but to be precise you are not deleting values but "dissociating" a word from a value that it points to. With only one-word-per-value it is not important but when you associate one value for few words (a: b: [some big block]) removing one *connection* will not remove another (as fair I remember). If your value is some huge value you may prevent garbage collector from removing it.
ps. I guess @toomasv knows this already
abdllhygt
14:28doesn't this unset 'a clear from memory? @nedzadarek
nedzadarek
14:31@abdllhygt as I said, no. It merely disassociate (a word does not point to old value) word from a value. Depending on garbage collector, values can stay longer than unset 'a.
abdllhygt
14:31@nedzadarek thank you for the info
nedzadarek
14:33@abdllhygt You can read more [there](https://www.red-lang.org/2018/12/064-simple-gc-and-pure-red-gui-console.html)
abdllhygt
14:54okay
greggirwin
17:17@ralfwenske @9214 pointed out the difference between a working directory and startup path. Running the Red console directly, versus running a compiled exe, versus running a script from an editor that may or may not set the working directory to the dir where the script is located, is a lot of variables to account for. It can be confusing.

You've already made a start on the research. If you would create a wiki page (Active and Process Directories might be a good name) and get some initial info in there, that would be *great*.
17:18If there are things you don't feel you can answer there, leaving questions in the wiki is fine, so others can see gaps that need to be filled. A section on #include and relative paths would also be helpful.
9214
18:11@abdllhygt if words are bound to the same context, then unsetting one will also unset all the others, because you don't really "delete a variable", you just put a special-purpose unset value in it.
abdllhygt
18:17@9214 thank you
9214
22:08Sorry, my message above is actually pretty nonsensical, it's rather the other way around: words can have same spelling but different bindings, and in such case unsetting one won't affect the other.

What I described earlier (different spellings but same binding and index) isn't possible without aliases.

ralfwenske
00:35@9214 @greggirwin Thank you for helping me with this.
I tried the following (OSX):
Red [needs: 'view] 
print ['what-dir what-dir]
print ['get-current-dir get-current-dir]
print ['system/options/boot normalize-dir to file! system/options/boot]
p1: form what-dir
p2: form get-current-dir
p3: form normalize-dir to file! system/options/boot
view [size 400x100 below text p1 text p2 text p3]

starting from console
macmini:red-test ralfwenske$ /usr/local/bin/red --cli /Users/ralfwenske/red-test/what-dir.red
what-dir /Users/ralfwenske/red-test/
get-current-dir /Users/ralfwenske/red-test/
system/options/boot /Users/ralfwenske/.red/console-2019-7-23-71505/

after compiling with -c starting from console
macmini:red-test ralfwenske$ ./what-dir
what-dir /Users/ralfwenske/red-test/
get-current-dir /Users/ralfwenske/red-test/
system/options/boot /Users/ralfwenske/red-test/what-dir/

when double-clicking the -c version (inside %/red-test/)
macmini:~ ralfwenske$ /Users/ralfwenske/red-test/what-dir ; exit;
what-dir /Users/ralfwenske/
get-current-dir /Users/ralfwenske/
system/options/boot /Users/ralfwenske/red-test/what-dir/

when double-clicking the -t MacOS -r version (window shows)
/
/
/Users/ralfwenske/red-test/what-dir.app/Contents/MacOS/what-dir/

My aim is to supply the compiled (or sources.red) app inside a folder which also contains data files/folders/apps which the interpeted/compiled app can access - independent from where this folder sits.

(From users perspective: simply download folder and start the app in various ways).
Is that possible in Red (for Win/Mac/Linux)?
01:10Earlier I had used the -e option to compile in interpreter mode.
I have changed some set instruction so I can now compile using -c.
Obviously the compiler now has to deal with constructs it hadn't seen under -e .
btw. interpreted the app runs fine.
Compiling I get:
-=== Red Compiler 0.6.4 ===- 

Compiling /Users/ralfwenske/Dropbox/red-crypto5/prepare-ledger.red ...
...using libRedRT built on 28-Jul-2019/22:42:09
Compiling libRedRT...
...compilation time : 2352 ms

Compiling to native code...
...compilation time : 59385 ms
...linking time     : 772 ms
...output file size : 1085440 bytes
...output file      : /Users/ralfwenske/Dropbox/red-crypto5/libRedRT.dylib 

...compilation time : 837 ms

Target: Darwin 

Compiling to native code...
*** Compilation Error: argument type mismatch on calling: red/eval-int-path* 
*** expected: [struct! [
        header [integer!] 
        data1 [integer!] 
        data2 [integer!] 
        data3 [integer!]
    ]], found: [struct! [
        header [integer!] 
        ctx [pointer! [integer!]] 
        symbol [integer!] 
        index [integer!]
    ]] 
*** in file: %/Users/ralfwenske/Dropbox/red-crypto5/prepare-ledger.red 
*** in function: exec/f_<anon580>
*** at line: 332 
*** near: [
    stack/unwind 
    actions/length?* 
    stack/unwind 
    type-check as red-typeset! get-root 164
]

I am a bit lost as in 'how to narrow this down' to the cause of this.
Any ideas?
greggirwin
02:49If it's hard for you, imagine what it's like for us, when we can't even see the code. ;^)
ralfwenske
04:29:) of course. I do have my source - yet the mentioned file only has 203 lines and the interpreter understands it (at least all the code it came along).
My thinking is that some reference to my sources might make it a bit easier to find out wether it’s me having a bug in my code or if it is something valid/invalid that the compiler has not (yet?) anticipated? I cannot find a resemblance of *** expected and my code.
My asking for ideas was related to some hints for possibly finding a connection between my sources and those 'libRedRT' files...
greggirwin
04:42If you're building things dynamically, and using paths with them, where integer indexes are used, red/eval-int-path* is a clue.
ralfwenske
04:45Thank you @greggirwin that narrows it down - I will start digging.

ralfwenske
02:14Sorry - me again :)
Now that I have embedded (hopefully) all dynamic code with do I encounter following:

A view app with a reactor leads to being
interpreted: it works (shows a view, on button click does some processing )
compiled -c: it works (shows a view, on button click does some processing )
compile -t macOS -r: compiler error
*** Compilation Error: word with not defined in react/with 
*** in file: /Users/ralfwenske/Dropbox/red-test/test-objects.red
*** near: [react/with blk ctx]

after removing all react stmts:
compiled -t maOS -r: it works partly (shows view but does not respond to button click)

putting back in two lines:
win-size: 1200x800
react: make reactor! [w-size: win-size]

compile -t macOS -r: results in:
same compiler error as above.

So I am wondering: if it compiles and runs with -c shouldn't it do the same with -r ?
greggirwin
02:34I think it should. If you can post the smallest code that dupes the issue in a gist, that will help us all verify, and eventually debug it.
ralfwenske
05:44@greggirwin Not sure if I did this right #3959 ?
endo64
07:38@ralfwenske Thanks for submitting the issue.
There are some issues in your submit that you can easily fix:
1. Copy & Paste the whole URL into Gitter, not just write # and issue ID, Gitter automatically formats the full URL into short form.
2. Please edit the issue description instead of commenting. You can move you last comment to the description (just click on the green Edit button for the issue itself) adn remove the comments.
3. Please format your code by enclosing it between three back-ticks ` (or select your code and click on the Code icon in the tool bar)
ralfwenske
07:44@endo64 Thank you for your help. It all makes sense - only I fail to see a green Edit button or anything similiar where to put the issue?
endo64
07:48Ah sorry, it is the button next to green one
07:48[![image.png](https://files.gitter.im/red/help/hYp2/thumb/image.png)](https://files.gitter.im/red/help/hYp2/image.png)
ralfwenske
07:50@endo64 When I click that one I get to edit the title, nothing else.
toomasv
07:50@ralfwenske Click on "..." on right at your issue bar.
ralfwenske
07:53@toomasv mmh? I see "…" only in the comments bars. Nowhere else on the entire page
toomasv
07:56[![image.png](https://files.gitter.im/red/help/mEiZ/thumb/image.png)](https://files.gitter.im/red/help/mEiZ/image.png)
I mean.. where your issue is described.
endo64
07:58Ah, yes @ralfwenske is right, your first issue description goes to comments section, my bad.
07:58So you can remove your first "empty" comment and format the correct one. Thanks!
ralfwenske
08:25Here the proper link to the issue [3959](https://github.com/red/red/issues/3959)
08:34@endo64 How do I remove that empty comment? (Initially I was looking for some entry form myself and somehow then ended up in the second… :) A bit confusing when using it rarely.
endo64
15:23i think delete is available only for a limited time, then you can only edit.
greggirwin
17:15@ralfwenske I've messed it up at times myself. Web UIs in general can be difficult, due to lack of consistency. Only regular use solves that. And even then...
nedzadarek
19:26@endo64 @ralfwenske only edit is *time limited*. You can delete your own post after longer time (just click ...).
justjenny
23:36The 'tit for tat' theory/strategy - please show me some Red examples

ralfwenske
05:01In an earlier post :point_up: [July 28, 2019 4:19 PM](https://gitter.im/red/help?at=5d3d3e65b2f4075cb8160ff1) I said
> Is there a simple way how to organise folder structure for a 'view app?
> I found accessing folders/files with relative path %./.... didn't work after compiling.

@9214 corrected me in that
Now I found how I came to make that statement:
An app compiles fine with -c yet when compiling the same app with -c -e I get
-=== Red Compiler 0.6.4 ===- 

Compiling /Users/ralfwenske/Dropbox/red-crypto5/prepare-ledger.red ...
...using libRedRT built on 1-Aug-2019/7:18
*** Compilation Error: include file not found: ./libs/globals2.red 
*** in file: /Users/ralfwenske/Dropbox/red-crypto5/prepare-ledger.red
*** near: [
    #include %./libs/globals2.red 
    #include %./libs/objects2.red 
    #include %./coingecko.red 
    init: func
]

I remember when putting in absolute path’s it compiled.
greggirwin
05:07@justjenny what is your comment related to? Examples of what?
ralfwenske
06:03Regarding my above post: I created a small app replicating above’s include structure and that compiled with -c -e. Then in the above (more complex app) I replaced only the #include %libs/globals2.red with the absolute path (also in objects2.red) and then it compiled and worked? What to say?
9214
09:35@ralfwenske https://github.com/red/red/issues/3464 looks similar.
ralfwenske
09:41@9214 thanks
abdllhygt
16:17what means it:
*** Script Error: either does not allow logic! for its true-blk argument

why either can't allow logic!?
9214
16:54@abdllhygt it allows logic values only for the first argument, not the second or third one.
endo64
16:55@abdllhygt second and third values should be a block, only first one can be logic!
16:56Ah I wasn't fast enough :)
abdllhygt
16:58my code was like that
>> either comment {} true [][]
*** Script Error: either does not allow logic! for its true-blk argument
*** Where: either
*** Stack:
16:58i guessed that it doesn't see the comment
16:58@9214 @endo64 thank you
endo64
17:25@abdllhygt you are giving unset! logic! block! to either
toomasv
17:28And unset! is treated as true here.
greggirwin
18:01@abdllhygt it sees the *result* of comment, which others pointed out is unset!. When using the comment function, as opposed to ; syntax, the values do not disappear from your code during evaluation. Here you can see the result of comment is returned.
>> either probe comment {} true [][]
unset
*** Script Error: either does not allow logic! for its true-blk argument
*** Where: either
*** Stack:


So your either statement looks like this to Red (concretely what @endo64 said):
>> either unset! true []
18:07This can be a useful feature in dynamic programming. For example, you can have things that act as comments in your code, then "enable" them with a switch or just changing comment to do.
>> e.g.: :comment 
== func ["Consume but don't evaluate the next value" 'value][]
>> add-3: func [n][add n 3]
== func [n][add n 3]
>> blk: [e.g. [print 3 = add-3 0]   add-3 1  add-3 100]
== [e.g. [print 3 = add-3 0] add-3 1 add-3 100]
>> do blk
== 103
>> e.g.: :do
== make native! [[{Evaluates a value, returning the last evaluation result} 
    value [any-type!] 
    /expand "Expand dir...
>> do blk
true
== 103

Which is something Red can leverage as well, for testing, docs, and new ideas we haven't developed yet.
abdllhygt
20:43@endo64 @toomasv @greggirwin i see, thank you
justjenny
21:00@greggirwin 'tit for tat' as a strategy in game theory. As in the 'Prisoners Dilemma'
I have looked at some simple Python scripts, just wondered if anyone did any Red code.
Was reading this: https://en.wikipedia.org/wiki/Prisoner%27s_dilemma and became interested.
not a biggy, am playing with it for fun. Jenny
greggirwin
21:16@justjenny I understand tit for tat, but didn't know if there was something specific you wanted. The Red Community and Red Code repos (under the Red organization on github) have examples, and many of us have gists or personal repos out there. e.g. https://gist.github.com/greggirwin, https://gist.github.com/toomasv.

Anyone know if you can search for all Red Lang gists?

You can also post specific questions or things to port. If they're small, you'll get takers.
9214
21:36@greggirwin [here](https://github.com/red/red/wiki/%5BLINKS%5D-Scripts-collection).
21:39Although I don't recall any game-theoretic projects. A good way to start is to play with payoff matrices and try to model dove / hawk strategies.
justjenny
21:57Hawks and Doves - just reading it - http://college.holycross.edu/faculty/kprestwi/behavior/ESS/HvD_intro.html#qualSoln - good stuff, thank you

TimeSlip
03:56Hello. It's been so long since I have had the time to touch Red. I'm now returning to add some fixes to an app but I continue to get : *** Driver Internal Error: Script Error : to-local-file expected path argument of type: file string
*** Where: throw-error
*** Near: [to-local-file script-name]
03:57I tried hello.red just to make sure it wasn't my app but that too returns the same error. Any thoughts?
9214
04:01@TimeSlip can you give us a minimal code example and about info?
TimeSlip
04:03Thank you.
04:03Red [
title: {hello.red}

]
print "hello world"
04:03Red 0.6.4 on windows
04:05O:\>red -c hello.red

-=== Red Compiler 0.6.4 ===-

Compiling O:\hello.red ...
Compiling libRedRT...
*** Driver Internal Error: Script Error : to-local-file expected path argument of type: file string
*** Where: throw-error
*** Near: [to-local-file script-name]
9214
04:08@TimeSlip okay, can you:
* try to compile your snippet with -r instead of -c
* check if the problem still persists in [nightly build](https://static.red-lang.org/dl/auto/win/red-latest.exe)?
TimeSlip
04:12Yes, -r worked. I'm thinking you're right and I will download and reinstall everything thing. It may have been installing 0.6.4 and not properly overwriting older files. Like I said it's been a while.
04:12@9214 Thank you so much!
9214
04:13@TimeSlip np, have fun.
TimeSlip
04:39@9214 Yes, it was because I did not update the "Source" files. Again thank you.
14:38How does one "center" vid containers within a window (or another container)? Do I need to calculate the "at" position or is there a keyword? Just trying to make my interface prettier :-) Thanks.
pekr
14:54Try help center-face at the console ....
TimeSlip
14:55@pekr Thanks. I wondering if "below" would also work. It seems to have a center alignment. Appreciate it Pekr.
9214
14:59@TimeSlip below and across change layout direction, column-wise or row-wise, respectively. You can also specify an alignment modifier (e.g. center), see [p. 4.1 - 4.3](https://doc.red-lang.org/en/vid.html).
TimeSlip
15:00@9214 Thank you!
15:25Yes "below center" is going to be a more elegant approach for me. Thanks to @pekr and @9214 (Pekr, it turns out I was using center-face/with in my app but with the morass of panels I wasn't probably confusing the heck out of Red and the Rebol version preceding it. :-)
15:27Don't you just hate it when a couple of words here and there fix a problem that you've been working on for a couple of hours? :-)
toomasv
16:20@justjenny Here's [one try](https://gist.github.com/toomasv/77884524435d80941c000de196ab2764) on Prisoner's dilemma tournament
greggirwin
18:11@TimeSlip:
view [
	style chk: check "Option" data yes
	style vline: base 2x60 red
	across top    vline button "Ok" text "Text" field chk return
	across middle vline button "Ok" text "Text" field chk return
	across bottom vline button "Ok" text "Text" field chk
]

view [
	style chk: check "Option" data yes
	style vline: base 200x2 red
	below left   vline button "Ok" text "Text" field chk return
	below center vline button "Ok" text "Text" field chk return
	below right  vline button "Ok" text "Text" field chk
]
18:12Adapted from the MacOS GUI blog entry example.
nedzadarek
20:19@toomasv with your [diagram dialect](https://github.com/toomasv/diagram) can I detect events like on-down?
I want to do this: when I click on some elements of a diagram and I want to change its (or other elements') color(s).
toomasv
20:32@nedzadarek Possible but unconvenient currently. I don't know yet how to easily mix predefined and user-defined actors. But currently you can do this so:
view dia [
    diagram border 1 [
        n1: node "one" 
        n2: node "two" 
        do [
            append body-of :n1/actors/on-down bind [
                change find/tail n2/draw 'fill-pen random 255.255.255
            ] :n1/actors/on-down
]]]
TimeSlip
23:15@greggirwin Gregg, Copied to my Curecode for future reference. Thanks.
23:21BTW @greggirwin It might be a good idea to place a note on the Download page about users needing to download the sources zip so they don't end up having compiling issues like I did. It's not all that obvious that one needs those sources along with executables and the necessity of making sure they are up-to-date if an executable is also updated. That's the second time that has thrown me for a loop. Doc had to set me straight the first time :-) Hope all is well with you.
greggirwin
23:25If you use the binary download, you shouldn't need the sources. What may have happened is that you had an old compiled runtime that caused the problem. There is a -u compile switch for that, to force an external runtime recompile.
justjenny
23:28@toomasv thanks you

TimeSlip
01:27@greggirwin Gregg, I suppose but it was trying to generate a new one I think. Anyway, downloading the newer sources and copying them over did the trick. I didn't delete anything so I think the old libRedRt was there. I have another old directory on another computer so I could verify whether the -u would work. It's in storage so it might be a while. Anyway thanks.
nedzadarek
11:09@toomasv thank you.
ps. can't you just parse something like some-keyword event [...] or on-my-down/up/... into above code like this:
view dia [
  n1: node "one"  on-my-down [
    ; some code here
  ]
]

would translate to:
view dia [
   n1: node "one" do [
      append body-of :n1/actors/on-down bind [
         ; some code here
      ] :n1/actors/on-down
   ]
]
toomasv
11:12@nedzadarek Yes, it can be done. It can be done even with on-down [...], as it is parsed anyway. But I'm not convinced it is good or general enough for all actors. But it is a possibility, yes.
nedzadarek
14:20@toomasv I see, thank you.
abdllhygt
21:46can i use rich-text on area? i mean as syntax colors
greggirwin
21:48@abdllhygt no, you have to use the rich-text style for that. Area is a basic, native control the OS provides.
abdllhygt
21:51which method i have to use for area styling?
greggirwin
22:04You can't style an area. It's just plain text.
22:05You can set the font, as with other faces, but not change it based on text elements. e.g. view [area font-size 16 italic 400x300].
abdllhygt
22:07do IDEs use their own tools for it?
greggirwin
22:17Yes.
22:20There are other tools and libraries out there, for general use. e.g. Scintilla, so you can see how others do it. Red has basic highlighting in the console, and you can use the rich-text style in Red. @toomasv has written some examples for that.
abdllhygt
22:55thank you

TimeSlip
02:05Can anyone point me to an example of a #import'ed .dll that uses a Struct! ? I know there is some special voodoo that has to be done and I rarely ever venture into making routines so I can't figure out what I am doing wrong and it seems like the Rebol example (Nick's mp3 script) is different enough from Red's implementation that it has become a show stopper, well, at least a compile stopper. :-) Thanks in advance. If I can see it properly done, I believe I can figure it out.
greggirwin
02:20https://github.com/red/code/blob/master/Library/os/windows.reds
TimeSlip
03:02@greggirwin Thanks Bro.
greggirwin
04:04@Oldes is expert in that area, should questions arise.
TimeSlip
04:06@greggirwin Funny you should mention that. Your example led me to the script library and I was looking at his work. Unfortunately for me he has his own way and I'm still stuck.
04:07The alias struct! appears fine but my code uses "routine" and for whatever reason, I can't get it to compile correctly following the #import [] part where all the routines are at.
04:08
*** Compilation Error: invalid definition for function exec/red_Mp3_PlayLoop: [
pStartTime [red-StartTime!]
fFormatEndTime [integer!]
pEndTime [red-EndTime!]
nNumOfRepeat [integer!]
return: [integer!]
/local res
]>
toomasv
05:38@abdllhygt [Here](https://github.com/toomasv/learning/tree/master/snippets/rich-text) are some rich-text examples. And see [docs](https://doc.red-lang.org/en/rtd.html) of course.
9214
06:39@TimeSlip can you please format your code using code fences and specify how you compile your script, to make it easier for us to identify the problem?
Oldes
08:04@TimeSlip routine is for running Red/System code from Red side, but Red does not have struct! datatype yet, so that is probably your source of problem. As @9214 mentioned, it would be easier to see your code to give you some help.
abdllhygt
10:18@toomasv thank you
toomasv
11:40:+1:
GaryMiller
13:01Has anyone here tried this yet with red? https://devblogs.microsoft.com/commandline/introducing-windows-terminal/
gurzgri
14:04@GaryMiller It's already somewhat usable with the following profiles.json section, but I experienced that the console history doesn't work :
{
            "acrylicOpacity" : 0.85000002384185791,
            "closeOnExit" : true,
            "colorScheme" : "Solarized Dark",
            "commandline" : "red-lang.exe --cli",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "guid" : "{b0db2a1f-c11e-4c05-a14b-853dc38d885d}",
            "historySize" : 9001,
            "icon" : "D:\\Development\\Red\\red.ico",
            "name" : "Red",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : "D:\\Development\\Red",
            "useAcrylic" : true
        }

TimeSlip
03:07@9214 @Oldes #system [ StartTime!: alias struct! [ ms [integer!] sec [integer!] bytes [integer!] frames [integer!] hms_hour [integer!] hms_minute [integer!] hms_second [integer!] hms_millisecond [integer!] ] EndTime!: alias struct! [ ms [integer!] sec [integer!] bytes [integer!] frames [integer!] hms_hour [integer!] hms_minute [integer!] hms_second [integer!] hms_millisecond [integer!] ] #import [ "libwmp3.dll" stdcall [ Mp3_Initialize: "Mp3_Initialize" [ return: [integer!] ] Mp3_Destroy: "Mp3_Destroy" [ initialized [integer!] return: [integer!] ] Mp3_OpenFile: "Mp3_OpenFile" [ class [integer!] filename [c-string!] nWaveBufferLengthMs [integer!] nSeekFromStart [integer!] nFileSize [integer!] return: [integer!] ] Mp3_Play: "Mp3_Play" [ initialized [integer!] return: [integer!] ] Mp3_Stop: "Mp3_Stop" [ initialized [integer!] return: [integer!] ] Mp3_PlayLoop: "Mp3_PlayLoop" [ initialized [integer!] fFormatStartTime [integer!] pStartTime [StartTime!] fFormatEndTime [integer!] pEndTime [EndTime!] nNumOfRepeat [integer!] return: [integer!] ] ] ] ]
03:08And in the same file outside the #import block I have the routines: red_Mp3_Play: routine [ "Play an mp3 file" initialized [integer!] return: [integer!] /local res [integer!] ][ res: Mp3_Play initialized res ] red_Mp3_Stop: routine [ "Stop an mp3 file" initialized [integer!] return: [integer!] /local res [integer!] ][ res: Mp3_Stop initialized res ] red_Mp3_PlayLoop: func[ "loop an mp3 file" initialized [integer!] fFormatStartTime [integer!] pStartTime [StartTime!] fFormatEndTime [integer!] pEndTime [EndTime!] nNumOfRepeat [integer!] return: [integer!] /local res ][ res: Mp3_PlayLoop initialized fFormatStartTime pStartTime fFormatEndTime pEndTime nNumOfRepeat res ]
03:10I have a couple of other routines but I just copied a few to show you what I was doing. All the other routines work. The only problem child is the mp3_PlayLoop one.
03:12Thank you for your help. I have to work on my real job so I'll be checking in later. As I mentioned, I took this from Nick's Rebol code and I also researched it on mp3lib page to verify that the naming and types were correct.
greggirwin
03:18@TimeSlip click the little M to the right of the edit area for markdown help on formatting code. You got close on the first one. ;^)
Oldes
06:45@TimeSlip as I said.. there is nothing like a struct datatype in Red yet. Also instead of blindly providing routines to the Red level from the R/S level.. it is better to use Red datatypes.. in this case for example time! and fill the struct used in the loop routine from it. I'm only on mobile and don't have libwmp3 sources.. so I cannot comment more. Also as you noticed.. I have my own way of doying these things.. btw.. you should also not give user a chance to crash the app using bad arguments.. which you do with your way.
GaryMiller
14:58@gurzgri https://www.zdnet.com/article/microsoft-new-windows-terminal-update-is-out-and-its-huge/
gurzgri
15:08@GaryMiller Thanks, nice! Red --cli still w/o console history, but Terminal now accepts [ ] { } with german keyboard layout. Starting to get useful.

quan-nh
07:36hi, what's practice way to remove the last item from a block?
pekr
07:50remove back tail series?
07:51
>> series: [1 2 3 4 5]
== [1 2 3 4 5]
>> remove back tail series
== []
>> series
== [1 2 3 4]
>> head remove back tail series
== [1 2 3]

quan-nh
07:59oh, nice. thank you. although more function than I expected :D
rebolek
08:00
>> series: [1 2 3 4 5]
== [1 2 3 4 5]
>> take/last series
== 5
>> series
== [1 2 3 4]
pekr
08:25I don't take it :-)
rebolek
quan-nh
10:42I have 2 files like this:
a.red
Red []

a: 1
b: 2

add: func [x] [x + a + b]


b.red
Red []

do %a.red

print add 1


when do compile red -r b.red I got the error:
*** Compilation Error: missing argument 
*** in file: b.red
*** near: [add 1]
10:42how to fix this :D
10:43run from console with red b.red working fine
9214
10:45@quan-nh try with -r -e flags, or use #include instead of do.
quan-nh
10:51 both are working :thumbsup:, thanks!
endo64
21:02@quan-nh This would also work: (b.red)
Red []
do %a.red
print [add 1]

GiuseppeChillemi
16:02Hi, when I compose a block, how could I add refinements to a function?
16:05Also, question number 2, is it possible to have the full specs definition, so I could use it as a specs to build another similar function without intervening into modification of the starting specs?
toomasv
17:17@GiuseppeChillemi Could you be more specific with question 1? Any examples?

Doesn't spec-of work for question 2?
nedzadarek
19:21@toomasv @GiuseppeChillemi as for 2) there are some "exceptions":
>> f: function [][m:0] spec-of :f
== []
>> f2: function[/extern o][] spec-of :f2
== []
19:27
>> qux: func[/ref][either ref[12][34]]
== func [/ref][either ref [12] [34]]
>> compose [(reduce to-path [qux ])]
== [34]
>> compose [(reduce to-path [qux ref])]
== [12]

?
endo64
19:44@nedzadarek "as for 2) there are some "exceptions""

Actually, it is not an exception, the spec of the function is [] in your example. [/extern o] is a dialect evaluated by function native to generate a function value (with a spec [] in this case)
>> f: function [/extern a] [a: 1]
== func [][a: 1]  ; <-- spec is []
GiuseppeChillemi
19:48@toomasv

>> probe spec-of get 'select
[
    {Finds a value in the series and returns the value or series after it.}
    series [series! object! port!]
    value [any-type!]
    /part "Limits the search to a given length or position."
    range [number! series! port!]
    /only "Treats a series value as a single value."
    /case "Characters are case-sensitive."
    /any "Enables the * and ? wildcards."
    /with "Allows custom wildcards."
    wild [string!] "Specifies alternates for * and ?"
    /skip "Treat the series as records of fixed size"
    size [integer!]
]


Yes, it worked.
nedzadarek
19:55@endo64 that's why I put it in the quotes (") - user hasn't questioned about function but function (e.g. spec in helpers likefunc spec ..., has spec ..., function spec ... etc) . From the way s/he phrased the question I think s/he meant later - s/he wanted spec: [/extern a] from your example.
19:58@GiuseppeChillemi you can use "get syntax"(get-word! or get-path!): probe :select.
endo64
20:19@nedzadarek I understand your point but we should not confuse, [/extern a] is NOT a spec, it is just a block (a dialect) interpreted by a *function* to generate a function value. The generated function value has a spec.
GiuseppeChillemi
20:38@nedzadarek I have tried:

>> a: "find" b: "tail" compose [(reduce reduce [to-path rejoin [a "/" b] "abc" quote 'b])]
*** Script Error: path must start with a word: find/tail
*** Where: reduce
*** Stack:


nedzadarek
20:39@endo64 but does the spec(ifications) can be in different forms? In my opinion things like [/extern a] are specifications as well because they specify requirements. Those things, however, may differ with the programming's people.
GiuseppeChillemi
20:39Have tried:

a: "find" b: "tail" compose [(reduce [to-path rejoin [a "/" b] "abc" quote 'b])]
== [find/tail "abc" 'b]
20:41But the second reduce has not worked
20:42I have already encountered this problem with strings reduced to path and first word not recgnized as word.
20:48I had this problem some months ago and discussed here with you
nedzadarek
20:52@GiuseppeChillemi ah, sorry, I've typed without much thinking. to-path doesn't need /. It just needs elements (or space in case of strings, as fair I can see).
20:53a: 'find b: 'tail compose [(reduce reduce [to-path reduce [a b] "abc" quote 'b])] ; == ["c"]
endo64
20:54
>> reduce reduce [to-path "find tail"]
*** Script Error: find/tail is missing its series argument  << expected

>> reduce reduce [to-path "find/tail"]
*** Script Error: path must start with a word: find/tail  << strange error

GiuseppeChillemi
20:56@nedzadarek Thanks, now I have understood
20:57@toomasv everything is now clear
nedzadarek
20:58@endo64 yes, errors' messages might be little clearer.
endo64
21:02But it still is not clear to me:
>> probe b: first probe a: first reduce [to-path "find/tail"]
find/tail
find/tail

>> reduce [a b]
== [find/tail find/tail]
>> reduce reduce [a]
*** Script Error: path must start with a word: find/tail   <<< Why?

>> reduce reduce [b]
*** Script Error: find/tail is missing its series argument  <<< OK
21:03a and b are both find/tail path value, how they produce different errors, there must be some internal difference between them.
9214
21:04@endo64 as a general rule of thumb (which really should be documented elsewhere, because I'm frankly tired of repeating it [over](https://www.reddit.com/r/redlang/comments/86kdwr/on_words_vs_paths_confusion/) and [over](https://github.com/red/red/wiki/%5BDOC%5D-Path!-notes), esp. WRT path!s): do not use to for string conversions, use load.

In your 2nd case, error is straight to the point - find/tail is a path! which sole elemement is find/tail itself.
>> length? to path! "find/tail"
== 1
>> first to path! "find/tail"
== find/tail

This stems from unfinished any-path! and to / make design , which should be resolved at one point or another.
21:10To make it a bit more obvious: internally, a looks like [[find tail]] and b looks like [find tail].
endo64
21:20@9214 Thanks a lot, that explains it all! Somehow I missed your notes on path, sorry.
9214
21:24@endo64 not to worry, you're welcome. Notes are not mine, they were extracted and extended by @greggirwin from related Reddit discussion, IIRC. It's a bit hard to find them after wiki reorganization, unless you remember that they exist somewhere out there :wink:
nedzadarek
22:16@endo64 Ah, I thought you mean general error's design not your actual problem. I'm sorry.
GiuseppeChillemi
22:34@nedzadarek
> @endo64 but does the spec(ifications) can be in different forms? In my opinion things like [/extern a] are specifications as well because they specify requirements. Those things, however, may differ with the programming's people.

Once the function is built internally I suppose the /extern a spec disappears.
23:04I am trying
23:06.. To get also the Arity of a function. I remember some code doing this. Has anyone a link?
23:17It seems I hav found it https://gist.github.com/dockimbel/111bbccd0d446fc69b2ec372ca05417c
23:18Tomorrow I will try.
endo64
23:18https://gist.github.com/dockimbel/111bbccd0d446fc69b2ec372ca05417c
23:18Ah you found it already :)
GiuseppeChillemi
23:35Yes, also for rebol!
23:36I have a very little project but really interesting in my mind. I'll discuss about it in the future.
23:36Also, thanks!

nedzadarek
08:15@GiuseppeChillemi
> Once the function is built internally I suppose the /extern a spec disappears.

It seems that this info is not needed* so they get rid of it (or just they haven't collected it).
* needed -> /local local-a ... part is needed because it's just a refinement (with associated words) and refinements, as other words, are included (and needed) in a spec.

I wonder if it would be very problematic to include /extern ... in a spec. I guess extern's words would have to be somehow excluded from the "refinement system".
GiuseppeChillemi
09:05I have never investigated what happens to the body source block after a function has been internally built. I suppose /extern is useful if you want to recreate a function association to a different word from the building blocks and not using the :get-word notation. Without this information the corresponding word set as extern wold be set as local in the new function.
09:06*recreate a function associating it to a diffente block
09:07Pardon, I am on mobile phone
09:07*different word
09:07Gosh!
AiguyGary_twitter
14:50On Red Windows is there a way of checking from Red if the speaker volume is muted or set to lowest volume. I call an external speech utility to verbally read a string passed from Red but if the user is muted or volume is set to lowest I would like to bypass that step since it take a few seconds verbally give the response and if the user is running silent that few seconds is wasted response time.
15:06I did a doc search on volume but did not get any hits https://doc.red-lang.org/en/datatypes/event.html?q=volume
pekr
17:44IIRC Red does not have sound api yet ....
giesse
19:00@nedzadarek can you show a case where preserving /extern is useful?
AiguyGary_twitter
19:02Thanks, yeah I realized that I just want sure if there wasn't a more generic Windows API call or system call that could be used to make the call. For instance this is how you would do it in C#
In case you wish to set it to an exact value using the Core Audio APIs:

using CoreAudioApi;

public class SystemVolumeConfigurator
{
private readonly MMDeviceEnumerator _deviceEnumerator = new MMDeviceEnumerator();
private readonly MMDevice _playbackDevice;

public SystemVolumeConfigurator()
{
_playbackDevice = _deviceEnumerator.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
}

public int GetVolume()
{
return (int)(_playbackDevice.AudioEndpointVolume.MasterVolumeLevelScalar * 100);
}

public void SetVolume(int volumeLevel)
{
if (volumeLevel < 0 || volumeLevel > 100)
throw new ArgumentException("Volume must be between 0 and 100!");

_playbackDevice.AudioEndpointVolume.MasterVolumeLevelScalar = volumeLevel / 100.0f;
}
}
nedzadarek
20:29@giesse help might use /extern ... info. As noted by @GiuseppeChillemi function creators might need that info when they use different or modified block... but I'm not sure what kind of *function creator* might need it as I strive from side effects.
GiuseppeChillemi
21:11Here comes my big **THANKS** to anyone:
I have ended just now the first phase of a long project started when I was a confused programmer (still I am !). Now I have a good set of functions which will help me into interacting with database data and ERPs.
The most satisfying part was to create a kit to convert a data, or block of data. It works selecting the sequence of conversion functions to apply from a map of data-types/sequence-name and then sequence-name/list-of-functions.
Each conversion sequence executes an user defined set of REDBOL functions (any number) on each data to convert.
Converted data is then returned as single value or into a block if a block of values has been originally passed as argument.

Just an example:

Here is a set rules and the corresponding list of functions.
*Each single function must have been created and "visible" in the current context*


conversion-sequences: [
		dupetext [string-surround "'" dupe]; ;sequence of functions with operator or no operator
		text1 [string-surround "'"]
		text2 [string-surround "-----"]
		foxdate [to-foxdate] 
		exadecimal [hex]
]

*(Note, each sequence has no TEMP storage for the result of the previous functions as it is composed on the run)*

Here is container for models: each model is NAME / TYPE - SEQUENCE-NAME couple

conversion-models: [
	base-map [
		string! [dupetext]
		integer! [exadecimal]
		date! [foxdate]
		]
]


Here is a simple conversion of a block of data using the base-map model

>> dataman/convert-data/model [12/11/2019 "duped"  33 55 "duped2"] 'base-map


Converted block is:

==["20191112" "'duped''duped'" #00000021 #00000037 "'duped2''duped2'"]


I will refine the kit in the future but again, thanks to everyone !
22:05@nedzadarek the building of the function is lossy and the specs-block does not contain anymore all the building specs. You can't recreate the original from its function state but you need the original "instructions".

greggirwin
17:47@GiuseppeChillemi very nice. Thanks for letting us know how you're using Red.
GiuseppeChillemi
19:04@greggirwin hope to release something useful for the community in the future. Actually I am still in alpha stage with heavy daily modifications. But I felt great emotion when yesterday converted automatically a row of data by its type and associated conversion sequence.
19:06Well, now I have a question about hybrid function/object.
19:09Could we have a function that called using its name FNCNAME is executed (with varying Arity) but also has an inner object or methods? I mean we can run the via FNCNAME/METHOD notation.
endo64
20:49Can't you do it by a simple object or a block?
>> b: reduce ['func1 func [a b] [a + b] 'func2 func [a] [a * 2]]
== [func1 func [a b][a + b] func2 func [a][a * 2]]
>> b/func1 4 5
== 9
>> b/func2 6
== 12

Or did I misunderstand?
GiuseppeChillemi
22:26 b should be a function to and eventually have arguments.
22:27So we can invoke:
b
b/func1
b/func2
gavr123456789_gitlab
22:53Hello, i wanna try redlang on arch. When i run its binary (from site) i get that
gavr@archlabs ~/D/T/RedLang> ./red-064 
Compiling compression library...
Compiling Red console...
/home/gavr/.red/console-2018-11-22-8164: error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory

Then i installed package libcurl-compat 7.65.3-1 but nothing change.
greggirwin
23:46@GiuseppeChillemi seems like normal refinements should work for dispatching that way.

9214
03:06@gavr123456789_gitlab have you read Arch-specific info on Download page? Did it help?
GiuseppeChillemi
09:04@greggirwin

I have tried:

>> a: func [] [b: func [c] [print c]]
== func [][b: func [c] [print c]]
>> a
== func [c][print c]
>> a/b
*** Script Error: a has no refinement called b
*** Where: a
*** Stack: a


And

>> a: func [/b func [c] [PRINT "hello"]][]
*** Script Error: c has no value
*** Where: func
*** Stack: a  

>> a: func [/b d: func [c] [PRINT "hello"]][]
*** Script Error: invalid function definition: d:
*** Where: func
*** Stack: a


No luck !


toomasv
09:18@GiuseppeChillemi May be something like this:
>> a: func [/b x /local d] [d: func [c] [print c] either b [d x][:d]]
== func [/b x /local d][d: func [c] [print c] either b [d x] [:d]]
>> a
== func [c][print c]
>> a/b 1
1

GiuseppeChillemi
19:02@toomasv So, without refinement you get the function as result, doesn't it ?
19:05I am trying to figure the limitations of this approach, if any.
toomasv
19:16@GiuseppeChillemi I followed your example above.
You might also do it this way:
context [b: func [c] [print c] set 'a func [/b x] [either b [self/b x][:self/b]]]
greggirwin
19:48@GiuseppeChillemi I was thinking something like this:
multi-func: function [args [block!] /a a-arg /b /inner "ignores /a/b"][
    private-fn: func [args] [print ["Inner" mold reverse copy args]]
    either inner [private-fn args][
        case [
            all [a b]   [print ["/a/b" mold args a-arg]]
            a           [print ["/a" mold args a-arg]]
            b           [print ["/b" mold args]]
            'else       [print ["default" mold args]]
        ]
    ]
]
multi-func [1 2 3]
multi-func/a [1 2 3] 'aaa
multi-func/b [1 2 3]
multi-func/a/b [1 2 3] 'aa
multi-func/inner [1 2 3]

Variable arity is the tricky part, so a block makes it easy.
GiuseppeChillemi
20:19Very tricky solutions but it's the only way to learn.
20:22@greggirwin is there a way to validate the args block as for standard args block and have errors if wrong arguments have been passed?
21:14@greggirwin I will be more specific: is there any way to use the built in function specs validator for a custom block or you have to create a new one ?
21:16@toomasv
> @GiuseppeChillemi I followed your example above.
> You might also do it this way:
>
> context [b: func [c] [print c] set 'a func [/b x] [either b [self/b x][:self/b]]]
>


I remember time ago you or someone else explained this way of creating functions but I can't find the chat thread. I will search again...

greggirwin
00:29@GiuseppeChillemi validating args could be done this way:
multi-func: function [args [block!] /a a-arg /b /inner "ignores /a/b"][
    private-fn-a: func [x [block!] y [string!]] [print ["Inner A" mold x y]]
    private-fn-b: func [x [integer!] y z] [print ["Inner B" x y z]]
    private-fn: func [args] [print ["Inner" mold reverse copy args]]
    either inner [private-fn args][
        case [
            all [a b]   [print "Can't use both /a and /b"]
            a           [do repend copy [private-fn-a] [args :a-arg]]
            b           [do repend copy [private-fn-b] args]
            'else       [print ["default" mold args]]
        ]
    ]
]
multi-func [1 2 3]
multi-func/a [1 2 3] "aaa"
multi-func/a [1 2 3] 1
multi-func/b [1 2 3]
multi-func/b ["a" 2 3]
multi-func/a/b [1 2 3] 'aa
multi-func/inner [1 2 3]

As you see, it leaks information about inner func errors, but it's an easy way to do it. We have some gists of refine and specialize examples out there, which are more involved. You *can* have total control, but it's more work.

Softknobs
21:35Hi, I am trying to figure out how "react" works and I can't understand why the following code is behaving differently for the same data type (here percent! but the same occurs with string!):
value: 100%

change-actions: func[][
	value: 50%	
]

view [			
	s: slider
	return
	text "s/data: "
	a: text react [a/data: s/data]	
	return
	
	text "value: "
	b: text react [b/data: value]
	return
	
	button "Change" on-click [do change-actions print value]
	button "Direct value change" on-click [value: 20% print value]
	button "Direct field change" on-click [b/data: 10%]
]

The first example with slider works: we bind a/data with s/data (percent!).
The second example with "value" does not work: when a click the "Change" button, value is updated but not b/data.
Any idea what is wrong with this code? Thanks.

AiguyGary_twitter
01:43What tasks still need to be completed for 6.5 to be released? I checked the Roadmap but not really clear from there.
9214
06:53@Softknobs I don't know why you expect it to work - value is not a reactive source.
quan-nh
06:57when asking for password from input console pass: ask "password: " how can I hide what user type?
9214
07:07@quan-nh nohow, ask doesn't have such feature.
quan-nh
07:30is there any way we can do that in red (with/without ask)
07:31*capture user input but turn off echoing
9214
07:37@quan-nh not yet, this is something that will be implemented only after 0.7.0 version. You can try your luck with Red/System in the meantime.
Oldes
09:45@quan-nh on posix in CLI console you can use prin "^[[8m" to turn off echo and "^[[28m" turn it on again.
09:58On windows, you could rewrite this C function to Red/System:
void Set_Echo_Mode(boolean set) {
	DWORD mode = 0;
	GetConsoleMode(Std_Inp, &mode);
	if (set) 
		SetConsoleMode(Std_Inp, mode | ENABLE_ECHO_INPUT);
	else
		SetConsoleMode(Std_Inp, mode & (~ENABLE_ECHO_INPUT));
}
09:59(but again, it would work only in CLI console version, not the GUI)
10:01Btw... here is related pull request: https://github.com/red/red/pull/2670
toomasv
10:41@quan-nh At least on Windows: view [field password]
9214
10:44@toomasv the question was about console interface.
toomasv
10:44@9214 Console was the first question. Second was:
> is there any way we can do that in red (with/without ask)
quan-nh
10:49yes, thank you all, I mean on console
10:51how can I proper combine prin "^[[8m" with ask function
prin "^[[8m"
pass: ask "password: "
prin "^[[28m"
print pass

hide the message as well
10:52same with pass: ask "password: ^[[8m"
bitbegin
10:54maybe we can add a refinement /password (feature) to ask: ask/password "password:"
9214
10:55@bitbegin Rebol has ask/hide for that.
bitbegin
10:57ok, i will try to add the feature
quan-nh
12:37:thumbsup:
Softknobs
17:37@9214 I know I am missing something obvious but looking at the first react example of the documentation (https://doc.red-lang.org/en/reactivity.html), my question is how is s/data supposed to be reactive in that case? Is related to the slider implementation? Both values are of the same type so I don't understand where the reactive mecanism is.
9214
18:09@Softknobs reactivity has absolutely nothing to do with datatypes. Your example works with slider because slider is a View face, which is a reactive object. Only fields of such objects can be sources of reactions. Both [documentation](https://doc.red-lang.org/en/reactivity.html) and initial [blog post](https://www.red-lang.org/2016/06/061-reactive-programming.html) on reactivity state that.
reactor: make reactor! [
    value: 50%
]

view [
    s: slider return

    text "s/data:"
    text react [face/data: s/data] return

    text "value:"
    b: text react [face/data: reactor/value] return

    field hint "Change" on-enter [reactor/value: to percent! face/data]
    button "Reset" on-click [b/data: 0%]
]
Softknobs
21:38@9214 Thanks for the example. Now I see it is really simple and I understand now my original question looked stupid... I think I got confused by the first documentation example stated as the "simplest form" of react and got stuck with it trying to figure out what was happening. Just my opinion, maybe it is not the best example to start with to explain how react is done in Red as part of the behaviour is hidden in the slider implementation. Though I understand the choice as it shows well the concept behind reactive programming. Thanks again for your help.
9214
21:40@Softknobs no problem, you're welcome.

9214
13:15@quan-nh check out latest build and see how ask/hide works for you.
quan-nh
13:21wow, it work perfectly. Thank guys!
SmackMacDougal
17:00Hey all.

Does anyone know why?

>> type? to-date [30 08 2019]
== date!
>> 1 + to-date [30 08 2019]
== 31-Aug-2019
>> ; expected the above

>> type? 2019/08/30
== date!
>> 1 + 2019/08/30
== 31-Aug-2019
>> ; expected the above

>> today: does [now/date]
== func [][now/date]
>> type? today
== date!
>> 1 + today
== 30-Aug-2019
>> ;  unexpected result above
9214
17:09@SmackMacDougal hello, which Red version are you using?
>> 1 + now/date
== 31-Aug-2019
>> today: does [now/date] 1 + today
== 31-Aug-2019
>> about
Red 0.6.4 for Windows built 26-Aug-2019/1:43:49+05:00 commit #a87243c
SmackMacDougal
17:10Red 0.6.4 for Windows built 21-Nov-2018/20:40:38-04:00 commit #755eb94
9214
17:11@SmackMacDougal I suggest you to use [latest build](https://static.red-lang.org/dl/auto/win/red-latest.exe) from now on. Grab it and see if the problem still persists.
SmackMacDougal
17:14Yeah, likely, the previous build had an error. They (Red team) should be better about incrementing version numbers.
9214
17:16@SmackMacDougal we don't follow semantic versioning. "Stable" release is just a snapshot of main development branch at a particular moment. Automatic build is updated on each new commit.
SmackMacDougal
17:17@9214 Sure, no problemo there Vlad. I can tolerate the confusion caused on their end, but many who will try Red for the first time will not.

9214
17:19@SmackMacDougal well, Red is an alpha software in the midst of development, so bugs and regressions are quite expected.
SmackMacDougal
17:20Yeah, I don't know about that @9214 .
17:20Say, do you know why the red console gets compiled to C:\ProgramData\Red and not to the folder where it is executed on Windows 10?
9214
17:44For the reference, I cannot reproduce [this](https://gitter.im/red/help?at=5d69563db156cd5e75af43cc) with stable build.
17:48@SmackMacDougal what you're executing is a toolchain binary. On the first launch it compiles GUI console in a default folder, and then just launches it on each subsequent run. You can compile console wherever you want directly from sources, if you want to.
GaryMiller
18:35So should regular users be downloading the Automatic builds periodically or should we wait for the stable releases? Is there a doc file that describes the install process for the Automatic build .exe or dos it just automatically replace any 6.4 stuff that it needs to?
9214
18:48@GaryMiller depends on how tight you want to be involved with Red. Some prefer to update on a daily basis, others are OK with waiting. Of course, automated builds contain new fixes and features, so IMO it's more preferable to stick with them.

There's no installation process. Toolchain compiles fresh console binary and that's it. You can still access older console versions directly in ProgramData/Red folder.
greggirwin
21:00I also can't reproduce @SmackMacDougal's problem.
AiguyGary_twitter
21:29@9214 Great! Latest Red build release didn't seem to break anything for me. Up to 52,901 lines now and nothing broke! Speed seems to be about the same too 8 seconds load time to get through the Lex before my view popped up but I know I'll be able to do more performance stuff later when the modules stuff and multithreading becomes available.
greggirwin
21:29Good to hear @AiguyGary_twitter, thanks.

SmackMacDougal
00:26Hey all. Will Nenad need to change the name of Red because of Node-RED, the flow-based programming tool that runs on Node.js and has the backing of IBM?

In many ways, Node-RED / Node.js is a crappier version of REBOL and by extension, Nenad's Red.

The whole idea of [Node.js](https://nodejs.org/en/about/) (out-of-the-browser Javascript interpreter) is to provide an an asynchronous, event-driven runtime to write scalable network applications in Javascript for the "Internet of Things" (IoT) that shuttles text strings as messages within implied meaning (JSON).

Carl called all of that the X Internet (executable Internet) way back when, 1999?

Of course, Carl Sassenrath ever ahead of his time. REBOL (and by extension Red) is an interpreter / virtual computer to run apps that pass messages in aesthetically-pleasing REBOL blocks with implied meaning as dialects and parsed by domain-specific rules to do IoT.

Node-RED itself is a flow-based development tool for visual programming that seems to be much like Yahoo! Pipes. ![](https://camo.githubusercontent.com/01ed64b01d73046a485ea82b645a3be529c64809/687474703a2f2f6e6f64657265642e6f72672f696d616765732f6e6f64652d7265642d73637265656e73686f742e706e67)

In short, has not the Javascript world re-invented a Stone Age version of REBOL with its Node.js (standalone prototype-based Javascript with its ugly syntax and built-in protocols HTTP, DNS, TCP, TLS/SSL, UDP and asynchronous processing) all to push around JSON, the REBOL-wannabe?

Node.js seems to want to be REBOL (Red) + Nenad's Uniserve. Perhaps The Red Community of Coders need to come together and produce a Node-RED like tool for anyone to code IoT stuff.

All of this Node.js / Node-RED makes me feel bad for Carl. His ideas have been ripped off in the worst way possible.

Anyway, it seems that Nenad's Red needs a name change. Thoughts? Also, full-blown async I/O for Red can not come fast enough.


00:34@9214 @greggirwin Of course you can't reproduce it. You are using a later build of Red.

We covered that as the fix.

I rectified the problem by using a later build of Red.

9214
00:36@SmackMacDougal no, the name will not change. Please keep this room on topic and move your IoT discussion elsewhere.

> You are using a later build of Red.

Unless you haven't noticed, I explicitly said that I used stable build from Nov 22.
SmackMacDougal
00:37@9214 Oh, I read this from you :

> I cannot reproduce this with stable build.

I didn't read in that sentence where you wrote the build number / date.

M'kay. Thanks.
greggirwin
00:43@SmackMacDougal as @9214 said, no name change is planned. There are a lot of Red name variants out there, with NodeRed being just one example. There is a lot of stuff coming down the pipe, pun intended. Red's reactive system is a general one, not limited to GUI use, and designed with a flow-based model in mind.
00:44If you haven't seen all the cool diagramming, flow, and other things @toomasv has built, you should check out his gists and repos.
SmackMacDougal
00:45Nice @greggirwin ! I am in awe of Nenad and his teammates.

Whenever I see Javascript code and JSON, I cringe. When I look at Red or REBOL, I smile.

Sweet tip Gregg, I shall check out his work right now!
01:57Does anyone know a way to write this better?

Red [
    Title:  "Get It Raw, aka git-raw"
    Date:   31-Aug-2019
    Name: none
    Version: 1.0.0
    File:   %git-raw.red
    Writer: ["Smack Mac"] 
    Purpose: {
        To provide DOing a download a script like on Rebol.org as a 
        teaching aid for those new to Red.
    }
    Notes: {
    }
    History: [
        0.1.0 [29-Aug-2019 {First Attempt} SM]
    ]
] 

git-raw: function [
	"Return a raw GitHub"
    url  [url!]
    /run "Do in console"
    /show "Show raw in browser"
    /keep "Download to disk" filename [file!]
][

    ;; make a url into an object!
	url: decode-url url

	;; remove the %blob path refinement
	remove/part find url/path %/blob length? %/blob

    ;; make the url 

comment {
	url: rejoin [ 
		https://raw.githubusercontent.com 
		url/path 
		url/target
	]
}
    ;; change the host
    url/host: 'raw.githubusercontent.com

    ;; reform the URL as url!
    url: encode-url url

    case [
        run  [do read url]
        show [browse url]
        keep [write filename read url ]
        true browse url
    ]
]
greggirwin
05:00
git-raw: function [
    "Return a raw GitHub"
    url  [url!]
    /run "Do in console"
    /show "Show raw in browser"
    /keep "Download to disk" filename [file!]
][
    url: copy url		; so we don't modify the original
    either find url "gist" [
        ; Hmmm, they seem to add extra hashes to the path for the raw gist url
    ][
        replace url "/blob" ""
        replace url "github.com" "raw.githubusercontent.com"
    ]
    case [
        run  [do url]
        show [browse url]
        keep [write filename read url]
        true [browse url]
    ]
]

url: https://github.com/red/code/blob/master/Showcase/eve-clock.red
git-raw/run url
SmackMacDougal
05:04I like it @greggirwin . It's shorter. Thanks. It is good always to see how someone else expresses ideas with Red.
GiuseppeChillemi
05:43@SmackMacDougal Yes, different points of view help us acquire new tecniques to solve the same kind of problems.
SmackMacDougal
07:14Indeed @GiuseppeChillemi. Here is yet another way:

git-raw2: function [
    "Return a raw GitHub"
    url  [url!]
    /run "Do in console"
    /show "Show raw in browser"
    /keep "Download to disk" filename [file!]
][

    ;; make a url 
    url: split-path copy url

   ;; remove the %blob path refinement
    replace first url "/blob" ""
    
    ;; make the url 
    url: rejoin [
        dirize https://raw.githubusercontent.com  
        second split first url "com/" 
        second url
    ]
    
    case [
        run  [do url]
        show [browse url]
        keep [write filename read url ]
        true [browse url]
    ]
]
nedzadarek
08:05@SmackMacDougal what is Nenad's Uniserve?
pekr
10:57Uniserve was/is a product of former Nenad's company, SoftInnov (https://www.softinnov.org/ ). It was a multi-protocol server, which later on became a base of his Cheyenne web server.
Palaing
14:50sounds like a bug:
param: 1
go: function [s] [
	print param
]
go "coucou"

works as expected; but
param: 1
go: function [s] [
	print param
	param: param + 2
]
go "coucou"

yields:
none
*** Script Error: + does not allow none! for its value1 argument
*** Where: +
*** Stack: go
9214
14:51@Palaing this is not a bug. Change function to func.
Palaing
14:52but why does it work in the first place?
nedzadarek
14:53@Palaing not bug, as per ? function:
> Defines a function, making all set-words found in body, local.

you make param local by using set-word!... and it seems that before you set it, function set it to none
14:53^ because param in the first function wasn't set, hence not local - it was global
9214
14:53@Palaing because in the first case you don't have param: inside function's body. function automatically collects all set-word!s and makes them local, with none as a default value.
Palaing
14:54@9214 @nedzadarek Ok thanks to both of you. I got it.
9214
14:56@Palaing check both functions with :go or probe and see how they differ.
>> function [s][print param]
== func [s][print param]
>> function [s][print param param: param + 2]
== func [s /local param][print param param: param + 2]
Palaing
14:59@9214 yes (shame on me) I used to know that difference, but was confused because in the first example, it still knew "param" when I only asked to print it
15:00@9214 => it can still read-access the global version in that case
9214
15:03@Palaing you mean the latter one? You can do that, either with system/words/param or by using /extern.
>> function [s /extern param][print param param: param + 2]
== func [s][print param param: param + 2]
Palaing
15:06@9214 ah yes, thanks; actually I meant that in
go: function [s] [print param ]

param is still readable as long as it has not been assigned somewhere (later) in the function
SmackMacDougal
15:11@nedzadarek **UniServe is a multiplexing engine for writing Internet apps in REBOL.**

Here is the link to it: [UniServe](https://www.softinnov.org/rebol/uniserve.shtml)

nedzadarek
15:18@SmackMacDougal @pekr thank you for links about Uniserve. They both seems similar (as for not experienced person). I wonder how good Uniserve was compared to "some older" and the newest node.js'.

quan-nh
05:18how to compile this script:
user: ask "username: "
print user


with red -r test.red I got the error Compilation Error: undefined word ask
05:19with red -r -e test.red it's compiled, but got this error when running Script Error: ask has no value
xqlab
07:44You have to include
**#include yourpath/red/environment/console/CLI/input.red**
9214
09:09@quan-nh [see here](https://github.com/red/red/wiki/%5BNOTES%5D-Compiling-with-console-functions---input,-ask).

ralfwenske
05:44I am a bit puzzled by this:
Red []
foreach year [2000 2001 2002] [
    print  [year]
    if year > 2001 [
        print  [" year > 2001 ->" year]
        break
    ]
]

it produces:
2000
2001
2002
 year > 2001 -> 2002

Could someone please tell me why I shouldn’t be (puzzled)?
pekr
05:48What is wrong with it?
ralfwenske
05:49
>> help break
USAGE:
     BREAK 

DESCRIPTION: 
     Breaks out of a loop, while, until, repeat, foreach, etc. 
     BREAK is a native! value.
pekr
05:51Break seems to apply with last block element in your case?
05:52Try adding 2003 in there to see if it breaks. I have not much experience with break though
05:53I am just on the smartphone, so cant try myself
ralfwenske
05:54@pekr thanks ! I got it : silly wiring in my brain :)
pekr
05:58cool 😀
ralfwenske
06:07Sorry - me again. When trying to short the original issue I focused on the wrong issue: it’s not about the break but a comparison
Red []
Settings: #(
    FinYears: #(
        2018 #('start 2017-07-01 'end 2018-06-30 'method none)
        2019 #('start 2018-07-01 'end 2019-06-30 'method none)
        2020 #('start 2019-07-01 'end 2020-06-30 'method none)
    )
)
foreach year keys-of Settings/FinYears [
    ?? year
    ?? Settings/FinYears/:year/method
    if none? Settings/FinYears/:year/method [
        print ["about to break"]
        break
    ]
]

for some reason the none? … doesn’t work
year: 2018
Settings/FinYears/:year/method: none
year: 2019
Settings/FinYears/:year/method: none
year: 2020
Settings/FinYears/:year/method: none

Any idea?
rebolek
06:10@ralfwenske if you try type? on your none, you’ll find out it’s word!, not none!
ralfwenske
06:13Thank you @rebolek if 'none = Settings/FinYears/:year/method gives me what I expect.
While at it: is there a way to init that map with none! ?
rebolek
06:16@ralfwenske if you want true none!, you can use literal form:
>> type? select #(key #[none]) 'key
== none!
ralfwenske
06:17Cool! thanks @rebolek (type? should become my friend…)
07:43A note regarding my above issue: I found that when saving and loading a map containing this
'method #[none] the *#[none]* turns into a word *none* (after load).
I will find another solution.
Oldes
07:49@ralfwenske
> the *#[none]* turns into a word *none* (after load).

Above is not true, it is not *word*, but none! value. Check this:
>> type? load "#[none]"
== none!
>> type? load "none"
== word!


07:53Hm... maybe I should not react after reading just the last message reading backwards.
rebolek
ralfwenske
07:55@Oldes
Red []
m: #('method #[none])
print ["none? m/method" none? m/method]
save %tmp.map m

m1: load %tmp.map
?? m1
print ["none? m1/method" none? m1/method]

produces:
none? m/method true
m1: #(
    method: none
)
none? m1/method false

and content of file:
#(
    method: none
)

Oldes
07:58@ralfwenske just in case you don't know it, mold/all is quite useful for above case... as there is not save/all implemented yet.
m: #('method #[none])
print ["none? m/method" none? m/method]
write %tmp.map mold/all m

m1: load %tmp.map
?? m1
print ["none? m1/method" none? m1/method]

none? m1/method true
ralfwenske
08:05@Oldes I think this *none* business is a rare special case. Or would you recommend to save maps in general with mold/alluntil save/all is implemented?
Oldes
08:07@ralfwenske hard to say... I think that it is not _rare special case_. It is same for common logic values too.
>> type? select load "#(a true)" 'a
== word!
>> type? select load "#(a #[true])" 'a
== logic!
08:08So if you want to be safe, using serialized form is better.
08:09Question is, if this serialized form should not be default for true, false and none values.
rebolek
08:10It's important to remember that none, false, true and so on, are just words that hold values, not values itself.
08:10If I use nic, ne, ano, it's equal. There is nothing special about above words.
ralfwenske
08:11Thank you @Oldes …so much to learn. Seems a good question to me too - as I naively thought this way about none.
Oldes
08:13The serialization is btw quite unfinished in Red. I think it works only in above mentioned cases.
rebolek
08:15@ralfwenske also consider using object! as it reduces its values:
>> type? select load mold object [a: none] 'a
== none!
Oldes
08:23@ralfwenske is there any reason why you are using:
#('start 2017-07-01 'end 2018-06-30 'method none)

instead of nicer:
#(start: 2017-07-01 end: 2018-06-30 method: none)
rebolek
08:24beauty is in the eye of the beholder :)
ralfwenske
08:27@rebolek I had (while only using the interpreter) objects containing functions like my object/find and it worked fine. I wasn’t able to compile this though.
From this experience I (subconsciously) learned that certain names/words are to be avoided for my own purposes.
When I code someboolean: true I have a type logic! - so in this context true doesn’t seem to be just a word…
And thanks for the object! hint. I guess I have to do more exploring rather than assuming :)
@Oldes no particular reason - I found it worked. But I agree start: … is nicer.
SmackMacDougal
17:06In this GUI, the intent is to capture tab key events from the user, i.e., tab to the next field.

GUI:

gui: layout [title: field 
...
        on-focus [face-name: 'title print ["title boca"]]
        focus
    tags: field 
...
        on-focus [face-name: 'tags  print ["tags boca"]]
...
    editor: area 
...
        on-focus [face-name: 'ed  print ["ed boca"]]
]


Here GUI actors is the property of the GUI object created above.
Commented out is one way to do it, actually my preferred way (case [ ]). The other way (switch event/key [ ] ) seems to be popular.

Ignoring tabbing in the area face seems prudent since users could have tabs #"^-" in their text. But why does shift tabbing fail out of an area? Even testing tabbing fails.

**See expressions commented as ;; fails!**

All other actions in the faces work.

gui/actors: [

...

    on-key: func [key event] [
        
	comment{
       case [
           ;; temporary until the app is solid
           event/key = escape [ unview ]
           ;; Function Keys
            
            is? event/key 'F1 [action/_help]
            is? event/key 'F12 [action/_clear]
            is event/key 'F8  [action/_save] 

           ;; tab down
           all [event/key = #"^-" is? face-name 'title] [set-focus tags]
           all [event/key = #"^-" is? face-name 'tags ][set-focus editor]

            ;; tab up
            all [event/shift? event/key = #"^-" is? face-name 'tags] [set-focus title]
            
            ;; fails! likely a quirk in Red and the area face!
           ;; all [event/shift? event/key = #"^-" is? face-name 'editor] [set-focus title]
       ]
}
                    
        switch event/key [

            ;; temporary until the app is solid
            ;; escape key
            ;; the word escape does not work with switch, but does with case and if
            #"^[" [ unview ]

            ;; Function Keys
            
            F1 [action/_help]
            F12 [action/_clear]
            F8  [action/_save] 

            ;; Control Keys
            #"^S" [ action/_save ]
            #"^V" [ print "markdown viewer" ]

            ;; tab
            #"^-" [ print "tabbed" 
                case [
                    ;; tab down
                    is? face-name 'title [set-focus tags]
                    is? face-name 'tags [set-focus editor]
                    ;; tab up
                    all [event/shift? is? face-name 'tags] [set-focus title]
                    
                    ;; fails! likely a quirk in Red and the area face!
                    ;; all [event/shift? is? face-name 'editor] [set-focus tags]
                ] ;;- case
             ] ;;- tab key action
        ] ;;- switch

    ] ;;- on-key

] ;;- actors


Note for those wondering about is? : func ["is the first equal to the second" a b][either equal? a b [true] [false]]
17:36Also, I've tested the up and down arrow keys. And up arrow fails from the type area face.

See expressions below and original post above.

;; up arrow through the faces
            up [
                case [
                    all [is? face-name 'tags] [set-focus title]

                    ;; fails
                    all [is? face-name 'editor] [set-focus tags]
                ]
            ]

            ;; down arrow through the faces
            down [
                case [
                    all [is? face-name 'title] [set-focus tags]
                    all [is? face-name 'tags] [set-focus editor]
                ]                
            ]
greggirwin
17:53@ralfwenske I'm late to the game, but this shows how break works in your first example.
foreach year [2000 2001 2002] [
    print  [year]
    if year > 2001 [
        print  [" year > 2001 ->" year]
        break
	print "Ooops!"
    ]
]
18:02As to other confusion, and for other readers, this is where Red is different from other langs, which means there are things to learn. The most important being when evaluation occurs. Some of that just takes time and experimentation. Once you stumble across a behavior, and say "That's funny." to yourself, it's time to play. Because of the way Red works, most issues can't be understood by "walking" the Red data being evaluated and imagining that you are the interpreter. Not so different from regular debugging, but a slightly different mindset, because you're going value by value, instead of instruction by instruction.

As you've seen now, there are key differences between maps and objects, but also similarities to leverage. It may seem confusing at times, how Red wants to normalize things (e.g. path access), but then have different behavior in types (maps don't eval their spec, while objects do). This is intentional and by design. Part of Red is using datatypes effectively, for clarity and power. Technically, Red could get by with words, blocks, and strings, which would make it very much Lisp/Logo-like. The other types are sugar, much as C adds structures and control flow to make it nicer than ASM for people.
toomasv
18:42@SmackMacDougal One [tabbing experiment](https://gist.github.com/toomasv/4f08339e854669247d4f34aa7a8c1a3b). May be can be of help.
SmackMacDougal
19:29@ralfwenske

First, let's do something simpler:

>> b: ['jolly none]
== ['jolly none]
>> type? b
== block!


The Red interpreter sees a block! When asked what it sees in the second position, it sees a word!

>> type? b/2
== word!


Now, tell Red-I to evalute it.

>> type? reduce b/2
== none!

The Red-I now sees a none! because you told it get the value, i.e., you told it to evalute the word!.


Now, let's make a map from b:

>> m: to-map b
== #(
    jolly: none
)


What does Red-I see?

>> type? m
== map!


From the red-lang.org site:

> A map represents an associative array of key/value pairs...Unlike the hash! datatype, a map is not a series, so does not have a concept of offset or positions.

This should fail because a map! is not a series!

>> type? first m
*** Script Error: first does not allow map! for its s argument
*** Where: first
*** Stack: first

So we can access values from a map! with path notation or select.

>> m/jolly
== none
> select m 'jolly
== none


What does Red-I see?

>> type? m/jolly
== word!
>>

You have not told Red-I to evaluate the value associated with the key. But when you do:

>> type? reduce m/jolly
== none!
>> none? reduce m/jolly
== true

So to get your foreach to work, reduce


>> foreach year keys-of Settings/FinYears [
[ ?? year
[ ?? Settings/FinYears/:year/method
[ if none? reduce Settings/FinYears/:year/method [
[ print ["about to break"]
[ break
[ ]
[ ]
year: 2018
Settings/FinYears/:year/method: none
about to break
>>
`
In Red (and REBOL), you must request evaluation with evaluator words. Otherwise the interpreter merely sees datatype!(s).
19:31@toomasv Thanks Toomas! I shall take a look at that right now!
toomasv
19:47@SmackMacDougal You are welcome!
endo64
20:07> @ralfwenske also consider using object! as it reduces its values:
>
> >> type? select load mold object [a: none] 'a
> == none!
>


@rebolek This is not correct, you get none because select didn't find 'a:
>> type? select load mold object [a: none] 'xxxx
== none!
>> type? select load "a b" 'c
== none!
toomasv
20:29Yes, should be
type? select do load mold object [a: none] 'a ; or `first reduce` instead of `do`
dander
22:03@SmackMacDougal regarding your is? comment -

is?: func [a b][either equal? a b [true] [false]]

can be reduced to this (since every expression returns a value):

is?: func [a b][equal? a b]

which can be reduced to (if you prefer to use is? instead of equal?):

is?: :equal?
greggirwin
22:12Is? can be a tricky term. It sound more like an identity func (same?) or a category func (like typeset checking), than equality. But that is for Red as a GPL. In a dialect it can be useful for different meanings, including assignment in non-predicate form (is).
SmackMacDougal
22:29@toomasv I appreciate much you pointing me to your example.

You gave me an idea. I can hide GUI data in an object! inside the actors object!.


main-screen/actors: make object! [

    joker: context [
        face-name: none
        name: func [
            n
        ][
            face-name: n
        ]
    ]

...


which then can get set when the face gains focus (see: face definition in the VID block!)

title: field 

...
        on-focus [print ["title boca"]         
            main-screen/actors/joker/name 'title
            print rejoin ["the actor on stage:" main-screen/actors/joker/face-name]
        ]
        on-unfocus [print ["title unboca"]]
...


> Ignore all that print stuff, please. That is how I debug.

And then I can achieve my goals of meeting users' expectations:

1. down from fields skips to next field
2. ctrl+up and ctrl+down cycle through the faces
3. home takes the user to the front of a line of text in the "editor" (face/type: 'area)
4. end takes the user to the end of a line of text in the editor.
5. ctrl+home takes the user to the start of text of the editor.
6. ctrl+end takes the user to the end of text in the editor.
7. down takes the user to the next line of text in the editor

Points 4-7 already come free with the face/type: 'area and likely match the expectations of users of Windows 10 editors, at least.

So now it is easy. There is a quirk with HOME when using CTRL+SHIFT.

on-key: func [face event] [

        switch event/key compose [

            ;; temporary until the app is solid
            ;; escape key
            ;; the word escape does not work with switch, but does with case and if
            ;; #"^[" [ unview ]
            (escape) [ unview ]

            ;; up arrow through the faces
            up [
                case [
                    all [event/ctrl? is? main-screen/actors/joker/face-name 'tags] [set-focus title]
                    all [event/ctrl? is? main-screen/actors/joker/face-name 'editor] [set-focus tags]
                    all [event/ctrl? is? main-screen/actors/joker/face-name 'title] [set-focus editor]
                ]
            ]

            ;; down arrow through the faces
            down [
                case [
                    is? main-screen/actors/joker/face-name 'title [set-focus tags]
                    is? main-screen/actors/joker/face-name 'tags [set-focus editor]

                    all [event/ctrl? is? main-screen/actors/joker/face-name 'title] [set-focus tags]
                    all [event/ctrl? is? main-screen/actors/joker/face-name 'tags] [set-focus editor]
                    all [event/ctrl? is? main-screen/actors/joker/face-name 'editor] [set-focus title]
                ]                
            ]

            ;; Function Keys
            
            F1 [action/_help]
            F12 [action/_clear]
            F8  [action/_save] 

			;; **quirk alert!**
			;; with text in the area and a user were to hit CTRL+SHIFT+HOME
			;; Red highlights to the first position of the first row from the cursor position
			;; leaves the text highlighted and moves focus to the first field.
			
            ;; HOME [ if all [event/ctrl? event/shift?] [set-focus title] ]
            
            PAGE-UP [ if all [event/ctrl? event/shift?] [set-focus title] ]
            PAGE-DOWN [ if all [event/ctrl? event/shift?] [set-focus editor] ]

            ;; Control Keys
            #"^S" [ action/_save ]
            #"^V" [ print "markdown viewer" ]

            (tab) [ print "tabbed" 
                case [
                    ;; tab down thru faces
                    is? main-screen/actors/joker/face-name 'title [set-focus tags]
                    is? main-screen/actors/joker/face-name 'tags [set-focus editor]
                ] ;;- case
             ] ;;- tab key action
        ] ;;- switch

    ] ;;- on-key
...




22:46@dander Thanks Dave. is? and isnt? were copied from an old REBOL instance. I inherited those. For meaning , it is clearer to me than equal? and not-equal?. And it is a few less keystrokes.

But hey, good catch!

ralfwenske
03:18Thank you all. In essence what I missed was the fact that in maps the values are not being evaluated (as opposed to objects) …and serialization being unfinished.
endo64
06:01@ralfwenske as opposed to objects part may not correct, see my comment above.
AndreasWagnerBerlin
09:31I would like to ask, whether the following text transformation is possible with Red and Parse.
The input is a text as per following simplified example:
(rfid OR (radio 1W frequenc+))
The output shall be a text with changes as per following example:
(rfid OR (radio SEQ2 frequenc*))
In general the text is much longer and has different elements to be changed.
Questions: does red support this transformation? Is parse the right approach? Are there any reference implementations?
Thank you in advance.
toomasv
10:13@WaBerlin_twitter It is perfectly possible with parse. You can use e.g. change as in

parse text [
    any [{radio } change {1W frequenc+} {SEQ2 frequenc*} 
|   skip]
]


On phone now, can’t check, but something like this should work.
10:32Checked:
text: {(rfid OR (radio 1W frequenc+))
something else
(rfid OR (radio 1W frequenc+))}

rule: [any [{radio } change {1W frequenc+} {SEQ2 frequenc*} | skip]]

parse text rule
;== true
text
;== {(rfid OR (radio SEQ2 frequenc*))^/something else^/(rfid OR (radio SEQ2 frequenc*))}
AndreasWagnerBerlin
11:02@toomasv thank's a lot. That is a good starting point.
toomasv
11:03You are welcome!
AndreasWagnerBerlin
18:13I do have a follow-up question regarding flexible handling of input.
The following text input shall be transformed:
(rfid 2W radio) OR (rfid 10W frequency) ==> (rfid SEQ2 radio) OR (rfid SEQ10 frequency)
My approach is as follows:
rule: [ any [
     change {W} {SEQ}
    | change {1W} {SEQ1}
    | change {2W} {SEQ2} 
    ...
    | change {99W} {SEQ99}
    | skip ]
]

This is not appropriate, as the number could go up to {99W}.
Is there a clever way to cope with different inputs {W}, {1W} .. [W99} and transform them into {SEQ}, {SEQ1}, ... {SEQ99}.
I tried with the copyand setOperator, but failed.
Thank you in advance.
9214
18:31
text
parse text: {
	(rfid 2W radio) OR (rfid 10W frequency)
}[
	any [
		"rfid" space
		change [copy match to #"W" skip] (rejoin ['SEQ match]) 
		| skip
	]
]

print trim/lines text
19:01Though, I'd recommend to stick with parse/case and to be careful with to, but the main logic stays the same.
greggirwin
19:14Another approach:
s1: "(rfid 2W radio)"
s2: "(rfid 10W frequency)"
s3: "(rfid 999W frequency)"
s4: "(rfid wwW frequency)"
s5: "(rfid 99 frequency)"

digit=: charset "0123456789"

mod-str: func [input /local num= =num mark][
	input: copy input
	num=: [copy =num some digit=]
	parse  input [
		any [
			["rfid " num= change #"W" "SEQ" insert =num]
			| skip
		]
	]
	input
]

print mod-str s1
print mod-str s2
print mod-str s3
print mod-str s4
print mod-str s5
19:22Should we start a parse cookbook wiki page?
19:23This is a simple reordering task that can be generalized with a few examples, or even a smarter func that takes parameters for the parts to reorder.
19:25@AndreasWagnerBerlin, if you'd like to do an initial entry on a new page, with this example, others can add to it later.
SmackMacDougal
20:00Does anyone know how to set the default opened tab on a tab-panel face?
endo64
21:41
view [size 600x400 tab-panel 500x300 select 2 [
  "one" [button "one"] "two" [button "two"] 
  ] 
]

SmackMacDougal
21:42@endo64 Thank you Semseddin. select n
greggirwin
21:54It's listed [here](https://doc.red-lang.org/en/vid.html#_select), but should we add a note to the tab-panel section specifically? This is the balancing act of making info available, while not filling docs with redundant elements that make it all much larger. The difference in utility comes from needing a very specific answer, and not wanting to read the parts that lay out generally applicable features.
endo64
21:57We can update this part "Sets the selected facet of the current face (selected tab of a tab-panel, ...)" current explanation doesn't give much hint what "selected facet of the current face" is.
greggirwin
22:00Good point. Agreed.
SmackMacDougal
22:02@greggirwin Thanks Gregg. I keep docs open in tabs all of the time, the [official](https://doc.red-lang.org/en/vid.html) and [helpin](http://helpin.red/).

I guess in the TOC in the official threw me off because it lists wrap as a major heading and well that did not seem like it had anything to do with my goal.

7. wrap
7.1. no-wrap


but this did:

8. Panels
8.1. panel
8.2. group-box
8.3. tab-panel


9214
22:03> current explanation doesn't give much hint what "selected facet of the current face" is

Uhm... selected facet, quiet literally? It's a reference documentation, not a user guide, so I disagree with adding nuanced explanations and examples all other the place, as it supposed to be succinct and technical.
22:11@greggirwin by the way, documentation formatting is way off. Scroll thru 6.1.12 section - code fences are all ragged, and wrap somehow became a top-level heading. I'm not sure if this affects other pages.
greggirwin
22:12@9214 indeed. Please file a ticket to fix formatting.

AndreasWagnerBerlin
05:17
parse wikibookand I am happy to start filling an existing Wiki page.
However someone has to setup such a Wiki and set the R/W rights (I simply do not know how to do that in the GitHub context).>
greggirwin
05:32Thanks @AndreasWagnerBerlin. I'll do that tomorrow, if nobody beats me to it.
18:01Here you go @AndreasWagnerBerlin: https://github.com/red/red/wiki/Parse-Cookbook
18:02The github wiki makes it pretty easy. You should see and Edit button and a New Page button in the upper right area. Holler with any questions, and then we can walk you through setting up a new page next time.
GiuseppeChillemi
18:49@greggirwin 👏👏👏

melcepstrum
10:29I'm learning red and i'm trying to make a vector but I must be doing something wrong
>> a: [float! 32 5] 
== [float! 32 5]
>> x: make vector! a
== make vector! [float! 32 [0.0 0.0 0.0 0.0 0.0]]
>> N: 5 a: reduce [float! 32 N]
== [float! 32 5]
>> x: make vector! a
*** Script Error: datatype! type is not allowed here
*** Where: make
*** Stack:

toomasv
10:36@melcepstrum Consider this:
>> type? first a: [float! 32 5]
== word!
>> N: 5 type? first a: reduce [float! 32 N]
== datatype!

But
>> N: 5 a: reduce ['float! 32 N]
== [float! 32 5]
>> x: make vector! a
== make vector! [float! 32 [0.0 0.0 0.0 0.0 0.0]]
melcepstrum
10:38ok, i get it, thanks
toomasv
10:38:+1:
melcepstrum
10:43I have implemented FFT in Red and Red/System. Red/System is about 50 times faster than (compiled) Red
10:44can i share ma code here or is there a better place?
toomasv
11:06Short code is OK here. Longer code is may be better to put in a gist and have a link here.
melcepstrum
11:22https://gist.github.com/melcepstrum/8ab63dc26c0b4257ad827f14ca2dfef1
toomasv
12:01@melcepstrum Nice, thanks! Will study that.
ldci
12:48@melcepstrum Thanks for your code:)
nedzadarek
18:51@melcepstrum even compiling (just Red's) yields faster code. Thank you for your code. As noted above, gists are nice for something "little longer" or you just want to keep it. A github's repository might be better place when you want to add some other code, readme, license etc. or a code is longer.
@toomasv do you know Fourier Transformations? If yes and if it is not too much problem could you make some presentations (examples) using @melcepstrum 's FFT implementation? It would be nice to see how and where it is used.
toomasv
19:11@nedzadarek Nope, that's why it's so interesting!
greggirwin
19:35@melcepstrum thanks for that! +1 to @nedzadarek's request for examples to go with it. As the author, can we impose on you @melcepstrum to provide some?
nedzadarek
21:04@toomasv You have nice attitude. Well, it's not a simple topic so take your time. Please "@" me when you have something. Thank you.

greggirwin
02:58Thanks @AndreasWagnerBerlin, for your additions to the parse cookbook page!
SmackMacDougal
03:22If one has a block! of dialect like this (yes, it's a dialect even though some of those words look like set-word!(s))

[name: "Bob Soe" street: none city: none phone: none]


it is easy to create an object:

>> set-word-dialect: [name: "Bob Soe" street: none city: none phone: none]
== [name: "Bob Soe" street: none city: none phone: none]
>> o: make object! set-word-dialect
== make object! [
    name: "Bob Soe"
    street: none
    city: none
    phone: non...


But if a dialect is a word / string-looking dialect, trying the above fails.


>> word-string-dialect: [name "Bob Soe" street none city none phone none]
== [name "Bob Soe" street none city none phone none]

>> o: make object! ws-dialect
*** Script Error: name has no value
*** Where: make
*** Stack:


One way to handle this would be through a series of datatype transformations since a to map! type conversion converts pseudo name-value pairs like those shown in the word-string-dialect.

to-object: function [
    {Return an object! from a map! or block!}
    indat [map! block!]
][
    if all [
        block? indat
        not set-word? first indat
    ][indat: to-block to-map indat]
    make object! indat
]


Another way would be to loop through the block changing the odd words to set words.

to-object: function [
    {Return an object! from a map! or block!}
    indat [map! block!]
][
	if block? indat [
		either not even? length? indat [
			return make error! "block is not of even length"
		][
			forskip indat 2 [
				change indat to-set-word indat/1
			]
		]	
	]
	make object! indat
]


Yet another way would be using parse this:

to-object: function [
    {Return an object! from a map! or block!}
    indat [map! block!]
][
	if block? indat [
		parse indat [ some [ w: word! any-type! (poke w 1 to-set-word first w)] ]
	]
	make object! indat
]

Which would be the better way (your subjective belief) and why? To learners of Red, this might help give insight to leveraging the language better.
greggirwin
03:30My gut response:
make-obj: func [
	spec [block! map!] "More forigiving than just MAKE"
][
	object either map? spec [to block! spec][
		collect [foreach [k v] spec [keep reduce [to set-word! k :v]]]
	]
]
make-obj #(a 1 b 2)
make-obj [a 1 b 2]
03:32Then look at what kind of cases and extra validation you want to do. This could be interesting in a number of ways. Odd length lists imply none, or do all words except 'none become keys, so you can list just keys? For maps, string keys magically vanish, which could be a feature, depending on how you structure your data. That is, you could have maps that have elements meant to become part of objects made from them, and other/meta data that doesn't.
SmackMacDougal
03:35@greggirwin Nice Gregg! Of course, you would do it that way because your solution leverages collect. ;-)

Your commentary gives me much to consider, Gregg. Thanks.

03:53I see truly the merit of your soloution.
giesse
06:04This is a safe way to convert a map! to object!: https://github.com/giesse/red-topaz-parse/blob/master/ast-tools.red#L243
(The others posted above will fail on some edge case scenarios, which you may or may not care about.)
06:05Hopefully one day we'll be able to just use to object!
SmackMacDougal
22:38@giesse Neat!

rgchris
02:34What are the pitfalls of saying construct body-of map ?
greggirwin
02:36
>> m: #(a 1 b 2 "c" 3)
== #(
    a: 1
    b: 2
    "c" 3
)
>> body-of m
== [
    a: 1 
    b: 2 
    "c" 3
]
>> construct body-of m
== make object! [
    a: 1
    b: 2
]
rgchris
02:39Ah—I thought the problem was just with words/set-words...
gltewalt
03:32is to-csv suppose to include newline characters in the output string?
giesse
05:55@rgchris it will fail on some datatypes
05:56
>> m: #(a: b: c: 2)
== #(
    a: b:
    c: 2
)
>> construct body-of m
== make object! [
    a: 2
    b: 2
    c: 2
]


one example
05:57using my code linked above:
>> map-to-object m
== make object! [
    a: b:
    c: 2
]
toomasv
08:39@giesse But there is problem, e.g.:
>> map-to-object #(a 1 "b" 2 c 3)
== make object! [
    a: 1
    c: 2
]

May-be so:
foreach [word value] body [
		if set-word? :word [
			append words word
			append/only values :value
		]
    ]
rebolek
08:49@melcepstrum Thanks for your FFT code! I also did FFT, so I'll try to do some tests to compare speeds.
endo64
10:43> is to-csv suppose to include newline characters in the output string?

@gltewalt It is:
>> probe to-csv [[a b] [1 2]]
"a,b^/1,2^/"
rebolek
10:45@endo64 thanks
@gltewalt yes, do you want something else there instead?
gltewalt
15:35No, just checking
rgchris
15:41@giesse Hm, that seems to me a failing of CONSTRUCT. What is the benefit of CONSTRUCT working that way?
15:44On considering strings—this seems bad practice as you're allowing the same key to be encoded in different ways. map-to-object #(a 1 "a" 2 3) becomes messy.
giesse
18:32@toomasv map-to-object requires all keys to be word!; in the more general case I suspect that causing an error for non-word keys would be a better approach, but otherwise the behavior becomes clearly application-specific.
18:34@rgchris I was surprised by construct behaving that way as well. I think I posted about it at some point. IMHO construct should not try to be smart in any way, but there are arguments for the current behavior. (In fact, if you look at the changes history of the file I linked above, you'll see I had to stumble over those issues and rewrite that code a few times.)
18:35In any case, the proper solution would be a native to object! implementation for map!.
greggirwin
19:11I don't see construct/object as trying to be smart, but trying to be flexible. Simply a design choice. Object specs not being strictly key-value pairs is close to standard evaluation semantics and can be viewed as a dialect of sorts.

@rgchris in Red I don't think it's messy, but it's Red-like. Using different datatypes as keys is a feature, just as if you were using a block. Maps have different semantics and limitations of course, but suppose you have a dialect you're processing, and values you come across map to keys in a map!. If maps are limited to only word! keys, you lose a lot of power.
rgchris
19:19@greggirwin Usage of map! is obviously more free-form than object! is great. Where it gets messy is when you are working with the types of data (shall we call it 'form data'?) where you have to normalise keys before processing them (which, again, I thought was the intent of the OP)—especially in cases where your goal is to corral them into objects.
greggirwin
19:30We always have to make those choices. Almost always, Red should not enforce those restrictions, convenient as that may seem, because you *can* enforce them at higher levels, but not so much the other way around. What happens then is you fall back to blocks and build your system on that foundation. This way, normalizing, however you want to do it, should be just some small helpers.
rgchris
20:31construct is weird because the expectation is that content is unevaluated (except according to the spec, none/true/false)—set-word chaining seems to break that expectation.
20:32@greggirwin Right, I'm not suggesting Red enforce those restrictions. That doesn't mean it's not messier in these cases than not.
greggirwin
20:49Something to document, certainly.
20:51The problem, though, is that having construct behave differently would make its specs incompatible with object, so it wouldn't just be a "safer" drop-in replacement.
rgchris
21:32The problem then though is not having a complement to body-of (which is not necessarily how I'd expect construct to work, but I don't see why it shouldn't):
>> foo: object [a: to set-word! 'b c: 'd]
== make object! [
    a: b:
    c: 'd
]
>> bar: construct body-of foo
== make object! [
    a: 'd
    b: 'd
    c: 'd
]
greggirwin
21:51What is the problem use case?
21:53It's true you can create specs that don't round trip, but it's simply a different design choice, right, not a clear win? You have to give up one to get the other.
rgchris
22:07One—I'd say it's unexpected behaviour (I was surprised it didn't work!), two—was reflecting on @giesse's edge case above. construct is never quite going to resemble object, so why have *some* evaluative behaviour at the cost of an expensive round-trip?
>> construct [a: b: func [][]]
== make object! [
    a: 'func
    b: 'func
]

*(am also not saying that round-trip is worth it for its own sake, just that it is a better model for how you'd expect a non-evaluating object creator to work)*
22:11On the other side, I can only see minor benefits from the pseudo-evaluative behaviour of construct [a: b: c: 'd], but I see it as a cute hack with an expensive trade-off.
greggirwin
22:28How many times, and in what case have people tripped over this in real life? That's my question. To me the current behavior is *extremely* easy to explain and reason about. Set-words behave as set-words behave.
>> construct [a: b: c: 'd]
== make object! [
    a: 'd
    b: 'd
    c: 'd
]
>> reduce [a: b: c: 'd] print [a b c]
d d d

What is the expensive tradeoff? What are the concrete examples where this causes issues?
rgchris
22:29The examples above! Every one is using iterator/iterators/collect to solve a common transformation goal...
greggirwin
22:30So you're talking about the map to object transformation, correct?
rgchris
22:30The OP was looking to go from [word "Value" word "Value"] to an object. Can do that with construct body-of to map! block with quirks.
22:34The problem with the quasi-evaluative behaviour is that it trips you up later on is all.
greggirwin
22:36Let's see if we can nail this down:
1) Object and constructare consistent today, agreed (Y/N)?
2) If we change things to work how you want, they are no longer consistent, agreed (Y/N)?
3) Where it causes a problem for you today is when a *value* is a set-word!, agreed (Y/N)?
22:394) The problem is not that you can't use set-word! values, but that one-liner conversions (i.e. the body-of approach) don't work with them, agreed (Y/N)?
rgchris
22:421) I'd argue no, 2) see 1, and 3) yes, 4) that is one aspect, sure.
greggirwin
22:42OK, for 1, how are they inconsistent?
22:43Here's my argument as to why they are:
>> object [a: b: c: none]
== make object! [
    a: none
    b: none
    c: none
]
>> construct [a: b: c: none]
== make object! [
    a: none
    b: none
    c: none
]
rgchris
22:44Here's an example where they're not:
>> object [a: 1 + b: 2]
== make object! [
    a: 3
    b: 2
]
>> construct [a: 1 + b: 2]
== make object! [
    a: 1
    b: 2
]
greggirwin
22:45Excellent!
rgchris
22:45The veneer of evaluative behaviour causes misconceptions, whereas a constructor that has simple rules [set-word! value!] has fewer surprises.
greggirwin
22:45This, to me, is a different issue entirely.
22:47This is an example where construct should complain about a bad spec. Is that what you expect?
rgchris
22:49I would, though that's an example that should choke. A better ambiguous example might be:
[foo: uppercase bar: "baz"]
greggirwin
22:50How is that ambiguous?
rgchris
22:50You get very inconsistent results between construct and object.
greggirwin
22:51Of course you get different results, but they're not inconsistent in their handling of the spec.
rgchris
22:55The inconsistency comes from creating a separate evaluation model for construct instead of being non-evaluative as stated.
greggirwin
22:55I'll retract my statement about construct [a: 1 + b: 2] being a bug though. It's consistent with object as well.
22:56The evaluation model (processing) of the spec is the same.
>> object [a: 1 '+ b: 2]
== make object! [
    a: 1
    b: 2
]
>> construct [a: 1 + b: 2]
== make object! [
    a: 1
    b: 2
]
>> reduce [a: 1 '+ b: 2]  print [a b]
1 2
22:57Which is entirely consistent with normal Red evaluation.
rgchris
23:04From that perspective, then 1) yes, they are consistent and 2) yes.
greggirwin
23:06Great, so can we agree that changing things would be a lateral move, different but not "better"?
rgchris
23:06I would say better :)
greggirwin
23:08i.e. more consistency with map and construct but less with construct and object.

I'll say current is better because map! *is* different, while the others both produce objects.

rgchris
23:08And different from the product of body-of object.
greggirwin
23:10What's different from what?
rgchris
23:10Consistency would dictate that body-of construct [a: b: c: 10] => [a: b: c: 10]
greggirwin
23:10No it wouldn't. That's what spec-of is for, if implemented for objects.
23:11But that means carrying it around.
23:12The resulting object, whether from object or construct is an artifact of evaluation. Just as you can't get back at the original after you reduce a block.
rgchris
23:13Context aside, that is what I would expect from construct—that's where I see the usefulness of that method.
greggirwin
23:16How would that work, without object! keeping its original spec? And I will ask again, what are the use cases for this, or where has it caused problems for people in real life.
rgchris
23:39I mean, there's the points in this thread where I and at least one other have said it leads to unexpected behaviour—doesn't that count as a real-life problem? I get the point you make that there's a certain type of consistency, but you've created a wholly separate evaluation model labelled as 'unevaluated' and thus inconsistency from another perspective. Use cases I've had (that I can recall) are akin to the OP and I'm not certain they still apply, though no-one has questioned the use of object! in this case (where perhaps map! would be more appropriate?). Then there's the other solutions posted as well that involve not-always intuitive iterative methods that would lead me to suggest this is a use case.
greggirwin
23:43> unexpected behaviour—doesn't that count as a real-life problem?

No. Your expectations are different from mine, and we can't all get what we expect in that light.
rgchris
23:45Hm. Ok.
greggirwin
23:45When something unexpected happens, the thing to do is step back and see if it makes sense upon reflection (no pun intended). If the point then seems worth arguing, we have https://github.com/red/red/wiki/%5BDOC%5D-Red-Should...-(Feature-Wars) where things can be weighed.
23:53And many things we can "fix with language" (i.e. docs).

AndreasWagnerBerlin
14:12I have a beginner's question regarding parse. How do I parse the following strings:
{abc def OR}
{abc def OR }

My goal is to detect OR or OR with blank at the end of a string. I am not interested in any OR somewhere else in the string.
Could not find any hints in parse documentation.
toomasv
14:49@WaBerlin_twitter Does {OR} opt space end work?
15:28Do you need case detection too?
>> OR-rule: [{OR} opt space end (print "{OR} detected")]
== ["OR" opt space end (print "{OR} detected")]
>> parse {abc def OR } [some [OR-rule | skip]]
{OR} detected
== true
>> parse {abc def OR} [some [OR-rule | skip]]
{OR} detected
== true
>> parse/case {abc def Or} [some [OR-rule | skip]]
== true
endo64
15:40He probably needs a space before OR too to prevent detecting OR in fork orc or, just guessing.
toomasv
17:03@endo64 True, space before would be good, but not necessary in your example :)
>> parse {abc orc def OR } [some [OR-rule | {or} (print "stumbled on {or}") | skip]]
stumbled on {or}
{OR} detected
== true
>> parse {abc orc def} [some [OR-rule | {or} (print "stumbled on {or}") | skip]]
stumbled on {or}
== true
>> parse {abc def ORC } [some [OR-rule | {or} (print "stumbled on {or}") | skip]]
stumbled on {or}
== true
AndreasWagnerBerlin
17:40Dear Toomas, thank you for explanations. You solved my problem.
toomasv
18:06@AndreasWagnerBerlin You are welcome!

SmackMacDougal
18:34Hey all! Has anyone implemented autocomplete using a face type 'field? If so, is your code online so I can read it and learn from it?

Here is what I am trying to achieve:

- I have a small data file of blocks [string! url! word! word!]
- In most cases, as the user is typing text that gets closer to matching one of the strings, I'd like for them to tab through to complete it, which will then select the URL behind the scenes, ready to accept the next bit of input in the field as the search string to be added to the url.
- They should see a drop down ( I don't know if this possible or that it must be implemented not as a field but as a drop down) as they type which winnows away possible selections as they get closer to their goal.

I see this kind of UI functionality in the Javascript world. I've implemented it in toy web UIs, but will Red support this?
greggirwin
19:00I can't find one real quick, and my 1 minute hack didn't work. Have to do other things, but will check back later if nobody else jumps in.
dander
19:47@SmackMacDougal maybe not a minimal example, and doesn't display the options, but you could look at the [Red Console sources](https://github.com/red/red/blob/master/environment/console/auto-complete.red).
toomasv
20:24@SmackMacDougal General idea, but unfinished (sorry, have to go):
blk: [
    ["Blog" http://www.red-lang.org] 
    ["Download" http://www.red-lang.org/downloads] 
    ["Documents" http://www.red-lang.org/documents]
] 
view [
    at 10x33 tl: text-list hidden data [] on-change [
        dd/text: copy pick face/data face/selected 
        face/visible?: no
    ] 
    dd: drop-down focus on-change [
        collect/into [
            foreach b blk [
                case [
                    empty? face/text [clear tl/data tl/visible?: no] 
                    find/match b/1 face/text [keep b/1]
                ]
            ]
        ] clear tl/data 
        tl/visible?: not empty? tl/data
    ] on-key [
        switch event/key [
            down [tl/selected: either tl/selected = -1 [1][max tl/selected + 1 length? tl/data]] 
            up [tl/selected: either tl/selected <= 1 [-1][tl/selected - 1]]
        ]
    ] on-enter [
        if all [tl/selected > 0 tl/visible?] [
            face/text: copy pick tl/data tl/selected 
            clear tl/data 
            tl/visible?: no
        ]
    ]
]

SmackMacDougal
02:57@toomasv @dander @greggirwin Thank you all, much so.
02:58Toomas that is a start and I shall give it much thought. I've toyed with capturing keys and pushing sub faces, so this should be interesting.
toomasv
03:39It would be nice to have some method to programmatically let drop drop-down's item-list.
(And links are bogus in my example. :flushed: Just typed, didn't check.)
greggirwin
03:47@toomasv agreed. Having not touched drop-down for a while, this was my quick hack earlier:
choices: [
    "Testing A"
    "Testing B"
    "Profile"
    "Process"
    "Func"
    "Function"
    "Functor"
]

filtered-list: none

view [
    dd: drop-down data choices on-key [
        filtered-list: copy choices
        if not empty? face/text [
            remove-each str filtered-list [not find/match str face/text]
        ]
        face/data: filtered-list
    ]
    button [print mold dd]
]

For a combo box (edit+list), we need to data/text facets for some things.
GiuseppeChillemi
17:46I have a big object full of methods and when I call one of them it seem to work but something is eating words... Any advice on how to find the problem without inspecting piece every methods of the code ?
greggirwin
17:51What do you mean by "eating words"? Can you post the code for that one function?
GiuseppeChillemi
18:31@greggirwin I have found the cause of the problem: a function name had the same name of an argument of many mathods. It created a fake sense of words being eaten while actually it was dropped as the previous word wasn't a function anymore.

ldci
14:52 @melcepstrum I've included in redCV complex numbers operators and FFT routines. You are credited for your job in redCV manual as contributor :)
nd9600
15:36Is there any way to define an object with a key that's also a word! outside the object? Like
a: 1
o: context [
  a: a
]
15:36I just get lots of a has no value
15:39seems like something that should be really easy to do
nedzadarek
15:39@nd9600 like this:
15:39
obj: context [a: 'a]
; make object! [
;     a: 'a
; ]
  obj/a
; a
nd9600
15:40context compose [a: (a)] does it
15:42I remember someone saying something about function specs letting you type return values - is there some way to do that?
15:42I think I heard you can write them, but the compiler/interpreter just ignores it for now
nedzadarek
15:42@nd9600 if your a points to something (e.g. a: 'a / a: to-word "a")
nd9600
15:42like f: function [x [integer!] [integer!]] [x + 1]
15:43thanks
nedzadarek
15:44> I remember someone saying something about function specs letting you type return values - is there some way to do that?

[routines](https://doc.red-lang.org/en/datatypes/routine.html) support that. Not sure how compiler treats it.
nd9600
15:45yep that looks exactly like I want, thanks
nedzadarek
15:45:+1:
9214
15:58@nd9600 return: . It has no bearing on interpreter, but IIRC compiler uses such annotations to make its life easier.
16:00Also:
>> a: 1
== 1
>> set o: object [a: none] a
== 1
>> o
== make object! [
    a: 1
]
meijeru
17:35@nd9600 The precise syntax for _functions_ as opposed to _routines_ is return: [] ; see e.g. [this spec](https://github.com/meijeru/red.specs-public/blob/master/specs.adoc#function).
17:38Note (1) there is as yet no check on this and (2) when compiling, the typeset names must be of built-in (pre-defined) typesets -- user-defined typesets are not allowed in that case; see also [this issue](https://github.com/red/red/issues/3285)
giesse
18:42@nd9600 another way:
>> a: 1
== 1
>> o: context [a: system/words/a]
== make object! [
    a: 1
]

greggirwin
01:32@nd9600 your first example is a great "think like Red" experiment:
a: 1
o: context [
  a: a
]

To create a context and bind the words to it, context (or object) has to first find and collect all the set-word! values. Now, while you know that the a you want to evaluate is global, Red doesn't. A slight change should make this clear:
a: 1
o: context [
    a: self/a
]

That's how Red sees it, which lets you express things with locality in mind.
a: 1
o: context [
    a: 2
    b: a
]

Red's design choice is based on the premise that you shouldn't have to say self/a (though you can if you want). This is a huge win overall. Using compose or a path to another context also make it clear when you are reaching outside the spec for values.

rebred
20:16[![abyssconfig.png](https://files.gitter.im/red/help/Nh9h/thumb/abyssconfig.png)](https://files.gitter.im/red/help/Nh9h/abyssconfig.png)
20:17I am trying to make the Abyss Web Server work with Red. My red scripts work and I am able to print the date correctly:
print ["Date/time is:" now]
When I tried to use a CGI form and use
print input
the server hangs and doesn't print the form content. Is there anyone that has any experience with this server ?
endo64
22:40Not used Abyss Web Server, but you can check this document out, if you didn't already, https://github.com/red/red/wiki/%5BDOC%5D-Using-Red-as-CGI
rebred
22:53thank you I am using a
post
form and following the link page you posted
print rejoin ["Post data: " mold input]
- the server still hangs
9214
23:39@rebred it hangs because input is a function that waits for user input from console.
rebred
23:42 @9214 I see. do you know a way to read the post data
9214
23:43@rebred have you read the link @endo64 mentioned?
23:44Ah, I see that it mentions

> For the POST method, you can get the POST data using input

So I might be wrong.

AndreasWagnerBerlin
12:23I have another question regarding parse. I want to parse strings of the following outlook:
(abc OR def)/TI
So there are outer brackets and a /TI at the end. I am not interested what is inside the brackets, as long as there is a /TI.
It becomes tricky with the following strings:
```( ( abc AND JKL) OR (def AND GHI))/TI```
( ( ((abc AND JKL) OR (def AND GHI) )) )/TI`
Is there any easy solution using parse?
Thank you in advance.
toomasv
13:17@AndreasWagnerBerlin Please be more specific:
1) Do you expect just logic return or collected output?
2) What result do you expect in your last case ( ( ((abc AND JKL) OR (def AND GHI) )) )/TI?
3) Can /TI occur inside and outer parens be without ending /TI, e.g. ( ( ((abc AND JKL)/TI OR (def AND GHI) )) )?
AndreasWagnerBerlin
17:29@toomasv Sorry for the confusion. I try to be more specific as follows:
re 1) logic return (true or false) would be fine
re 2) I expect a true as return because the case fulfills the pattern ( ... )/TI and the brackets are balanced
re 3) no, the /TIshall not occur inside a larger pattern
toomasv
17:52@AndreasWagnerBerlin Thanks! Does this rule work?
[(pars: 0 yep: no) any [
   #"(" (pars: pars + 1) 
   | ")/TI" end (yep: true) 
   | #")" (pars: pars - 1) 
   | skip
   ] if (all [pars = 1 yep])
]
9214
18:10
text
source: {
    (abc OR def)/TI
    (abc OR (def AND GHI))/TI
    ((abc AND JKL) OR (def AND GHI))/TI
    ((((abc AND JKL) OR (def AND GHI))))/TI
}

probe parse load source [4 [paren! /TI]]
toomasv
18:11:smile: :+1:
AndreasWagnerBerlin
18:32Thank you for both solutions. Both work for me. I did not know those parse features.
9214
18:45Also:
source: trim/lines {
    (abc OR def)/TI
    (abc OR (def AND GHI))/TI
    ((abc AND JKL) OR (def AND GHI))/TI
    ((((abc AND JKL) OR (def AND GHI))))/TI
}

state: reactor [
    counter: 0
    bump: func [delta][counter: counter + delta]
    balanced?: is [zero? counter]
]

rule: [
    some [
        some [
              #"(" (bump +1) 
            | #")" (bump -1)
            | not "/TI" skip
        ] 
        "/TI" if (balanced?)
    ]
] 

probe parse/case source bind rule state
greggirwin
20:12@AndreasWagnerBerlin if you could add the pattern and solutions to https://github.com/red/red/wiki/Parse-Cookbook, that would be great. Thanks!
20:13Both solutions are important, because leveraging load is always a win, but sometimes data is not loadable. Matching brackets is also fairly common.

giesse
06:04@9214 any reason to use a reactor there?
Also, why not put the rule in the object if you're binding it anyway?
9214
07:34@giesse mere didactics.
10:56
text
source: trim/lines {
    (abc OR def)/TI
    (abc OR (def AND GHI))/TI
    ((abc AND JKL) OR (def AND GHI))/TI
    ((((abc AND JKL) OR (def AND GHI))))/TI
}

grammar: object [
    counter: 0
    bump: func [delta][counter: counter + delta]
    balanced?: does [zero? counter]
    rule: [
        some [
            some [
                  #"(" (bump +1) 
                | #")" (bump -1)
                | not "/TI" skip
            ] 
            "/TI" if (balanced?)
        ]
    ] 
]

probe parse/case source grammar/rule
AndreasWagnerBerlin
13:31@greggirwin parse-wiki is updated.
rebred
14:36
f: []
q: ["test"]
w: ["random"]
e: ["nice"]
r: ["ok"]
f: rejoin [q w e r]

== ["test" ["random"] ["nice"] ["ok"]]


how do I get this instead
[["test" ] ["random"] ["nice"] ["ok"]]

and this one
["test" "random" "nice" "ok"]
>
toomasv
14:42@rebred
reduce [q w e r]
;== [["test"] ["random"] ["nice"] ["ok"]]
compose [(q) (w) (e) (r)]
;== ["test" "random" "nice" "ok"]
rebred
14:44great thanks!
toomasv
14:44:+1:
Longer versions:
f: collect [foreach x [q w e r] [keep/only get x]]
;== [["test"] ["random"] ["nice"] ["ok"]]
f: collect [foreach x [q w e r] [keep get x]]
;== ["test" "random" "nice" "ok"]
rebred
15:32when I do:

a: ["this is just somet text"]
b: ["Remember outweigh do he desirous no cheerful. Do of doors water ye guest. We if prosperous comparison middletons at. Park we in lose like at no. An so to preferred convinced distrusts he determine. In musical me my placing clothes comfort pleased hearing. Any residence you satisfied and rapturous certainty two. Procured outweigh as outlived so so. On in bringing graceful proposal blessing of marriage outlived. Son rent face our loud near"]
write %file_name reduce [a b]

file content:
[["this is just somet text"] [{Remember outweigh do he desirous no cheerful. Do of doors water ye guest. We if prosperous comparison middletons at. Park we in lose like at no. An so to preferred convinced distrusts he determine. In musical me my placing clothes comfort pleased hearing. Any residence you satisfied and rapturous certainty two. Procured outweigh as outlived so so. On in bringing graceful proposal blessing of marriage outlived. Son rent face our loud near}]]

I get curly braces on the second block. how can I avoid this?
meijeru
15:34What is the problem of having curly braces? They are equivalent to quotes in that they delimit a string! value, except that you can have quotes inside them.
15:35As far as I can see, the mold function applies curly braces if the string is longer than some limit (BRACES_THRESHOLD, currently 50).
rebred
15:40@meijeru I save many records and they vary in length. I don't want to have some with curly braces and others without. this is a problem
meijeru
15:42If you load the file, you will get the strings back. If you will treat the file with another, non-Red program, than you will have to take care of both cases, if you ask me.
rebred
15:43@meijeru yes these records are used by other applications
meijeru
15:45If none of your texts contains " inside, you could preprocess the molded strings by replacing " " by { } OR make all texts at least longer than BRACES_THRESHOLD... by padding them with blanks
rebred
15:49@meijeru is there a way to remove the "{" "}" from the block
meijeru
15:53No because then you would not know the type of the value, which is undesirable, I suppose. For sure you could not reload it in Redbol.
rebred
15:55@meijeru could I convert a string
"test"
into something like
{test}
Oldes
16:12@rebred when you don't care about escaping:
>> t: "test" rejoin [#"{" t #"}"]
== "{test}"
rebred
16:15@Oldes there are still quotation marks!
Oldes
16:15I mean.. you may create unloadable content, like here:
>> t: "foo}" load rejoin [#"{" t #"}"]
*** Syntax Error: missing #"{" at "}"
*** Where: do
*** Stack: load
16:15There will not be _quotation marks_ if you write it into a file. Or maybe I don't want to undesratnd what you want to get.
rebred
16:18@Oldes
t: "test" rejoin [#"{" t #"}"]
write%test t

16:19this removes the quotation marks but it also removes the curly braces. I'd like to replace quotation marks with curly braces
Oldes
16:19
>> t: "test" write %foo.txt rejoin [#"{" t #"}"] print read %foo.txt
{test}
rebred
16:22@Oldes thank you!
16:22
a: "ok.txt"
write %a "test"
16:23how do I assign a variable to the name of a file
Oldes
16:23
a: %ok.txt write a "test"
rebred
16:24@Oldes great thanks!
Oldes
16:24or:
a: "ok.txt"
write to-red-file a "test"

rebred
16:33I have a string
a: "%test"
how do I convert it to a file type
toomasv
16:33@rebred
>> a: "%test"
== "%test"
>> load a
== %test
rebred
16:34@toomasv thanks!
toomasv
16:35You are welcome!
rebred
16:46when I do

a: {this is just some text}
b: {Remember outweigh do he desirous no cheerful. Do of doors water ye guest. We if prosperous comparison middletons at. Park we in lose like at no. An so to preferred convinced distrusts he determine. In musical me my placing clothes comfort pleased hearing. Any residence you satisfied and rapturous certainty two. Procured outweigh as outlived so so. On in bringing graceful proposal blessing of marriage outlived. Son rent face our loud near}
write %z reduce [a b]


I get in the file

["this is just somet text" {Remember outweigh do he desirous no cheerful. Do of doors water ye guest. We if prosperous comparison middletons at. Park we in lose like at no. An so to preferred convinced distrusts he determine. In musical me my placing clothes comfort pleased hearing. Any residence you satisfied and rapturous certainty two. Procured outweigh as outlived so so. On in bringing graceful proposal blessing of marriage outlived. Son rent face our loud near}]

16:47how can I get in the file the curly braces on the first record also
toomasv
16:55I don't think there is currently a simple solution to this. But if you don't mind to have space-filled endings you can pad strings to 50 places to force curly braces:
>> a: pad {this is just some text} 50
== {this is just some text             ...
>> reduce [a b]
== [{this is just some text            ...
rebred
16:56@toomasv I have thousands of records I can't have all these chars
toomasv
16:58 :cold_sweat:
9214
17:00
text
a: {this is just some text}
b: {Remember outweigh do he desirous no cheerful. Do of doors water ye guest. We if prosperous comparison middletons at. Park we in lose like at no. An so to preferred convinced distrusts he determine. In musical me my placing clothes comfort pleased hearing. Any residence you satisfied and rapturous certainty two. Procured outweigh as outlived so so. On in bringing graceful proposal blessing of marriage outlived. Son rent face our loud near}

parse c: mold reduce [a b][
    (flag: no)
    some [change dbl-quote (pick {{}} flag: not flag) | skip]
]

write %z c
rebred
17:01@9214 wow! that's some gymnastic!
17:06I notice that if there is a quotation mark
"
in
a
it automatically saves it with the curly braces
17:07like
a: {this is just some text"}
9214
17:07That's how string escaping mechanism works.
Oldes
17:39@rebred it would be good to know, what you want to do... because if you just want to save/load data in Red, you can just use save and load and don't care about string escaping.
17:41
>> data: ["aa" 121 "bb" 435]
== ["aa" 121 "bb" 435]
>> new-line/all/skip data true 2
== [
    "aa" 121 
    "bb" 435
]
>> save %data data
>> load %data
== ["aa" 121 
    "bb" 435
]
17:42and even:
>> read/lines %data
== [{"aa" 121} {"bb" 435}]
rebred
17:44@Oldes load is very slow unfortunately
17:45
file.txt

["1" "test1" "nice" "hanna"]
["2" "test2" "nice" "robert"]
["3" "test3" "good" "jack"]


I read it with this
s: read/lines %file.txt


s/1 gives me
s/2 gives me
["2" "test2" "nice" "robert"]
s/3 gives me
["3" "test3" "good" "jack"]`

how do I get the items in the sub-record?

I tried s/1/2 but it gives me the second char instead on the second sub-record>
Oldes
17:46read/lines gives you block of strings per line.
9214
17:46@rebred you do realize that read returns you a string!, not a block!? "Sub-records" are non-existent in it.
17:46Block of strings actually, not block of blocks.
rebred
17:51I see I will need to convert it to a block with
load
and then I can access it
18:04@Oldes I tried to use
load
to load a 48MB text file and RED chocked
18:04
>> load %file.txt
*** Internal Error: not enough memory
*** Where: do
*** Stack: load  

>> console-2019-9-18-68998(10891,0xffd93000) malloc: can't allocate region
                                                                          *** mach_vm_map(size=1048576) failed (error code=3)
                                       console-2019-9-18-68998(10891,0xffd93000) malloc: *** set a breakpoint in malloc_error_break to debug

(escape)
>>
18:05it took more then a minute and then hang
18:06when I use
read/lines
I am able to load the file in a few seconds
18:07
console-2019-9-18-68998(10891,0x1c3080) malloc: can't allocate region
*** mach_vm_map(size=49344512) failed (error code=3)
console-2019-9-18-68998(10891,0x1c3080) malloc: *** set a breakpoint in malloc_error_break to debug
*** Access Error: cannot open: %file.txt
*** Where: read
*** Stack:

Oldes
18:09Sorry, that is out of my ability... only @dockimbel can tell you, if it will be improved. Loading 48MB should not be such a problem. But you know. Red is still in **alpha**.
greggirwin
18:56:point_up: [September 23, 2019 7:31 AM](https://gitter.im/red/help?at=5d88c93cc77f285fb1cc1c32) Thanks @AndreasWagnerBerlin !
nedzadarek
19:52@rebred can you try **not** to display loaded file? I mean, after you read/load a file you output it into console, which will change console's fields. I think the gui-console-ctx/terminal/lines will be main culprit.
greggirwin
19:53@rebred you might try the CSV codec, depending on your data format.

The quote/brace issue is interesting. Switching to curly braces at a given length is a carryover from Rebol's design. Someone would have to search to see if Carl ever gave a reason for this. We can guess at some, but it's been a pain point for me a few times in the past.

Quick survey: Do people like this behavior in strings, or would they rather not have the length-based switch to braces?
GaryMiller
19:57Would making the length settable solve the problem. After the load you could set it back to default. Set it to 1 or 1,000,000 to make it consistent and then set it back to default afterwards to not require changes other places in the code that expect standard behavior.
meijeru
20:01The length based switch is not motivated by intrinsic properties of the braces variant, because the most significant difference with quotes is the ability to include newlines and unescaped quotes. Therefore it is a candidate for removal for me. A workaround consist of escaping newlines and embedded quotes, with a (small?) loss of readability.
greggirwin
20:09@GaryMiller I think that will just make it less predictable, especially in the wild.
GaryMiller
20:10@meijeru Would that also require quoting of UNICODE characters like the umlaut ä
greggirwin
20:19@GaryMiller the only special chars it sniffs for are newlines and quotes. That shouldn't change.
meijeru
20:36Right: but don't forget unmatched braces.
rebred
22:52
a: [0 1 2 3 4 5 6 7 8 9]


is there an easier way to remove the 7th element other then
head remove find/tail a 7 - 1
greggirwin
22:58You can use at.
>> a: [0 1 2 3 4 5 6 7 8 9]
== [0 1 2 3 4 5 6 7 8 9]
>> remove at a 7
== [7 8 9]
>> a
== [0 1 2 3 4 5 7 8 9]

Noting that you're removing the 8th element in your example. :^)
22:58And your use of /tail and - 1 simply counteract each other.
rebred
23:00thanks!!
23:03it seems I am removing the 6th element
greggirwin
23:08It's easier to visualize if you start with 1: a: [1 2 3 4 5 6 7 8 9]
23:09Red is a 1-based language, not 0-based.
23:10Using find in your first example conflates things, because finding is not based on indexing.
23:10But you can use index? find ... to see the index where a value was found.
23:10
>> a: [0 1 2 3 4 5 6 7 8 9]
== [0 1 2 3 4 5 6 7 8 9]
>> index? find a 7
== 8
rebred
23:12I see!! thank you!!

lucindamichele
11:20@meijeru @Oldes @9214 @greggirwin and especially @rebred -- it's been cool to watch you guys all figure this out together. What an awesome community. :)
rebred
23:40I am trying to configure apache or any web server to execute red scripts
23:40I followed https://github.com/red/red/wiki/%5BDOC%5D-Using-Red-as-CGI
23:41is there a way to make a red script work with any web server
23:41I followed these poorly written instructions and it's not working
23:43perl scripts work fine
23:43red scripts do not work, the compiler hangs when a red script is called
23:44does anyone have any experience on how to make it work
Respectech
23:45I use lighttpd web server successfully with Rebol and Red scripts.
rebred
23:49@Respectech could you post your lighttpd config file so I can try to make it work

rebred
00:15@Respectech @rebred I updated this line
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".scgi", ".red" )
00:54I was finally able to make it work!
01:03i also updated
cgi.assign                 = ( ".pl"  => "/usr/bin/perl",
                               ".cgi" => "/usr/bin/perl",
                               ".rb"  => "/usr/bin/ruby",
                               ".erb" => "/usr/bin/eruby",
                               ".red" => "/usr/local/bin/red.dms",
                               ".py"  => "/usr/bin/python" )

01:05and I put red inside the
/usr/local/bin/
directory
01:07then I un-commented this line
include "conf.d/cgi.conf"
Respectech
01:20@rebred Great job!
rebred
01:24@Respectech can red work through **FASTCGI** or **SCGI** as well?
greggirwin
01:56@rebred if you would update the CGI wiki page with helpful info, that would be much appreciated.
Respectech
05:53@rebred I haven't tried.
05:53Sorry.
rebred
15:44@greggirwin I just did
endo64
20:06> @Respectech can red work through **FASTCGI** or **SCGI** as well?

Currently no, since ports not implemented yet.
greggirwin
21:07Thanks @rebred!
nd9600
21:12> @nd9600 The precise syntax for _functions_ as opposed to _routines_ is return: [] ; see e.g. [this spec](https://github.com/meijeru/red.specs-public/blob/master/specs.adoc#function).

Is the spec right @meijeru? a: function [return: [string!] {test}] [1] doesn't work in the interpreter, it fails with Script Error: invalid function definition: return:
It works fine without the the return-doc
9214
21:26@nd9600 IIRC this is a regression that has never been fixed, introduced at some point in attempt to make spec dialect more strict.
21:29https://github.com/red/red/issues/3595
nd9600
21:40ah right, thanks
psahani21_gitlab
22:41If I compile the following code I get the kind of error that I would expect.
foo: function [][continue]
forever [
	print "foo"
	foo
	break
]

*** Compilation Error: CONTINUE used with no loop

But if I compile in encap mode or run it as a script, the program runs fine and "foo" is printed infinitely. This is strange behavior to me as most other programming languages don't do this, even if they're interpreted. It's almost as if it's being lazily evaluated. Could someone explain what exactly is going on here?

rebred
00:24@Respectech are you able to upload a file from an HTML page using lighttpd
greggirwin
00:49Interpretation *is* lazy evaluation. But this is a good question.

First, we can note that the interpreted behavior intentionally matches R3's design. R2 didn't have continue. Rebol never had a compiler, so there was no decision on what it should do in that case.

Next, we can see that in Red, continue is just another function. It's not a special syntactic construct or keyword as in most other languages. This makes for a great deal of flexibility, but that makes some things trickier, or even non-compilable. You can write code in Red that is so dynamic that it can't be compiled (except JIT).

Third, we can see that in light of continue being just another function, the interpreted behavior is easy to reason about, if perhaps not the most maintainable code, depending on other factors (it may well be, however, which is why Red is flexible in how it lets you structure things). It allows you to do things like this, for example:
>> foo: function [n][if even? i [continue]]
== func [n][if even? i [continue]]
>> repeat i 10 [
[    	foo i
[    	print i
[    ]
1
3
5
7
9

We have a runtime stack of evaluations which contains a loop, and all is well. If not...
>> foo 1
*** Throw Error: no loop to continue
*** Where: continue
*** Stack: foo


Last, we can "Play Red Compiler". If I'm the compiler, and I see foo: function [][continue], I look at the *compile time* expression stack to see if any loops are there. Imagine that's the only thing in your script. No forever at all. I can clearly say "Nope, that's not gonna work." Doesn't matter if you ever call the func or not. What happens if it *could* be called from inside a loop, as when interpreted, somewhere in the code? We don't know that, without doing a full static analysis, which Red's compiler doesn't do, and complicating the compiler quite a bit. The alternative is that we simply use the compile-time expression stack, what's currently being compiled, and if we're in a loop, all is well; otherwise no-go.

Hope this helps. Others will correct me where my explanation errs.
psahani21_gitlab
01:06Ah ok, this all makes a lot more sense now. I still don't quite understand what you mean by "Interpretation is lazy evaluation" though. Do you mean that in Red this is true or that this is true of all languages?
greggirwin
01:07True in all languages.
01:09Not in the exact sense of functional lazy evaluation of course.
psahani21_gitlab
01:10Oh ok, that's where I was getting confused
Respectech
01:18@rebred Yes, using POST with R3 on lighttpd.
01:18But you have to fiddle with permissions as lighttpd runs as user www-data
rebred
01:32@Respectech I can read HTML forms
post
on lighttpd by getting the variable
input
01:33
input
contains all the text from the form
01:34but how do I get a file from a form ?
01:35I tried to use
write/binary %test.png input
but it's not working
01:36is any other variable other then
input
where I can get the data coming from the form ?
Respectech
02:59Can you display what is being returned by 'input
03:00It may be a multipart data stream that needs to be decoded. I have a script called cgi.r3 that I use in that case.
rebred
11:32
print [input "<BR>"]
print [input "<BR>"]
print [input "<BR>"]

gives me

"------WebKitFormBoundaryF55Zs0icYMcHCoO3^M" 
{Content-Disposition: form-data; name="test"; filename="test.txt"^M} 
"Content-Type: text/plain^M"

the second line shows the name of the file being uploaded
the third line shows what kind of file it is

if I keep printing
input
it gives me the entire text file one piece at the time. it works only when it is a text file.

how do I get and store images/video
12:02this script will print a text file uploaded from a HTML form

while [not empty? a: input][
				print a
				print  "<BR>"
				]

13:08but I am not able to get an image
Respectech
14:36You need to decode the multipart data.
rebred
14:43@Respectech how do I do this
Respectech
15:55I'll send you the link to a script shortly.
16:59http://video.respectech.com:8080/a.com/cgi.r
16:59It will likely have to be modified to work with Red. This version was being used with R3.
rebred
20:28@Respectech could you help set it up I will pay for it
Respectech
21:57Well, that's part of what one of my companies offers. Do you have external SSH access to the machine hosting the webserver and Red?
SmackMacDougal
22:23Hey all. Being new Linux, my install has lxterminal and rxvt. I am trying to set up a menu entry in fluxbox to have a terminal stay open running Red.


[exec] (Red) {lxterminal -e "/home/demo/Apps/red"}


I see something flash on the screen but I do not know what is happening. That is the path to the executable.

rebred
05:07@Respectech I'll set it up and give you access to it
endo64
06:04@SmackMacDougal Can you try to point to the console executable instead of the Red toolchain?
SmackMacDougal
14:06@endo64 Yeah, I don't know. I followed this:

[](https://www.red-lang.org/p/getting-started.html)

And when I click on the executable (It's an elf maybe) nothing happens. At the terminal though, a ./red "in the directory path" opens up red in the terminal. There does not seem to be a console executable as in the Windows sense at least one that generates its own console.

I know things about operating systems having started with Tops 20 on a mainframe and VMS on VAX Clusters. I've been computing for decades. I understand the basics of Linux though I have little of the shell commands memorized. There has been much to learn in a little time.

In Red on Win 10, to get that to work with a hot word launcher (Slick Run), I had to find where Red hid the Red GUI-console build on the hard drive.

It does not appear there is a GUI console for Linux. The documentation must be parsed along with actual experience to discover this.

I'll figure out how. Red will be bumped down on the priority list as I'll use REBOL instead to build GUIs to Linux CLI commands. Hopefully, I can write them in a way to re-purporse the code to Red when it matures.

Red on Windows is great, but I do not want to put Windows 10 back on this machine after the massive fail of the forced update by Microsoft.
14:13Following this to the letter [
Getting Started (Red-Lang.org)](https://www.red-lang.org/p/getting-started.html) and then asking Red to evaluate this at the "console" in Linux (i.e., Red running in a terminal),

red>> view [text "Hello World!"]


Red returns this:

>> view [name: field button "Hi" [print ["Hi" name/text]]]
*** Script Error: view has no value
*** Where: catch
*** Stack:


Is view not available on Linux?
14:26At the "console" that runs in the terminal on a Linux-based OS:

--== Red 0.6.4 ==-- 
Type HELP for starting information. 

>> ? view
No matching values were found in the global context.
meijeru
14:40Could I have a definitive explanation, preferably from @dockimbel, why the following occurs:
>> f: func [w][2  * w]
== func [w][2 * w]
>> (f 1) + 2
== 4
>> f 1 + 2
== 6
>> f: func ['w][2  * w]
== func ['w][2 * w]
>> (f 1) + 2
== 4
>> f 1 + 2
*** Script Error: + operator is missing an argument

I would have thought that, since in the last example, f consumes one value and yields 2, the result should be 2 + 2 and not an error.
Oldes
14:42@meijeru It's a bug.
14:43@SmackMacDougal on linux you must use GTK version which is being developed. https://github.com/red/red/tree/GTK
14:45also the console must be build with needs: 'view in the header to include the view part.
meijeru
14:50@Oldes It was defended by @greggirwin as being intentional. If it is a bug, was it raised as an issue yet?
SmackMacDougal
14:51@Oldes Thanks. So that means what, exactly? On this Debian flavored distro, I need to

1. discover how to apt-get the GTK packages first?
2. and then apt-get those packages?
3. and then using REBOL, build Red as per this: **Running Red from the sources**?
Oldes
14:53@SmackMacDougal I'm not familiar with the GTK branch... @rcqls is working on it mainly.. also there is [GTK related Red room](https://gitter.im/red/GTK)
SmackMacDougal
14:54@Oldes Oh cool. Thanks for the GTK room tip.
rebolek
15:00@meijeru IIRC it's a bug that is being deferred currently.
15:02@SmackMacDougal see https://github.com/red/red/wiki/%5BNOTES%5D-Gtk-Bindings-Development for details and ask in Red/GTK room
SmackMacDougal
15:07@rebolek Thanks!
9214
15:27@meijeru I thought I already explained to you why it doesn't work that way?

hiiamboris
15:47> If it is a bug, was it raised as an issue yet?

@meijeru :) https://github.com/red/red/issues/2622
15:48I'm siding with you that it's a bug btw :)
SmackMacDougal
15:57@rebolek Well, that brought me further along. There is still one issue that bombed at the end of following along the instructions there.

The terminal command did not work for me. I am tempted to open up the REBOL core console and run the script as specified in the terminal command instruction.
meijeru
16:21@hiiamboris Thanks for reminding me about my own issue :frowning: . Shows how long ago, and still no resolution...
16:23@greggirwin Since the issue has not been dismissed by @dockimbel it is still a bug.
9214
16:37"still no resolution" - so why didn't you fix it yourself @meijeru, or convinced core developers of its sheer importance and priority, if it concerns you so much?
greggirwin
17:26Don't stress @9214. :^)

@meijeru between Rebol and Red, which behavior is better? Breaking the rule of op! precedence, or stopping you rather than giving you an unexpected result?

My view, and let's document this somewhere, is that it's a current limitation. Lit args are...necessary but not easy. They have specific purposes and benefits (big ones), but may be confusing. There's an easy, if imperfect solution: Fix it with language. Tell people that if they're going to use lit args, there are guidelines <create document for this>, and one of them is to always include a type check for the arg. e.g.

>> f: func ['w [word!]][2  * w]
== func ['w [word!]][2 * w]
>> f 1 + 2
*** Script Error: f does not allow integer! for its 'w argument
*** Where: f
*** Stack: f


How does that sound?
9214
17:30@9214 [no stress!](https://www.youtube.com/watch?v=7NwFkBrmuuM)
greggirwin
17:38I'm dancing now...WOOO! BP going down. Hammock time! Can't touch stress.
meijeru
20:33I repeat: the bug was raised as an issue, that issue was not dismissed, I must therefore hope that eventually it will be resolved. I don't stress, but apparently several others do... @9214 What makes you think I am well-placed to fix it? Understanding why it is like it is, or being told in which direction it will be resolved, will help me to improve the formulation in the spec document that I take care of.
9214
20:36@meijeru [it was already explained to you](https://gitter.im/red/bugs?at=5d86618be45b6d473231c97d). I don't think anything particular about you, it just doesn't make sense to me why you keep bringing this topic up.
meijeru
20:38I did not understand that explanation, in any case, I have difficulty accepting an explanation for an issue that is still pending.
20:40If the explanation is endorsed by the Red Team, then dismiss the issue. But @greggirwin calls it a "current limitation", so I don't think he wants it dismissed.
9214
20:42@meijeru well, okay, both me and @greggirwin offered you our perspectives on the subject at hand. Can you comment on why do you think Rebol behavior is more preferrable / consistent, so we can document the options?

I get that you want your spec to be precise and up-to-date. and so you urge for this issue to be resolved one way or another, but team obviously has a different set of priorities right now, of which I believe you are well aware. If it will ever be fixed, it will most likely happen with other related issues and refactoring of literal args and op! handling logic in the interpreter.
greggirwin
20:45I copied my notes from here to the ticket, for posterity. I don't know, having not thought deeply enough about it, if it's better as a permanent limitation or what issues may arise if it's changed. For example, is it likely to make code harder to reason about, and we should leave it as is, telling people "Here there by Tygers"?

This is not a high priority, or a quick, easy fix.
20:47We can note the limitation, and also the known workarounds. It's not a showstopper for any reason, is it?
meijeru
22:17@9214 Will answer you tomorrow, I am on CET.

meijeru
08:43@9214 @greggirwin It is not a showstopper (presumably none of the 300-odd pending issues are). It has to be resolved one way or another: either the highest precedence of operators has to be enforced "lexically", as it were, in which case my example f 1 + 2 is indeed an error, or it has to be enforced "semantically", in which case my example is valid like in Rebol. The downside of that is that the reader can less easily guess what is going on, but in the absence of compulsory parentheses, the arity of functions gives the reader a problem anyhow. My preference is for the latter, but I am not deciding.
melcepstrum
09:26why this doesn't work when compiled? it works in the interpreter
apply: function [vec [vector!] fn [any-function!]][forall vec [vec/1: fn vec/1]]
v: make vector! [0.1 0.2 0.3 0.4]
apply v :sin
9214
09:52@melcepstrum compile with -e flag.
melcepstrum
10:43@9214 is it possible to do something similar that will work compiled without -e flag? compiled code runs a lot faster than in encap mode
hiiamboris
11:28@melcepstrum In your case, compiler does not know at compile time that fn you provide is also a compiled function. You can wrap the call in a do-expression: do [fn vec/1], but this unlikely will be faster. Try manually writing an application function for every operation you are using: apply-sin for sin, etc. Or better, use macros to spawn those funcs at compile time.
9214
11:51@melcepstrum write code that is less abstruse for current static compiler, or rewrite performance bottlenecks in Red/System. You cannot have both high-level flexibility and low-level speed in pure Red at this point.
14:04@meijeru operators take _value_ on the left and _expression_ on the right. In your proposal it take expressions from the left side too, but only if it involves a function with literal argument. It's the same kind of inconsistency as R2's do : result of evaluation, for some reason, takes the second chance and participates in evaluation _again_.

* in do :add 1 2, do :add yields add function, which is treated actively and eats 1 with 2, yielding 3;
* same thing with f 1 + 2: f 1 yields 2, which is actively sticked onto the left side of + and continues to participate in evaluation.

Like I said, Red semantics doesn't work that way: results of evaluation don't latch onto vacant expression and get re-used for further evaluation, like e.g. in Scheme:
>> ((if #t + -) 1 2)
== 3

In Red you need to wrap that in extra reduce for each evaluation level:
>> reduce [pick [add subtract] yes 1 2]
== [add 1 2]
>> do reduce [pick [add subtract] yes 1 2]
== 3


So why should we make an exception for functions with literal arguments? Granted, it's not the same as examples above ,but IMO the main idea is the same.
hiiamboris
15:25@9214 following the same logic :) (f 1) + 2 should not work, because (f 1) continues to participate in evaluation. And 1 + 2 + 3 should not work because 1 + 2 result continues that too :)
9214
16:06@hiiamboris your far-fetched "logic" has nothing to do with the point I tried to elaborate. In (f 1) + 2, + goes first as an op!, and (f 1) is a paren! value on the left - everything is consistent with evaluation model. Ditto for 1 + 2 + 3 - 2 + 3 is an expression on the right (relative to the first +), which is again consistent with evaluation model.

In your examples, operator / function goes first with the exact information on how much arguments to fetch (value on the left, expression on the right, which in turn is either a value or expression that requires value on the left and expression on the right, etc), and this "fetching" triggers evaluation of other expressions, top-down, by necessity.

In my examples, on the contrary, subsequent evaluations are carried after-the-fact, like "Oh, I see you returned a value which is not a part of any "top-down argument fetching" evaluation process. Cool! There's this vacant hole nearby, go stick it there. Why, you ask? Just because!".

In do :add 1 2, do is single-arity, but for some reason it takes 1 and 2 with it. There's one function application and two lonely integer! values here, but they magically fuse into one expression.

In f 1 + 2 there's an unary function application followed by a crippled operator with missing left argument: two distinct expressions which you for some reason want to be merged into one.

In (f 1) + 2, + goes first and does what it can to grab available arguments. In f 1 + 2, f 1 goes first, but its returned value is not an argument in any other function expression at that point - but in your model it magically becomes one, as soon as interpreter sees + next to it, as if + waited for f 1 to finish all this time (which is not true, because f took precedence over +).
16:19Same thing with Scheme example actually: pick [...] yes is an expression on its own, and evaluator doesn't go all "ah to hell with it let's stick it here!" over nearby 1 and 2 - that requires an extra layer of evaluation, after either add and subtract is already in place and forms one expression with 1 and 2 (on the grammar level, i.e. "function with arity of 2 followed by 2 values").
hiiamboris
16:20*2 + 3 is an expression on the right* thing isn't true, is it? We're not summing it in 1 + (2 + 3) order. Quite the opposite. We have an expression on the left 1 + 2 which is evaluated and it's result serves as a left operand to 3 + 3.
9214
16:30It's true that operators are left-associative, but e.g. in 1 + add 2 3 + simply cannot finish until add 2 3 expression is done.
16:49So, it's not like operands evaluatively "pull" their left sides - they just reach for a nearby leftmost value, while (grammatically) having expression on the right. It would be cool to have such "pulling" operands, I admit, but it would complicate evaluation quite a bit:
if this [that] else [other]

Here if is a hypothetical function with two (one?) literal argument(s), and else is an operator that works in conjunction with if just like you propose. The downside is that you'll need to wrap all expressions in (...), to escape ' quotations.
17:03Actually, this Rebol feature stops working as soon as you apply escaping:
>> f: func ['x][x * 2] 
>> f 1 + 2
== 4
>> f (1) + 2
== 6

>> f: func [:x][(do x) * 2] 
>> f 1 + 2
== 4
>> f (1) + 2
== 4
17:08Point is, if you guys plan to pitch for this feature: start with rigor and formalization, see how it fits into evaluation model and overall big picture. We can dismiss it on the basis of inconsistency (IMO, because even Rebol behavior doesn't look like an intentional feature), but maybe there's a new language mechanic lurking in here, as I always felt that literal arguments are not leveraged quiet enough and can offer something new.
meijeru
17:46@9214 You finally convinced me, for one. I will close #2622 but hope that some tutorial text will eventually be available to warn people for this pitfall.
18:01Moreover, I have adapted the spec text (which merely gives the accurate semantics, but is certainly not tutorial).
hiiamboris
18:27I still don't get it ):
You sayin that: 1 + 2 + 3 which evaluates as:
1 + 2[ + 3] => 3[ + 3]
3 + 3 => 6

is totally okay, but f 1 + 2 which should evaluate as (same thing to me):
f 1[ + 2] => 2[ + 2]
2 + 2 => 4

does not fit the evaluation model? How so? I fail to see the semantic difference
And that great if-then-else example should fit too. Great example.
(by [..] I denote the part that might have been looked ahead but is not on the evaluation stack yet)
giesse
18:49@hiiamboris I wonder if looking at a working model might help in this case. For example, https://github.com/giesse/Project-SnowBall/blob/master/topaz/actions.topaz#L115 (that's basically the core of the interpreter in Topaz - I doubt it's much different in Red, but I suspect Red/System and the internals may add to the confusion).

My first question to you would be - can you write a version that works as you describe? What does it look like? (Pseudo-code is fine.)
My second question is - can you see how the current model does NOT fit your example at all?
hiiamboris
19:10@giesse I would expect in your code, for f 1 + 2 expr, [result block] to become [2 [+ 2]]. Then while would set [arg2 block] to [2 []], final result to become do-op :+ 2 2.
Where am I wrong?
9214
19:12@hiiamboris okay, do you agree that 1 is a value and f 1 is an expression?
hiiamboris
19:13Yeah, so? 1 + 2 in 1 + 2 + 3 is also an expression.
9214
19:13Do you agree that operators take _value_ on the left?
hiiamboris
19:15Not an immediate value (2), but a result of previous evaluation (1 + 2) as 1 + 2 + 3 example shows.
9214
19:17@hiiamboris but that holds only for operators chained together, yes?
19:18i.e. you can really tell that add 1 2 * 3 should be 9.
hiiamboris
19:30> but that holds only for operators chained together, yes?

I don't see such limitation in @giesse's code (maybe I didn't look long enough ☺). Apparently in Red we have this simplification right now.

I see add 1 2 * 3 as follows:
add requires 2 arguments, so we save add for later and wait for 2 arguments to complete
we take 1 as 1st argument
after 2 we see ahead an op, so we extend the argument to 2 * 3, eval that to 6
then we see no op after 3 and we stop at that - got 2nd argument to add
then we eval add 1 6 and get 7

In f 1 + 2 case we know that f wants a lit-arg and we have decided that if the op + doesn't also want a lit-arg, then f takes higher priority and takes 1 as is. The fact that our implementation of operator + evaluation does not expect the result from a function f call, does not mean we cannot make it so.

And now I see why it fails with f (1) + 2 in R3 ☺ ... it can take the result of (1) for lit-arg, but for some reason switches to normal evaluation, as if lit-arg rejected the paren. Well, R3 is so alpha ☺ let's not take it as a peak of achievements.
9214
19:41> does not mean we cannot make it so

And that's where we need to think hard and do better than R3. I'm not opposed to such behavior per se, but I'm against introducing it just because "Rebol does that and we should too", without any design framework backing this feature - and, if what you really want is "operators that wait for expression on the left and pull its value as an argument", then I don't think literal arguments are an adequate solution at all.

In the current model, infix detection is a simple look-ahead by one cell, which is already burdened by multiple checks of literal arguments; adding f 1 + 2 behavior will only complicate it further, without any general semantic benefit (because, again, we would add it following "oh it's a bug because Rebol does this nifty thing instead of erroring out" logic, without any design deliberations).
19:45> but for some reason switches to normal evaluation

The reason is [escaping mechanism](https://github.com/red/red/wiki/[DOC]-Guru-Meditations#literal-arguments-and-get-arguments).

> if next value is get-word! or get-path! or paren!: eval to fetch bound value; else pass next value as-is
19:48So 'arg is "soft" quoting which you can bypass with some datatypes, whereas :arg is "hard" quoting without escape hatches.
19:51> Apparently in Red we have this simplification right now

This "simplification" is op!'s precedence over function!; with your proposal if would be function! over op!.
hiiamboris
19:53I see. Then "eval to fetch" part there maybe needs clarification or an example. E.g. in our f (1) + 2 expr it evaluates the whole rest of the block, which is (1) + 2, not (1) as we would expect.
melcepstrum
19:55@hiiamboris @9214 thanks, what is the best way of doing something like this in red
void map(int (*f)(int), int x[], size_t n) {
    for (int i = 0; i < n; i++)
        x[i] = f(x[i]);
}
9214
19:57@melcepstrum I thought you already wrote map yourself? For a more general version of it, look into collect.
hiiamboris
19:58@melcepstrum See, the thing is, there's no **best** way in Red ☻ Like in engineering, the amount of good designs is only limited by one's imagination.
9214
20:00
text
>> map: func [series function][collect [forall series [keep/only function series/1]]]
== func [series function][collect [forall series [keep/only function series/1]]]
>> map [1 2 3] :negate
== [-1 -2 -3]
>> map block: [[a b] [c d] [e f]] :reverse
== [[b a] [d c] [f e]]
>> block
== [[b a] [d c] [f e]]
hiiamboris
20:04@9214 in his case, x[] items are modified in place. So change/only is the way.
9214
20:04Or, following your example to the letter:
map: func [series function][forall series [series/1: function series/1] series]
hiiamboris
20:04Yeah ☻
9214
20:04@hiiamboris that's an overkill.
hiiamboris
20:17> we need to think hard and do better than R3 ... (and other points)

I totally agree with that. Considering the issue's age, support of this feature involves either some complication or slowdown. So to justify it we need solid examples of use cases. I call it a "bug", but I can call it a "weighed limitation of the current design". Crooked R3 support of it does not touch me much really. I can see two arguments in favor of this:
1) (and it apparently brought the issue to light in the first place) - is that this is how we tend to imagine the syntax tree of how Red should work. And to live to that expectation alone we should keep the option of implementing this feature, on our radars. Else it looks like the result of f 1 just disappears into nowhere.
2) We can implement it to give people more expressive power, to hold breath and (at some point in the future) see how some will twist the language ☻ But that's a dangerous path as we might not like the result...
20:20We should mention this issue and chat on design decisions wiki page... And the if example.
9214
20:34I have crude notes jotted down in the process of solving https://github.com/red/red/issues/3840, about how function and operators can be generalized. From hierarchical standpoint, the proto-father of all any-function!s is this n-arity thing that takes m arguments on the left and k arguments on the right:
m1 m2 .. mX thing k1 k2 .. kX

op!s (infix) are derived from that thing by restricting arity to 2 and making it possible to grab only 1 leftmost value; function!s (prefix) are "thing" with completely "clamped" left side. Hypothetical postfix! is a "thing" with clamped right side, etc. In other words, what can be parametrized is (a) arity and (b) distribution of arguments on each side and how they are treated (expression, value, literal argument, whatnot).

Another idea of mine are functions that can operate directly on the "stream" of data from the source itself, e.g. foo 1 2 3 takes [1 2 3 ...] itself as an argument - a block! position right after foo, which it can traverse with series actions and modify in-place while some predicate holds (e.g. until the newline marker or specific token; imagine this paired up with Parse).
20:41... and the main question is how to keep all of this practical and understandable, without derailing into pure esoterism and crackpot-level language design.
melcepstrum
22:37@9214 @hiiamboris ok, i thought i can have high-level flexibility and low-level speed, and simple and elegant code, like in C++ :)
9214
22:47@melcepstrum okay, why won't you port it to R/S then, which is far more closer to C++ (happily not too close) than Red?

rebred
00:33is there a way to force a number into certain number of digits? for example 4 digits. if you have 9 to make it 0009 or if you have 212 to make it 0212
00:37let's say you have a float of 0.3865217992041827 seconds with 16 digits after the dot. so if you have 0.93727473 it should be 0.9372747300000000 and keep the 16 digits form
00:38or do I have to do it manually ?
9214
00:48@rebred pad/with.
rebred
00:49@9214 thanks!!!!
00:56@9214 when the date shows the month, it shows 9 instead of 09. the same goes for the day and seconds. they are not shown as a set number of char
giesse
06:00@hiiamboris you are wrong because you are ignoring recursion. f is a function!, therefore it gets called, which means collecting arguments. So now we are at [1 + 2] and we need to collect one argument. The 1 evaluates to 1, but, there's a + after it which is an op!, therefore it gets evaluated, which causes another recursion to figure out the second argument to +. So, 1 + 2 is evaluated first, and passed as the first argument to f.

To behave differently means setting up a bunch of special cases. To be honest, I don't see how this could be a good thing (more things to remember, much harder to read code), let alone worth the effort.
prapro
06:24Does anyone have any recommendations, snippets, prayers, etc for patching in the serial port support for red?
Respectech
07:09Hey @prapro long time no see!
prapro
07:18Its has been a few years. I wondered off to Vegas for awhile, and just haven't been back.
nedzadarek
21:07
pad ( /left is useful, in my opinion, for floats):
f: function [numb pad-to] [
        if integer! = type? numb [return pad/with/left (to-string numb) pad-to #"0"] 
        if float! = type? numb [return pad/with (to-string numb) pad-to #"0"] 
]

f 2 10
; == "0000000002"
f 2.1 10
; == "2.10000000"


ps. I assume you don't convert to smaller numbers (e.g. 9999, for 2 digits, into 99; 1.1234567, for 3 digits, into 1.12)>

greggirwin
04:04> ...simple and elegant code, like in C++ :)

:^) But there will be a better way in the future, because we'll have standard HOFs in Red and then you don't have to write it yourself at all. Just use it.

I just skimmed the chat here, as you all have it well in hand. I'll just say that this will make a great article @9214 and you can do it now or after your other one. You keep more in your head than I can, so waiting may be OK. I'd want to strike while the iron was hot.

@prapro best thing is to keep your finger on the pulse here and wait for news on port! availability, offering to help with the serial port work when it's open for business.
Palaing
10:03~~What am I missing?
I launch the just-downloaded red-064.exe, it compiles a file named gui-console-2018-11-22-8164.exe and the system/build info is:
make object! [
date: 30-Sep-2019/11:57:01+02:00
git: make object! [
branch: "HEAD"
tag: #v0.6.4
ahead: 0
date: 22-Nov-2018/2:40:38+02:00
commit: #755eb943ccea9e78c2cab0f20b313a52404355cb
message: {Merge pull request #3604 from x8x/add-macos-mojave^/^/FIX: Add Mojave to list of macOS}
]
[...]~~
10:07Sorry - stupid question. I should have dowloaded the latest build, not the last stable.
nedzadarek
19:52@Palaing you can just click 3 dots (on the right side) and remove the message.

abdllhygt
08:37doesn't global variables change by a func?
08:48
a: "hi"
func...[
a: "hey"
]
print a

== hi

toomasv
08:51
a: "hey" never gets evaluated.>
ralfwenske
08:56MacOS: When just hitting return in console I observe between 1 and 5 seconds delay until >> shows again. Can someone confirm this (on Mac)? Tested on two different machines (Mini and MacBook).
Red 0.6.4 for macOS built 28-Sep-2019/2:46:20+10:00 commit #d0e6692

This happens in the 'Terminal' app. When hitting return in the terminal of Visual Studio I have the usual immediate response showing the >>
avitkauskas
09:04I do not experience that on my Macbook Pro. My Red is one of the automated buils downloaded a few days ago. Is there a way to get commit hash from the executable you have?
9214
09:05@avitkauskas about
ralfwenske
avitkauskas
09:06My version is Red 0.6.4 for macOS built 27-Sep-2019/19:46:20+03:00 commit #d0e6692. It works fine in iTerm and in Terminal.
ralfwenske
09:07@avitkauskas Could you try the latest? I downloaded it only a couple hours ago.
avitkauskas
09:08That's the same version, commit #d0e6692
ralfwenske
09:09Ohhh I see now. Strange as I observe it on two separate machines…. Thank you anyway.
Just to be sure: could you hit return a few times in short sequence? That seems to increase the delay for me
abdllhygt
09:17@toomasv i called in my code. so, you say that global variables can change in func, okay!
toomasv
09:20@abdllhygt
>> a: "hi" do [a: "hey"] a
== "hey"
>> a: "hi" f: does [a: "hey"] f a
== "hey"
avitkauskas
09:25@ralfwenske YES! It starts lagging if you hit return several times in short sequence!
ralfwenske
09:26I rebooted the MacBook and observed immediate return of >> in the beginning but when holding down the 'return' key for a few seconds the Terminal console hangs for a long time.
avitkauskas
09:26And when it starts lagging, the lag stays even if you hit return just once.
ralfwenske
09:27Thanks @avitkauskas I will report it in bugs.
nedzadarek
20:19@abdllhygt you got an error:
func...[
[    a: "hey"
[    ]
*** Script Error: func... has no value
*** Where: catch
*** Stack:

Try to remove your errors (read them) then you can conclude whenever or not functions can change "global variables".
20:20ps. unless something is wrong with copy/paste or something
endo64
22:31And remember, function automatically collects all the set words and makes them local to the function:
>> a: 1 f: function [] [a: 2] f print a
1

This is not the case for func and does.

nd9600
12:14Not sure if this is useful to anyone, but I've made a Markdown -> HTML compiler at https://github.com/nd9600/wiki/blob/master/compiler/markdown/markdown.red
12:14I use it to make https://wiki.nd9600.download/
rebolek
12:14@nd9600 congratulations, that's certainly useful!
nd9600
12:15thanks
12:15Is there a reason why
a: "abc"
switch/default type? a [
    string! [print "string"]
] [
    print "default"
]

never prints "string"?
12:15(type? a) == string! ; true
rebolek
12:16Yes, string! is word there, as it's not evaluated, so change type? to type?/word
nd9600
12:16thanks
rebolek
12:16
>> type? first [string!]
== word!
nd9600
12:17:+1:
13:02I've made a few more things that are probably a bit more useful
a little module loader (projects were getting a bit hard to manage, with lots of do %file.red everywhere
https://github.com/nd9600/personal_misc/blob/master/misc/red/lib/moduleLoader.red
13:03a very small test driver
https://github.com/nd9600/personal_misc/blob/master/misc/red/testDriver.red
13:03used like https://github.com/nd9600/personal_misc/blob/master/misc/red/tests/moduleLoader/moduleLoaderTest.red#L5
13:04a dotenv loader https://github.com/nd9600/personal_misc/blob/master/misc/red/lib/dotenv.red
rebolek
13:04so much stuff!
nd9600
13:07this one is a bit nasty:
https://github.com/nd9600/personal_misc/blob/master/misc/red/lib/obj.red
I've needed to hack in inheritance into our object!s for a few different things I'm doing - I know, it's all prototype-based, but this was too useful not to do
13:08with things like tokens in an AST parser, so I could say "what type of token is this?"
13:09and then there's a lot of a misc functions in https://github.com/nd9600/personal_misc/blob/master/misc/red/lib/helpers.red
13:14I'm slightly worried Red is going to have the Lisp Curse http://www.winestockwebdesign.com/Essays/Lisp_Curse.html
13:29It's very easy to make things like a test driver or a module loader, so people might make lots of alternatives
rebolek
13:38@nd9600 let's hope this won't happen and such stuff will be added into official distribution
hiiamboris
14:13@nd9600 I can tell that all the features you're using are planned to be a standard part of Red. We're just not there yet :)
Respectech
15:09@nd9600 Very interesting Atticus
15:12Very interesting *article*. I do see some of those issues with Rebol-based languages.
greggirwin
22:05@nd9600 thanks for posting! As @rebolek said "So much stuff!" :^)
22:08Modules and official test options, beyond quicktest, will be available in the future.

greggirwin
04:22@nd9600 having read a bit of your wiki, it sounds like you're cursed like the rest of us here. We can view it as a blessing, especially for those of us who have never aspired to be popular. ;^)

I have opinions on the business benefit of commodity programmers, based on personal experience. As an old developer, I've seen both sides, for small businesses and large. Commodity programmers reduce risk if you don't expect to have an experienced, vested developer or team. Certainly a single point of failure in any role puts a business at risk. But I believe you also get commodity results, especially if you do need to replace people. New developers who want ownership, and to take pride in their craft, will rewrite things. Commodity programmers don't, and those choices make a big difference over time. It's also a big cultural difference. People do move around in jobs a lot more now, so that's a consideration. Can a developer treat their employer like a commodity and not expect to be treated the same?

This is where Programmer Owned projects are different. Very different. Because you may stick with a project for a decade, or even much longer. There's a company whose conferences I spoke at many years ago. Very successful, built tools and a language that ran hospitals, finance, and big business. They had 2 main devs/architects who had been with them for a very long time, and they were linchpins. Without them, the company was at risk. But they didn't change the culture. They reduced their risk by making sure those 2 knew how much they were valued, in many ways. For all I know, they're still there.

We can choose to be commodity programmers, and there are certainly benefits to that. But also costs. I also don't want to treat others as commodity programmers. I try to treat others as I want to be treated myself.
Palaing
17:43@nedzadarek thanks; actually I was afraid that could confuse someone having already read the message.
Respectech
18:12As usual, @greggirwin you have hit the nail on the head. You have a really good grasp on this stuff.
nedzadarek
18:53@Palaing makes sense
GiuseppeChillemi
21:20Do RED/REBOL have an equivalent of goto <label> ?
greggirwin
21:28No. Not directly anyway. You can use catch/throw for non-local flow control.
rebred
23:17
filename: "%12dstest@123.txt"
write load filename "ok"

this gives me an error
9214
23:20@rebred type? filename
23:21
text
>> write %"12dstest@123.txt" "ok"
>> read %"12dstest@123.txt"
== "ok"


@greggirwin :point_up: guess what.
rebred
23:23@9214 I am composing the filename from different variables into a string called
filename
9214
23:25
text
>> type? load "%12dstest@123.txt"
== email!
>> type? to-red-file "%12dstest@123.txt"
== file!

Or you can compose filename into file! series in the first place.
>> type? append %"" "12dstest@123.txt"
== file!
rebred
23:30
a: 12
b: "test@123.com"
c: "test"
filename: load rejoin ["%" a b " " c ".txt"]
write filename "ok"

this gives me an error
9214
23:31@rebred haven't you learnt anything from my examples? Your filename is an email! value, write chokes on it.
rebred
23:31in macOS I can save a file with an
@
in it. can I save a file in RED with an @ in it ?
greggirwin
23:32> haven't you learned anything?

That may not be what you wanted to say @9214.
9214
23:32@rebred see my previous examples.
greggirwin
23:32@rebred why not use to file!?
23:36@rebred it also helps if you post the error you're getting.
rebred
23:39
a: 12
b: "test@123.com"
c: "test"
filename: load rejoin ["%" a b " " c ".txt"]
write filename "ok"

this gives me an error

*** Script Error: write does not allow email! for its destination argument
*** Where: write
*** Stack:

greggirwin
23:40And how do you go about debugging that?
9214
23:41@rebred ... but filename is a block! in this case. Try to insert probe before filename: to see the problem.
greggirwin
23:45As @9214 is trying to tell you, go step by step, understanding the results and intermediate values. You should solve it before long.
rebred
23:46
a: "%12 test@123.com test.txt"
write a "test"

*** Script Error: write does not allow string! for its destination argument


a: "%12 test@123.com test.txt"
write load a "test"

*** Script Error: write does not allow block! for its destination argument

greggirwin
23:46If you find yourself building string values and loading them, you're probably doing things the hard way.
23:46Do one thing. What is a in your first example?
23:47Hint: write tells you.
rebred
23:48I compose file names using a few variables. let's say the final var is
a: "%12 test@123.com test.txt"
is there a way to save a text file with this name ?
greggirwin
23:49Of course there is. But that value is *not* a file!. First, understand that.
rebred
23:50I can name a file in OS X with spaces and @ in it
greggirwin
23:50That's not the problem. Do you understand that?
23:51I think we've given you all the help and clues you need to solve this.
rebred
23:58@9214
a: to-red-file "12 test@123.com test.txt"
write a "test"

thank you!

9214
00:00@rebred do you understand why it didn't work in all previous cases?
rebred
00:01@9214 I needed to convert string and block into a file! type thank you!!!
greggirwin
00:46@rebred another thing that can help is to let people know that you've done the things they suggested. Glad it's working for you now.
ushakovs_gitlab
18:05[![image.png](https://files.gitter.im/red/help/43pF/thumb/image.png)](https://files.gitter.im/red/help/43pF/image.png)
greggirwin
18:07Code coming to dupe that?
ushakovs_gitlab
18:07
Red [Title: "drag" needs: 'view]
f: view/flags/options/no-wait [
    t: h5 red 80x20 "Frozen" 
] ['no-title] [drag-on: 'down]

m: view/flags/no-wait [
    t: h5 yellow 80x20 "Movable" 
	do [options: [drag-on: 'down]]
] ['no-title]

"Movable" window moves by grey border very nice.
Why do works, but view/options don't?
greggirwin
18:07Add a newline after the 3 ticks, and before the closing ones.
ushakovs_gitlab
18:08thanks
greggirwin
18:08:+1:
ushakovs_gitlab
18:13And Movable window cause some error messages into console (on screenshot). But moving fine.
greggirwin
18:16Yes. The error messages indicate there's something about this for windows versus controls/faces. @qtxie will be the one to answer this, and also the options question.
hiiamboris
18:18@ushakovs_gitlab replace [drag-on: 'down] with [options: [drag-on: 'down]]
18:19With view/options you're adding stuff at face! level, contrary to what one might infer from the name
ushakovs_gitlab
18:21Fine! It works!
First I decide that view refinement options == facet options.
But in reality it's better!
greggirwin
18:21Thanks @hiiamboris, we need to add that to the docs.
ushakovs_gitlab
18:22I have second question.
I want to move window by text field too.
What should I to write to achieve this?
I read something about event bubbling but how to resend event to parent?
hiiamboris
18:28My gut says you won't hack this, as dragging is done by OS' native code and you sending events there won't do any good. Instead, make an almost-transparent box (of color 0.0.0.254) over your window, and adjust window coordinates in response to mouse events (if you make it fully transparent it won't catch the mouse).
18:31Those error messages though. This is a bug. Something to do with events coming when window isn't ready (yet, or already) to receive them. Will you raise an issue on the tracker @ushakovs_gitlab ? ☻
ushakovs_gitlab
18:33Thank you, but you explanation is too short for me.
I just write my first code in Red.
I don't know how to work with events.

Yes, I will register bug.... Tomorrow .
18:34And about refinement /options. As I understand it can replace refinement /flags, really?
18:43Yes. It's possible to code without /flag refinement:
Red [Title: "drag" needs: 'view]
f: view/options [
    t: h5 red 80x20 "Not frozen now" 
] [options: [drag-on: 'down] flags: ['no-title]]

It works
18:59Hmm. I guess I understand you advice about almost transparent box. There is one not good thing with it. When mouse leave windows field - events stops to receive by any window faces. Maybe global events hook may help in this issue?
hiiamboris
19:13@ushakovs_gitlab add all-over after your box definition. When your mouse button is down, it should receive the events even mouse leaves.
19:15Sorry I'm not giving you examples in code ☺ A bit busy here
nedzadarek
19:25@ushakovs_gitlab maybe this could help (gets you started).
clicked?: off 
f: layout [base red all-over on-down [clicked?: on]on-over [if clicked? [f/offset: f/offset + event/offset] ] on-up [clicked?: off]] 
view f
19:40^ unless I misread your message
9214
21:47@ushakovs_gitlab it might help if you describe what you want to achieve, so we don't play a guessing game. As for bug reporting - please report it in [/bugs](https://gitter.im/red/bugs) for confirmation before opening a ticket.

set [hold? delta][#[false] 0x0]

window: layout [
    box 80x20 red "drag me" all-over
        on-down [hold?: yes delta: event/offset] on-up [hold?: no]
        on-over [
            if hold? [
                window/offset: window/offset + event/offset - delta
            ]
        ]
]

view/flags window 'no-title


This one is a bit simpler, but twitchy:
window: layout [
    box 80x20 red "drag me" extra 0x0 loose
        on-down [face/extra: face/offset]
        on-drag [window/offset: window/offset + face/offset - face/extra]
]

view/flags window 'no-title

SmackMacDougal
04:14Say gang, might someone help me with this one? I'm running a Linux box regularly now (first time). I can su to the super user (root) account.

I put Red in /opt/red because that seemed right. Then I symlinked it to /usr/bin because that seemed like a good way to handle path rather than adding to the path /opt/red.

Next I have created /usr/share/red/spells where I have scripts that define words for dictionary of words, which enhance red.

If I do this (Bash) $ red /usr/share/red/start.red the script executes but returns me to the shell. I want to stay in the Red console.

My same startup design worked under Windows 10 and Windows 7, but not under Linux. Why? What is kicking me back to the shell rather than keeping me in the Red console? The permissions are rwxrwxrwxeverything in `/usr/share/red/ including %start.red and the directories (paths) to other scripts.



9214
04:24@SmackMacDougal use --catch flag.
SmackMacDougal
14:43@9214 Thank You!
dander
14:54@SmackMacDougal many Linux systems have a built in 'red' command which is a variant of 'ed' I think. You should double-check that that one isn't in first in your path
greggirwin
16:22--catch isn't documented in the list of CLI args. Would someone like to do that? It just passes --catch on to the shell, at a glance.
hiiamboris
16:33It leaves you in the REPL after the script finishes.
greggirwin
16:38Yes, I should have said console or REPL rather than shell.
9214
16:53@greggirwin it's on my todo list, among with other undocumented flags.
avitkauskas
17:08Made a small PR for this if you care :) (#4066)
9214
17:09@avitkauskas FYI, --catch will probably be removed in 0.6.5.
avitkauskas
17:10:( ok, but while it's here...
9214
17:15@avitkauskas here's a full list, if you feel up for it:
* --no-compress: omit Redbin format compression
* --catch: see above
* --dev: should be removed, implied by -c (so, ignore it)
* --config: broken (format is ill-suited for console), ignore for now
* recent --show-func-map: output an address/name map of Red/System functions, for debugging purposes https://github.com/red/red/commit/2f202b52bbb2557613ecc5f5b3e8d422f518f79a
avitkauskas
17:18OK, I can add these. Should I add --dev as it's not mentioned now.
17:19And I leave --config but add a note for it. OK?
9214
17:22@avitkauskas keep --config and --dev as-is.
avitkauskas
17:23OK. Done
9214
17:30@avitkauskas great, thanks! :+1:
SmackMacDougal
17:40Thanks everyone. You have helped quite a bit with my transition to Red on Linux. I've been running red for a few years mostly as a way to automate downloading of datasets. Red replaced my REBOL for doing the same after REBOL started to flake out with certificate problems on Windows 7 & 10.

greggirwin
17:45Merged. Thanks @avitkauskas !
hiiamboris
17:58--config works for me
17:58@9214 why are you saying it's broken?
9214
18:01@hiiamboris I quote @dockimbel on that. Current key/value block format is too verbose to type from OS shell. Other languages command-line frontend hae special flags for that (--gc:off --bloat:0 or smth like that) AFAIK.
hiiamboris
18:02Just use quotes. --config "[format: 'ELF]" etc
18:03The options themselves: https://github.com/red/red/blob/master/system/config.r#L13
18:03I just tried a few, all OK.
9214
18:05@hiiamboris when I said "broken" I meant syntax, not functionality. It works as it is, but might use some polishing.
18:08Per original @dockimbel's message as jotted down in my notes

> --config is broken, cannot work properly, so ignore it for now. (passing a block of name/value pairs cannot work from command-line due to significant whitespaces).
hiiamboris
18:27I see ☺
18:49Come to think of it, the quoted args were really messed up some time ago. This could've prevented one from using config option properly. So, at that time, the statement might have been true.
GiuseppeChillemi
19:51Is there already available code to convert a web page to text ?
greggirwin
20:46Not that I know of.
nedzadarek
20:48@GiuseppeChillemi can't you just remove all tag! elements from a source?
GiuseppeChillemi
20:49Yes, I could but if there is some tool to keep good formatting or select the frame to convert it would be good
greggirwin
21:03@nedzadarek your suggestion implies that the HTML is entirely loadable, which may not be the case. Otherwise it's all just a big string to parse. Porting R2 solutions should be pretty easy.
GiuseppeChillemi
21:04@greggirwin Have you a preferred/suggested script ?
greggirwin
21:49I would have to search for one, just like you @GiuseppeChillemi.
GiuseppeChillemi
22:57Thanks, I have just found one.

nedzadarek
08:43@GiuseppeChillemi then if you parse it as a string, can't you just change everything, between < and > for nothing?
ps. that implies that things between tags stay unchanged, even thing like script -> [example](https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_script).
toomasv
10:47One somewhat simplistic try is [here](https://github.com/toomasv/learning/blob/master/browser/text-browser3.red)
GiuseppeChillemi
12:06@toomasv

Yes, it has a bug that changes only the first line while scrolling (scrolling back from the end) and also got errors like:

*** Where: >=
*** Stack: do-file context view do-events do-actor do-safe 
*** Script Error: path range/1 is not valid for integer! type
*** Where: >=
*** Stack: do-file context view do-events do-actor do-safe 
*** Access Error: cannot connect: https://github.com/red/wallet reason: timeout
*** Where: read
*** Stack: do-file context view do-events do-actor do-safe read-thru


But it is what I was searching !
12:19...Hmmmm... it happen always and it eats text either scrolling back and words.
12:47*back and forwards
toomasv
15:56@GiuseppeChillemi Feel free to play with or change it. I can't now deal with that. (You might try also this [readme](https://github.com/toomasv/learning/tree/master/browser))

ushakovs_gitlab
16:51@9214 , @nedzadarek thanks!
Your solutions works, but code is not so small and simple.
Imagine window with many faces and empty spaces between.
I want to drag window by "passive" faces such as text, box, etc and by empty window area as well. On the other hand "active" faces such as button, check slider, etc should respond by mouse as usual.
If there are a lot of faces then a lot of code is needed.

So what about more simple case?
Window's context menu (right mouse click) which must popup when click not only on empty window 's area, but on any text areas?
hiiamboris
17:26Have you tried the almost-transparent box idea of mine?
ushakovs_gitlab
17:31Sorry, I just hadn't time these days to think and try to write any code.
And if any buttons or sliders are placed behind this box... What's to do?
hiiamboris
17:32Oh well. That would ruin it ☺
17:33Then just define your styles. Add the code offered by @9214 to the style and reuse it.
ushakovs_gitlab
17:34Hmmmm... It's idea!
17:35I'm just dumb newbie. :)
hiiamboris
17:39Look ☻
window: layout compose [
    style box: box extra 0x0 loose
        on-down [face/extra: face/offset]
        on-drag [window/offset: window/offset + face/offset - face/extra]
    (collect [
    	repeat i 10 [
	    	repeat j 10 [
    			keep compose [box 80x20 (random/only load help-string tuple!) "drag me"]
    		]
    		keep 'return
    	]
    ])
]

view/flags window 'no-title

ushakovs_gitlab
17:41Excellent!
Thanks a lot!
hiiamboris
17:47you're welcome ☺
Softknobs
18:12Does anybody know the proper way to keep a command line Red program running until the user stops it? I have a Red script embedding Red/System and using view[] seems to be the most stable option I found. I tried, with no success, the following:
- adding input command => I get "undefined word input" on compilation
- adding at the end of the script forever[]=> I get access violations that do not happen if I replace forever by view[]
Thanks.
hiiamboris
18:19@Softknobs what about wait -1?
18:21Do you have a snippet that causes those access violations though? It's worth looking into.
greggirwin
18:46@ushakovs_gitlab a couple thoughts.
1) You're doing something standard UIs aren't designed for, so we can't expect it to be too easy.
2) @hiiamboris proves me wrong here.
3) Because you can adjust the z-order of faces, it's a simple matter to write make-draggable wrappers that shift the order of faces, relative to your almost invisible layer if you use that approach.
18:50For 3), first you need to learn a bit about how UIs are just a tree of faces, and that there's a pane value which contains a block of child faces. e.g. print mold layout [text "Hi" button "Close"]. Then you can play with reordering things in the pane block, knowing that they render in order.
ushakovs_gitlab
18:58Thank you for explanations!
So, may I ask another yet question? (I guess - yes :) )
view [
	title "Flicker"
    t: h5 green 130x20 "forever" rate 5
	on-time [t/text: mold now/time]	
]

How to avoid flicker?
hiiamboris
19:02try t: box green 130x20 font-size 15 "forever" rate 5
19:03these native controls, what a mess...
greggirwin
19:07Are you both on Win7? No flicker here on Win10.
19:07Agreed on native controls.
hiiamboris
19:20Yep, both. Very nasty flicker.
Softknobs
21:43@hiiamboris Thanks, wait -1works perfectly
I can't reproduce the problem with a snippet, however I created a gist with the full script here if want to have a look at it:
https://gist.github.com/Softknobs/6b7e70f84bb7a34a6f553b8a3b11bdec
Thank you.

schwarzbox
16:44Hello, I run red-064 with Mac OS Catalina 10.15 and have "Bad CPU type in executable"
When you plan support new version of OS X?
9214
17:19@schwarzbox when toolchain is ported to 64-bit, which is one of the top priorities.
ushakovs_gitlab
17:21@hiiamboris
Thank you again. There is not flicker on the box.
But why is it without box?
Is it bug?
9214
17:23@ushakovs_gitlab what box are you talking about?
ushakovs_gitlab
17:26@9214
>
>  view [
> 	title "Flicker"
>     t: h5 green 130x20 "forever" rate 5
> 	on-time [t/text: mold now/time]	
> ]
>

this flicker, and this is not:
> try t: box green 130x20 font-size 15 "forever" rate 5

hiiamboris
17:29@ushakovs_gitlab box (when it's color isn't fully opaque that is) is rendered in memory on W7. Only then painted back to the screen.
Uh, actually, no, opacity has nothing to do with that. It's just that base uses internal rendering, not the old GDI crap
9214
17:30You use different types of faces, which have different rendering, as @hiiamboris already explained to you. I don't see any flickering in either case.
ushakovs_gitlab
17:31Flicker is present on Windows 7
hiiamboris
17:34In fact, this leaves me wondering if a problem in View code on W7 (eager EndPaint call?), or it's a GDI issue (we can't fix then). But it's low priority IMO ☻
9214
17:35https://github.com/red/red/issues/1990, https://github.com/red/red/issues/2293

> It's a known limitation of the Windows native widget. The default windows widget is not suitable for animation.
hiiamboris
17:40That one was fixed though. No flicker.
9214
17:43@hiiamboris I guess the comment still applies in general. gob!-based GUIs are more suitable for animation than native ones.
hiiamboris
17:56Fair enough
nedzadarek
18:55@ushakovs_gitlab @hiiamboris posted nice code.
But about
> I want to drag window by "passive" faces such as text, box, etc and by empty window area as well. On the other hand "active" faces such as button, check slider, etc should respond by mouse as usual.

I don't know whenever or not "empty window area" is easy to do. You may try [global handlers](https://doc.red-lang.org/en/view.html#_global_event_handlers) but they are not easy to do and they can mess up your code. Maybe someone would make some examples using them for you. Good luck.
18:56ps. rule of thumb: quote/link a message. I may remember my yesterday's post... but 4 days is a long period of time.
ushakovs_gitlab
19:00@nedzadarek
This code make draggable empty window easy.
f: view/options/flags/no-wait [
] [options: [drag-on: 'down]] 'no-title
nedzadarek
19:03@ushakovs_gitlab nice :clap:

semiherdogan
11:43Hi everyone,
After updating to latest build, red started to slow down.
After 10 minutes i can not use it without stop and restart the red application.
Also after 10 minutes when hitting ctrl + c for quit waits for couple of seconds.
Is there anyone who has the same issue?
11:44[![Oct-09-2019---14-11-57.gif](https://files.gitter.im/red/help/Jp71/thumb/Oct-09-2019---14-11-57.gif)](https://files.gitter.im/red/help/Jp71/Oct-09-2019---14-11-57.gif)
9214
11:48https://github.com/red/red/issues/4058
semiherdogan
11:56thanks, is there any way to download a build from 1/2 months ago?
9214
12:00@semiherdogan you can build console from Github repository at specific commit, if you need to.
12:03@rebolek is your build server still running?
rebolek
12:04 @9214 I was getting it back to work today, but then the VPN provider had an outage that's still not fixed. So the short answer is no, it's not working right now.
semiherdogan
12:39i have builded from "f753e25c" and it's ok now, thank you.
GiuseppeChillemi
21:31
code: [prin a]. It uses the global word a which is "Hello".
The I use this code inside a function where a is set to ciao
I undestand code: [prin a] retrieves a from the global context but using
bind second code 'myprint
I supposed I would bind a locally
... but
it doesn't

Here are all attempts

a: "hello"
code: [prin a]
myprint: function [x] [do code print x]
myprint " world!"

a: "hello"
code: [prin a]
myprint: function [n x] [prin [n " > "] a: "ciao  " do code print x ]  
myprint "1) A set to -ciao- in function" " World!"

a: "hello"
code: [prin a]
myprint: function [n x] [prin [n " > "] a: "ciao " do code print x ] 
bind code 'myprint 
myprint "2) Binding -code- the block store word" " World!"

a: "hello"
code: [prin a]
myprint: function [n x] [prin [n " > "] a: "ciao " do code print x ] 
bind second code 'myprint
myprint "3) Binding the -a- in /code/ block to 'myprint' " " World!"
;I was  expecting this last one to work


Here is the output

------ Using Function ------
hello world!
1) A set to -ciao- in function  > hello World!
2) Binding -code- the block store word  > hello World!
3) Binding the -a- in /code/ block to 'myprint'   > hello World!
>>


Last one should output ciao World!

How could I define global code and let it use words in an autolocalizing function ? (hope it is the correct terminolgy)>

toomasv
03:15@GiuseppeChillemi
a: "hello"
code: [prin a]
myprint: function [n x] [prin [n " > "] a: "ciao " do bind code :myprint print x] 
myprint "4) `a` in `code` block can be bound to context of `:myprint` only when function's context is available, i.e. inside the function" " World!"

Output:
4) `a` in `code` block can be bound to context of `:myprint` only when function's context is available, i.e. inside the function  > ciao  World!

And then, as told:
>> do code
*** Script Error: context for a is not available
*** Where: do
*** Stack:  

>> do bind code system/words
hello

>> do bind code :myprint
*** Script Error: context for a is not available
*** Where: do
*** Stack:
GalenIvanov
06:58The standard output of a date is
06:59
>> now/date
== 10-Oct-2019
07:00How can I use the Additional formats when followed by T?
07:01I need the date to be shown as
07:01Currently I have this:
07:03
>> a: now/date
== 10-Oct-2019
>> rejoin[a/2"-"a/3"-"a/4]
== "2019-10-10"
>>
hiiamboris
07:05you better pad months and days /with #"0"
07:05otherwise, your solution works, doesn't it?
GalenIvanov
07:06@hiiamboris Thank you. Yes, it works. I just don't know how the formats work with this T
07:07From the documentation:
07:07Additional formats when followed by T:
-W -W- -
hiiamboris
07:10these are formats Red can read, I don't think a formatting func exists yet
GalenIvanov
07:12@hiiamboris OK. I thought they can be used for output.
pekr
07:37Soon I will have oportunity to do small integration myself. I am supposed to read https:// page, but it will require a login. Does Red has anything like read/custom allowing me to specify the header? Maybe it will be part of the URL, I don't know yet. Sorry if the question is naive and answer obvious :-)
rebolek
07:37@GalenIvanov not yet. There will be format function that will take care of it, but that's under development still.
GalenIvanov
07:38@rebolek Thank you for this info.
rebolek
07:40@pekr There is write/info for this. You can also use [http-tools](https://github.com/rebolek/red-tools/blob/master/http-tools.red) that make it simpler.
07:43If your login is done using basic authentication, there's direct support in send-request, so you don't have to construct custom header.
endo64
07:54@GalenIvanov Also check @greggirwin 's formatting functions: https://github.com/greggirwin/red-formatting?files=1
rebolek
07:55@endo64 yes, that's what I meant, sorry for not posting the link :)
GalenIvanov
07:57@endo64 Thank you!
pekr
08:16@rebolek I should use write/infoto read the page? :-) Thanks for the http-tools tip, will surely look into that ....
rebolek
08:17You use it for writing the request. But yes, it may seem bit confusing :) It's still simpleIO, this may change in the future.
08:18send-request does a lot of error checking and conversions, so you don't run into troubles with using write/info directly.
pekr
08:24OK, whatever works to quickly mock-up a solution :-)
toomasv
08:49@GiuseppeChillemi Something more to get an idea of binding:
lang: #()
foreach [l h][
	Italian "ciao" Russian "привет" Spanish "hola" French "salut" Czech "ahoj" 
	Polish "cześć" German "hallo" Estonian "tere" Finnish "hei" Portugese "olá"
][
	lang/:l: context compose [hello: (h)]
]
say: func [phrase '_ 'language][print rejoin bind bind phrase :say lang/:language]
sentence: ["Greeting in " language " is: " hello]

>> say sentence in Italian
Greeting in Italian is: ciao
>> say sentence in Czech
Greeting in Czech is: ahoj
>> say sentence in Polish
Greeting in Polish is: cześć
>> say sentence in Russian
Greeting in Russian is: привет

GiuseppeChillemi
09:12@toomasv (Note, I am answering to your first message and not to the last one which I can't read ATM).
I thought that once you make a function for the first time context was always available to rebind a word to that function.
toomasv
09:13It is not. Functions' context is available only while it is running.
GiuseppeChillemi
09:18This give me a false sense of function context recreation at each run of the function but I suppose it always exists and its only made visible at function run. Doesn't it ?
toomasv
09:27I am dark in these matters (but it's about stack and heap :eyeglasses: )
GiuseppeChillemi
11:34Maybe the context is "offline" but I don't know where to find documentation about this, so I have asked here.
11:35(I know what stack is but nothing about heap. Wikipedia will help)
toomasv
11:57[Intro](https://www.gribblelab.org/CBootCamp/7_Memory_Stack_vs_Heap.html) based on c.
hiiamboris
15:55Function context exists always and you can bind stuff to it:
>> f: func [/local a] [a: 100 print msg]
== func [/local a][a: 100 print msg]
>> msg: bind ["a is" a] :f
== ["a is" a]
>> f
a is 100

However, as function has to have a separate arguments for each invocation (suppose it's recursive?), that context's values are unavailable when the function isn't invoked. When it is, you can only access the topmost set of arguments.
9214
16:27Object's context have indefinite lifetime, and lifetime of function's contexts is limited by their invocation. Each context is a "table" with two series - words and values. Words are static and cannot be extended / modified after context's creation, values can be changed. values in object's context lives on a heap as a series!, and in function's context it simply points to argument stack (which is a series! too, but not directly accessible).

So, you can access function's context (which is function! value itself) at any time, but words bound to it obtain their values only when they are pushed on the stack (i.e. when function is invoked). Rebol3 introduced closure! datatype, which has indefinite lifetimes and is more similar to functions in FP. Rebol2 IIRC has this by default:
>> foo: has [x][x: 1 [x]]
>> foo
== [x]
>> reduce foo
== [1]

Compare to Red:
>> foo: has [x][x: 1 [x]]
== func [/local x][x: 1 [x]]
>> foo
== [x]
>> reduce foo
*** Script Error: context for x is not available
*** Where: reduce
*** Stack:

hiiamboris
17:23Great explanation @9214 ☺
So in R2 every function call was like a new object creation, sort of... Wow
ushakovs_gitlab
17:37rotate, transform, clip, etc doesn't affect on text in DRAW dialect. Is it bug, or unrealized feature?
hiiamboris
17:39@ushakovs_gitlab update your Red. I fixed it yesterday.
ushakovs_gitlab
17:46It's unbelievable coincidence! :) Thank you!
18:12I just clone https://github.com/red/red/wiki to have it offline.
But it is set of md-files. How can I browse it offline?
nedzadarek
18:14@ushakovs_gitlab try to open it with OpenOffice or your "good enough" text editor.
GiuseppeChillemi
18:45@toomasv
> [Intro](https://www.gribblelab.org/CBootCamp/7_Memory_Stack_vs_Heap.html) based on c.

Thanks. A reading for this evening.

18:48@hiiamboris
> Function context exists always and you can bind stuff to it:
>
...
> >> msg: bind ["a is" a] :f
>


So you can bind BLOCKS other than words, can't you ? Is there anything else that can be bound to a context ?
18:50Also :f returns you the context, doesn't it ?
18:52I 'll return on this explanation later.
> However, as function has to have a separate arguments for each invocation (suppose it's recursive?), that context's values are unavailable when the function isn't invoked. When it is, you can only access the topmost set of arguments.

19:08@9214 understood, but how do you pass a block of words/code to a lower context (in the sense of another caller function context) maintaining words values?
19:11(and note: I have understood there is no scope and context are not strictly hierarchical but could have mixed "direction" as there is no direction and only a fake sense of scope)
19:44(@toomasv, I have read it, so the heap is a memory region you have to manually allocate and manage, while stack is memory automatically managed where you store and retrieve elements using PUSH/POP )
giesse
20:11> So in R2 every function call was like a new object creation, sort of... Wow

Actually, no. A single object is created at function creation, then the values get pushed/popped from a stack every time the function is invoked. So you only have access to the top of the stack so to speak. So, it's not exactly a closure, but it covers some closure-like usage, and doesn't require new allocations or re-binding at function invocation, while relying on a single context implementation.
20:11(that was in reply to @hiiamboris )
20:12Red's way is more efficient but a bit more complex.

hiiamboris
07:28I see. Thank you @giesse
loziniak
12:19Hi. I try to compile a script with echo 'Rebol[] do/args %~/red-github/red.r "-d -r %script.red"' | ~/rebol +q -s, being in some other folder (let's say it's ~/work), but I get an error message:
Compiling to native code...
Script: "Red/System ELF format emitter" (none)
*** Linker Error: locked or unreachable file: /home/loziniak/work/script


Does it seem familiar for anybody?
rebred
13:01
>> a: "[1 2]"
== "[1 2]"
>> b: load a
== [1 2]
>> length? b
== 2

>> a: "[1 2][5 6]"
== "[1 2][5 6]"
>> b: load a
== [[1 2] [5 6]]
>> length? b
== 2
13:02when A is
"[1 2]"
the length of B after the load should be 1
13:03and
b: load a
should give
[[1 2]]
hiiamboris
13:09@rebred use load/all
rebred
13:11@hiiamboris great thanks!!!!!
endo64
13:43@rebred if there is only 1 value in the loaded string then load returns that value only, otherwise it returns a block of values. it is intentional behaviour.
rebred
21:03
a: [[43 773] [22 43] [71 37] [811 91] [10 11]]
remove/part skip a 2 1
== [[43 773] [22 43] [811 91] [10 11]]


this will remove the third item in the block

how do I remove the item where the index is (the second item)?

rebolek
21:06Not sure I understand, but is at what you are looking for?
>> a: [[43 773] [22 43] [71 37] [811 91] [10 11]]
== [[43 773] [22 43] [71 37] [811 91] [10 11]]
>> remove at a 3
== [[811 91] [10 11]]
>> a
== [[43 773] [22 43] [811 91] [10 11]]
rebred
21:08@rebolek perfect thank you!!!!
rebolek
21:09@rebred you’re welcome!
loziniak
22:20> Hi. I try to compile a script with echo 'Rebol[] do/args %~/red-github/red.r "-d -r %script.red"' | ~/rebol +q -s, being in some other folder (let's say it's ~/work), but I get an error message:
>
> Compiling to native code...
> Script: "Red/System ELF format emitter" (none)
> *** Linker Error: locked or unreachable file: /home/loziniak/work/script
>

>
> Does it seem familiar for anybody?

Seems like filenames with a minus "-" in name are the problem. For the sake of the post I changed file name to *"script.red"*, and originally it was *"include-rebol.red"*. I changed it to *"include_rebol.red"* and everything went smoothly. I use Arch Linux anyway, perhaps it's worth mentioning.

rebred
22:10how do I keep/trim a float number with just 2 digits after the period
22:11 let's say I have
12.1
sometimes and
12.154354
and I would like to keep it as
12.15

toomasv
05:23@rebred If you want max 2 digits after period, you can just round it:
keep round/to 12.154354 .01

But if you want exactly 2 digits, then I think some dancing is to be made, e.g. with forming and splitting and padding.
06:02
>> pad/with find/tail form round/to 12  .01 dot 2 #"0"
== "12.00"
>> pad/with find/tail form round/to 12.1  .01 dot 2 #"0"
== "12.10"
>> pad/with find/tail form round/to 12.13  .01 dot 2 #"0"
== "12.13"
>> pad/with find/tail form round/to 12.1589  .01 dot 2 #"0"
== "12.16"
06:34
preform: func [num precision][
	pad/with find/tail form round/to num 1.0 / power 10 precision dot precision #"0"
]
>> preform 0 2
== "0.00"
>> preform 12.241 2
== "12.24"
>> preform 12.1567 3
== "12.157"
rebred
10:42@toomasv great thank you!!!
toomasv
10:45@rebred :+1: [Here](https://gist.github.com/toomasv/006aaa95a0da02844916451fce8a6fcf) is one which forms percents too.
nedzadarek
13:29@toomasv how about if precision = 1 [return to-string round/floor/to number 1?
toomasv
14:11@nedzadarek precision in this func indicates number of decimals after period. When you want just integer you can truncate with to-integer or round it with round/to.
nedzadarek
14:42@toomasv
14:42:+1:
nd9600
20:53It's not possible for me to write something like
simplePattern: [
            | (x : xs) -> x * 2
            | [] -> []
]

is it?
20:54the : in the block breaks it
20:54so even [ : ] doesn't work
20:54I think I might need a different string to represent list consing
20:55(I'm trying to make something like https://caml.inria.fr/pub/docs/oreilly-book/html/book-ora016.html)
21:41I can't seem to do parse [ _: ] [ '_: ] either
this seems like a slight abuse of PARSE though

toomasv
03:07@nd9600
>> parse/case [ _: ] [quote _: ]
== true
greggirwin
03:26@nd9600 if you need to parse languages that aren't loadable Red, you have to use string parsing. Block parsing is powerful, but does mean all values have to be valid Red.
03:28As @toomasv shows, and you were on track to figure out, you can abuse things to some extent. ;^) The easier thing to do is change the dialect to use values that aren't special in Red.
toomasv
03:42@nd9600 Here are some Red ways to do this:
>> parse list: [1 2 3 4] [some [s: change skip (s/1 * 2)]] list
== [2 4 6 8]
>> parse list: [1 2 3 4] [some [s: skip (s/1: s/1 * 2)]] list
== [2 4 6 8]
>> parse [1 2 3 4] [collect some [s: skip keep (s/1 * 2)]] 
== [2 4 6 8]
>> list: [1 2 3 4] forall list [list/1: list/1 * 2] list
== [2 4 6 8]
>> list: make vector! [1 2 3 4] list * 2
== make vector! [2 4 6 8]
rebred
15:01
a: "test"
b: 3

c: 12
d: "ok"


t1: reduce [a b]
t2: reduce [c d]


write/append %ztest.txt reduce [t1 t2]

=[["test" 3] [12 "ok"]]

how do I append a new line at the end (ouside) the block ?

toomasv
15:23@rebred Does this do it as you want?
write/append %ztest.txt append mold reduce [t1 t2] newline
rebred
16:02@toomasv yes that's great thanks!!!
toomasv
16:48:+1:
rebred
20:32
>> a: round/ceiling 500 / 200
== 2

20:32
round/ceiling
does not work on integers ?
hiiamboris
20:35
>> 500 / 200
== 2
>> round/ceiling 2
== 2
greggirwin
21:39But note that // will be the new integer divide op in the future, and / will return a decimal result.
SmackMacDougal
22:17Here's one for the power Redders / Rebolers:

To further teach myself Red GUI programming, I am trying to make a ticker / scroller that will take discrete text (message), which can be clicked to launch a URL in a browser. The text of a message will start on the right hand side of the user's screen and move to the left. If the user hovers over any text, the scrolling will pause.

Here is one concept (to be coded and tested):

1. gather messages in a block of blocks (i.e., records)
2. each record is a dialect of [headline url]
3. load the messages
4. until done with messages
5. until done with next message
6. from the head of the messages take the first message
6. take a snip of the headline matching the size of the snip equal to the X portion of an offset
7. pad the front of the snipped headline to fill the field
8. update the field
9. test to see if the scroll headline is same length of message headline
10. if it is, it's time to load the next message

What are other ways to do this in Red?
greggirwin
22:24https://gist.github.com/greggirwin/0bdbac82f1731cd2b2ef4e3862128536 is an old experiment. I just ran it, though, and the font is small, so there's some regression or chance since it was written. It goes *really* fast for me though.
22:26Should be very simple to have a block of messages, and in the forever loop, in addition to resetting the x offset, change the text to the next item in the block, cycling as needed.
22:28A few other tweaks as well of course.
22:29Updating the field piecemeal will be a lot of (small) overhead. Rendering the face once and just moving it eliminates that. Moving the face also opens up the option to scroll vertically.
SmackMacDougal
22:54Hey thanks Gregg. Reading the works of others ends up being the best teacher for me.
23:03@greggirwin
>... It goes *really* fast for me though.

Was that an understatement? :smirk: Even Evelyn Wood could not keep up with that scroll speed.

rebred
23:06http://www.rebol.net/cookbook/recipes/0012.html
23:07Carl in this tutorial says you can add a key before a record block
23:09is the key just text next to a block ? just for saving it on a text file ? where do you load the key back into ?
GiuseppeChillemi
23:15How do you express code like (apologize , I am on mobile)
SmackMacDougal
23:18@rebred

Your unloaded flat file that you could view with a text editor would look like this:

[  key-1 [ record-1 ]]
[ key-2 [ record-2]]
...
[ key-n [ record-n ]]


Loaded, it would look like this:

>> db: load %db.txt
== [ [ key-1 [ record-1 ]]
[ key-2 [ record-2]] 
]


And then

>> db/1
== [  key-1 [ record-1 ]]


rebred
23:19@SmackMacDougal I see thanks! so is it a block into a block ?

what difference does it make between ex. 1 and 2 - speed ?
1.
[key-1 [ record-1 ]]

2.
[[key-1] [ record-1 ]]
GiuseppeChillemi
23:19Compose [if (length? A) = 22 [probe (row/1)]] leaving code in the first parenthesis untouched?
SmackMacDougal
23:26@rebred I'm unsure if I catch the meaning of your last question.

Even with keys, each record is one block. But the layout of a record has changed.

core: [datatype! datatype!  datatype! ]
full: [  datatype! block! ]


or looked at it another way:

new-style-record: [ key core]


Theoretically, you could have a records db of "type" core And then programmatically generate keys on-the-fly upon loading the data into memory.

23:32> what difference does it make between ex. 1 and 2 - speed ?
>
> 1.
> [key-1 [ record-1 ]]
> 
> 2.
> [[key-1] [ record-1 ]]
>


Consider:

db-keys: copy []
forall db [append db-keys db/1/1


Now:

forall db [select db/1 db-keys/2]


In #2, your key is in a block! Red or REBOL will not look into that block unless you tell either one to do so.
rebred
23:34@SmackMacDougal I see it now thank you!!
SmackMacDougal
23:35@rebred :smile: I'm glad to help you.
23:40@rebred It would have been better if I had written this for you:

[  key-1 [ data-1 ]]
[ key-2 [ data-2]]
...
[ key-n [ data-n ]]


Then it becomes easier to see:

>> records: load %db.txt


and

>> records/1
== [key-1 [data-1]]

greggirwin
23:52:point_up: [October 14, 2019 5:19 PM](https://gitter.im/red/help?at=5da502828e2e9a7c6bfb7f65) @GiuseppeChillemi there's no standard function to do that, you'll have to roll your own.

melcepstrum
00:28How to access member variable from a routine? i have this object
osc: make object! [
	c:	1.0
	s:	0.0
	co:	1.0
	so:	0.0
	setOmega: func [omega][co: cos omega so: sin omega]
	setPhase: func [phase][c: cos phase s: sin phase]
	run: func [v [vector!] n [integer!] /local t [float!]] [
			loop n [
					v/1: c
					t: (c * co) - (s * so)
					s: (c * so) + (s * co)
					c:  t
					v: next v
			]
	]
]

I want to rewrite run func in R/S. Is there some docs how to connect Red and R/S?
00:38I wrote something like this, but I don't like it
osc: make object! [
	c:	 1.0
	s:	 0.0
	co:	 1.0
	so:	 0.0
	setOmega: func [omega][co: cos omega so: sin omega]
	setPhase: func [phase][c: cos phase s: sin phase]
	run: func [v [series!] n [integer!]] [
			cs: make vector! reduce [ c s ]
			_run v n co so cs 
			c: cs/1
			s: cs/2			
	]
	_run: routine [vec [vector!] n [integer!] co [float!] so [float!] cs [vector!] /local v t p][
		v: as float-ptr! vector/rs-head vec
		pcs: as float-ptr! vector/rs-head cs
		loop n [ 
			v/1: pcs/1
			t: (pcs/1 * co) - (pcs/2 * so)
			pcs/2: (pcs/1 * so) + (pcs/2 * co)
			pcs/1: t
			v: v + 1
		]
	]
]
loziniak
00:56There's some info here: http://red.qyz.cz/red-system-from-red.html
00:57and here: https://github.com/red/red/wiki/%5BDOC%5D-Guru-Meditations
toomasv
06:38@GiuseppeChillemi One possibility:
compose/deep [if (quote (length? A)) = 22 [probe (row/1)]]

And if you have to adjust first parenthesis too, then:
compose/deep [if (to-paren compose [length? (A)]) = 22 [probe (row/1)]]
ldci
09:50@melcepstrum : some documentation about Red/system and Red connexions here https://github.com/ldci/OpenCV3-red. See in manual/ directory.
loziniak
15:04Hi! Is following code valid?
Red []
context [
	a: 123
	hidden: 999
	set 'global-exports context [
		export-a: a
	]
]
probe global-exports
rebred
15:33
a: #{6BAE43}


is there a command to remove these chars
#{}
and convert it to a string
so I can get
6BAE43
at the end ?
hiiamboris
15:38
>> copy/part next next s: form a back tail s
== "6BAE43"
9214
15:40@loziniak well, yes, if I understand you correctly. Have you spotted a problem somewhere?
15:41@hiiamboris
>> form to-hex to integer! #{deadbeef}
== "DEADBEEF"
>> enbase/base #{deadbeef} 16
== "DEADBEEF"
hiiamboris
15:42Great :)
rebred
16:32@9214 @hiiamboris great!!!
greggirwin
17:51@hiiamboris's example leads to a fun thought/code experiment. It's a special need, but if you generalize it, there are interesting things to think about. This is part of a Reducer's mindset, and how we can cover the general behavior in a doc string, but there may be subtleties we don't anticipate. Can you correctly guess all the results of running this code? I didn't.
choppy-head-tail: func [
	"Copy+chop"
	series    [series!]
	from-head [integer!] "How many to chop from head"
	from-tail [integer!] "How many to chop from tail"
][
	copy/part
		skip series from-head
		skip tail series negate absolute from-tail
]
choppy-head-tail form #{6BAE43} 2 1
choppy-head-tail "123456789" 1 1
choppy-head-tail "123456789" 3 3
choppy-head-tail "123456789" 10 0
choppy-head-tail "123456789" 10 1
choppy-head-tail "123456789" 10 10
choppy-head-tail "123456789" 0 10
choppy-head-tail "123456789" 1 10
hiiamboris
17:55☺ my guess would be: "6BAE43" "2345678" "456" "" "9" "123456789" "" "1"
endo64
19:49@rebred and also
>> trim/with form #{6BAE43} "#{}"
== "6BAE43"
toomasv
20:06After some head twisting there remains nothing to add to @hiiamboris :)
loziniak
20:22@9214 thanks! Yes, I get an error when compiling:
echo 'Rebol[] do/args %~/red-github/red.r "-u -c %b.red"' | ~/rebol +q -s
[...]
-=== Red Compiler 0.6.4 ===- 

Compiling /work/b.red ...
*** Red Compiler Internal Error: Script Error : Invalid path value: global-exports 
*** Where: register-object 
*** Near:  [objects/context/global-exports: make object! [
a: none
hidden: none
]]
20:32When interpreted, code runs ok:
~/red-13oct19-a4ee537c b.red
make object! [
    export-a: 123
]
hiiamboris
20:38@toomasv that's because I'm digging them series right now :D
greggirwin
21:12@hiiamboris @toomasv but it messes with your head a bit, or at least mine.
hiiamboris
21:15Teaches you to love symmetry though :)
greggirwin
21:17Even my smile is crooked.
GiuseppeChillemi
21:31@toomasv thanks

SmackMacDougal
02:37Hey all. Are there any Red on Linux gurus / power users?

The error returned here looks like a Red error for red-15oct19-0b80107c

$ ./vsc-red.red
** Script Error: Invalid compressed data - problem: -3
** Near: script: decapsulate 
if none? script
stone@OUTLAWOS:~/b


Here is the Enviroment (I have su privileges):

$ locate /usr/bin/red*
/usr/bin/red
/usr/bin/red-gtk

$ locate /usr/bin/atr*
/usr/bin/atronix-rebol

$ root@OUTLAWOS:/opt# locate /usr/bin/reb*
/usr/bin/rebcore
/usr/bin/rebview


Where the above are symlinks to:

stone@OUTLAWOS:~/bin
$ readlink -f /usr/bin/red*
/opt/red/red-15oct19-0b80107c
/opt/red/red-gtk
stone@OUTLAWOS:~/bin

$ root@OUTLAWOS:/opt# readlink -f /usr/bin/atronix-rebol 
/opt/atronix-rebol/atronix-rebol-linux-64bit

$ root@OUTLAWOS:/opt# readlink -f /usr/bin/reb*
/opt/rebol/rebcore
/opt/rebol/rebol


Permissions on all are rwx,r-w,r-w


I've tested the same code against these, changing only the hashbag:
* REBOL 2.7.8 View
* REBOL 2.7.8 Core
* Antronix REBOL 3.0.99.4.40
* Red GTK 3.24.5
* Red red-15oct19-0b80107c The red-gtk version works. Yes, it launches the app, but it gives a version identifier in the terminal: GTK VERSION: 3.24.5
exe: {/home/stone/Applications/VSCodium-1.38.1-1568285248.glibc2.16-x86_64.AppImage}
call/shell/console exe
`

> Note: The R2 View, R2 Core and Atronix R3 do not need the /console refinement.

Any ideas why "console" Red on Linux does not work?
loziniak
08:05It's a strange error message, @SmackMacDougal , since the line containing the string is commented in the sources:
https://github.com/red/red/blob/master/environment/system.red#L162
9214
08:17@loziniak this error message comes from Rebol SDK, and is mentioned in readme.

> Running the Red toolchain binary from a $PATH currently requires a wrapping shell script
loziniak
08:34Oh, I see. Thanks @9214 ! Regarding my [↑↑↑ problem](https://gitter.im/red/help?at=5da62a7f809de9699f4380d1), do you think it's ok to file an issue? Could you try to reproduce it?
9214
08:36@loziniak does it work with -e flag? Bear in mind that we have bootstrap static compiler that usually chokes on any dynamic code (like the one you wrote).
loziniak
08:45@9214 It works with -e, but this is problematic for me, since I have a project with Red/System code and routines.
08:46Will the problem be addressed by rewrite of the compiler in Red?
9214
08:47OK, I guess you can open a ticket. It's just that core team is busy with fast-lexer branch right now, so you might want to search for workaround while its pending.
hiiamboris
08:48do [probe ..] should work
9214
08:49Or wrap problematic part in do [...], yes. That will force it to run in the interpreter.
08:50> Will the problem be addressed by rewrite of the compiler in Red?

I don't think that rewrite will help, it needs a different architecture alltogether (like JIT planned for post-1.0 roadmap).
hiiamboris
08:52OK it works like this:
global-exports: none                    
context [                               
    a: 123                              
    hidden: 999                         
    do [set 'global-exports context [   
        export-a: a                     
    ]]                                  
]                                       
probe global-exports
loziniak
08:52Good idea. Thanks! I'll make a ticket anyway, eventually somebody will close it as needed.
08:52This worked for me:
Red []
context [
    a: 123
    hidden: 999
    do [
        set 'global-exports context [
            export-a: a
        ]
    ]
]
probe get 'global-exports
hiiamboris
08:53even simpler:
context [
    a: 123
    hidden: 999
    set 'global-exports make object! [
        export-a: a
    ]
]
probe global-exports
loziniak
08:53@hiiamboris even better, thanks!
09:31@hiiamboris BTW cool idea in [this comment](https://github.com/red/red/issues/3945#issuecomment-515228897) to automatically generate do [...] wrappers by compiler.
rebred
13:23@endo64 amazing thanks!!!!!
SmackMacDougal
15:46Here is a problem, which I shared here: [Can not Invoke Red Through a Script on Linux]( https://gitter.im/red/help?at=5da68269870fa33a4dfdb900):

So this is for those who might stumble upon the same problem of Red-based scripting not working as expected on a Linux-driven box and who need an actual how-to fix, here is one hack.

**The problem:**

> On Linux-based OS, (for now), one can not invoke the interpreter from a Red script (hashbang directive to the Linux loader) regardless of where the Red binary exists.

Here is a hack that works.

[1] Put this is a file.

#!/bin/bash 
/usr/bin/red $1


[2] Put the file on a path of the system-wide where PATH (e.g., /usr/bin) and name it redder (or whatever).

Now, from any Red script written by anyone:

#!/usr/bin/redder

Red [] 

comment {Red expressions after this comment}


On my system, /usr/bin/redis a symlink to /opt/red/[name of latest build of red].

15:57@loziniak Yeah, I solved it myself though not knowing a lick of bash scripting, because, well all scripting / command langs have alike constructs.

See the fix here: [How to Run Red Scripts on a Linux-based Box](https://gitter.im/red/help?at=5da73b5c2d59854e7f13e501)

Respectech
23:58Trying to run red-cli-191010 on an ARM64 device (ODROID-HC1) running Debian Jessie 8.11. However, Red is asking for libcrypto.so.1.1 which is in libssl1.1, but Jessie 8.11 only has libssl1.0.0 available...

Respectech
00:18So I tried the same executable on another ARM64 device (ODROID-N2) running Ubuntu 18.04. Same error:
# ./rpi-cli-191010
./rpi-cli-191010: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory
# apt install libssl1.1
Reading package lists... Done
Building dependency tree
Reading state information... Done
libssl1.1 is already the newest version (1.1.1-1ubuntu2.1~18.04.4).
00:19Any ideas?
rebolek
06:00@Respectech I just symlinked the file on Turris Omnia and it seemed to work. Unfortunately, there are other problems with that machine, so I can't comment about the functionality of this solution.
rebred
13:01
a:[[3 10][2 4][1 1]]
print mold a
=[[3 10] [2 4] [1 1]]

is there a way to print the block inside the block (without the external brakets) like:
[3 10] [2 4] [1 1]
rebolek
13:02
>> mold/only a
== "[3 10] [2 4] [1 1]"
rebred
13:03@rebolek great thanks!!!!
rebolek
13:03You're welcome
rebred
17:39
a:[[3 10][2 4][1 1]]

how do I change last block with [2 2] like:
a:[[3 10][2 4][2 2]]
9214
17:41@rebred how would you go about solving this?
rebred
17:42@9214 I know that
last a
gives
[1 1]
17:42but how do I set it
9214
17:48@rebred okay, that's a start. Having [1 1], can you change (hint) it to [2 2]?
17:48And knowing that it's a 3rd element, can you index it via path and set to something else?
rebred
17:51
change/part back tail a [[2 2]] 2
17:51great thanks!!!! is there anything terser then this ?
hiiamboris
18:18change last a [2 2]
9214
18:18a/3: [2 2]
hiiamboris
18:19Indeed :)
SmackMacDougal
23:19@rebred

While those other ways are terse, those won't help you programmatically, i.e., if you need your Red app to do stuff during run time, at least the direct setting a/3: [2 2] way.

Another way:

>> poke a index? find/only a [1 1] [ 2 2]
== [2 2]
>> a
== [[3 10] [2 4] [2 2]]


or perhaps better:

>> a/(index? find/only a [1 1]): [2 2]
== [2 2]
>> a
== [[3 10] [2 4] [2 2]]


Of course too, if you had found the index where the cursor is or where you expect it to be, and set a word cursor: to it, then you can do:

a/:cursor:  [2 2]

rebred
00:17@hiiamboris AMAZING THANKS!!!!!!!
13:26 I guess the money! datatype is not yet implemented?
hiiamboris
13:50Yes.
rebred
16:35is there a way around to make wildcards work in
find
hiiamboris
16:37Use parse :)
16:38Actually I might have something for you...
16:39https://gitlab.com/hiiamboris/red-junk/raw/master/glob/glob.red
Here the compile1 function transforms a string with wildcards into a parse expression.
toomasv
16:51@rebred My [try](https://gist.github.com/toomasv/8562fb66e0b8dc4ef9b0b51dc280cbd4) from a year ago. Seems still to work.
hiiamboris
17:06:+1: @toomasv
17:11@toomasv you need to make thru argument a block though, for backtracking, like I did:
>> find'/any "abcdef abcdefg abcdefgh" "*d?fg*?h"
== none
toomasv
17:34@hiiamboris Can't wrap my mind around this now - can you point me what I have to change? :flushed:
hiiamboris
17:49@toomasv you basically wrap the rest after the thru-rule into a block:
thru ["d" skip "fg" thru [skip "h"]]
17:50So that thru won't just find "d" and be off, but will continue looking until the whole rule succeeds
17:55I wonder if this will also work though:
thru ["d" skip "fg"] thru [skip "h"]
17:56Can't think of a case where it will not right now anyway :)
toomasv
18:25@hiiamboris OK, thanks! Done.

SmackMacDougal
01:38Who is smart here? Any ideas?

Red doc:


> A vector! value is an ordered sequence of values of identical type ...

Presumably, the idea behind a vector is to facilitate any math operation to every element of a series.

Said generally, a vector datatype explicit in any language exists to allow so-called vectorized operations, i.e., the application of operations to an entire set of values at once.

Having such a construct frees the programmer from writing loops to apply individual scalar operations.

**This is an expected result:**

>> v: make vector! 11
== make vector! [0 0 0 0 0 0 0 0 0 0 0]
>> v + 1
== make vector! [1 1 1 1 1 1 1 1 1 1 1]


**This is not:**

== make vector! [0 0 0 0 0 0 0 0 0 0 0]
>> v + 0.1
== make vector! [0 0 0 0 0 0 0 0 0 0 0]


**What is expected is this:**

== [0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1]


Also, this puzzles:

>> integer? 0
== true


Zero is not an integer. Zero is a placeholder. It represents nothingness.

Yes, I know that Carl's REBOL recognized zero as an integer, but if zero must be a number for convenience sake, should it not be a float!?

Now, Nenad designed Red to allow this:

>> r:  make vector! [float! 64 [0.0 0.0 0.0 0.0]]
== make vector! [0.0 0.0 0.0 0.0]
>> r
== make vector! [0.0 0.0 0.0 0.0]
>> type? r/1
== float!
>> r + 0.1
== make vector! [0.1 0.1 0.1 0.1]


But you must hand code those 0.0s.

This is not expected:

>> r: make vector! 5 [float! 64 [0.0] ]
== [float! 64 [0.0]]
>> r
== make vector! [0 0 0 0 0]


So does it mean the spec block! of a vector! must be set up ahead of time by the user before being vectorized via a make vector!?
rebolek
05:30Yes, you must set up the spec block ahead. Unlike block, vector is not composed from red values, but is allocated directly in memory (so it's more similar to binary!, than to block!). The idea behind vector is to make memory efficient data structure for numbers. See this http://www.rebol.net/r3blogs/0079.html
toomasv
06:06In your last example you first set r to make vector! 5 (with default 0s) and then return spec block. make takes *always* two arguments: type and spec (which may be simple as 5, or block).
You don't need to hand-fill:
>> r: make vector! [float! 64 5]
== make vector! [0.0 0.0 0.0 0.0 0.0]
meijeru
07:56Interesting! My old complaint was that make vector! always produced componenets of type integer! 32, and that it was therefore not possible to initialize to float!. But now I see the solution. Have updated my spec document with this possibility that I had left out because I did not know it.
melcepstrum
09:40@loziniak @ldci thanks! #get is what I was looking for
10:23how can I make a copy of an object containing a vector! ?
>> o: object [ a: 1 b: [ 2 3 ] c: make vector! [ 4 5]]
== make object! [
    a: 1
    b: [2 3]
    c: make vector! [4 5]
]

if I make a copy of this object b and c is pointing to the same data
>> p: copy/deep o
== make object! [
    a: 1
    b: [2 3]
    c: make vector! [4 5]
]

copy/deep created a copy of block but not vector
>> p/a: 6    p/b/1: 7    p/c/1: 8      p
== make object! [
    a: 6
    b: [7 3]
    c: make vector! [8 5]
]
>> o
== make object! [
    a: 1
    b: [2 3]
    c: make vector! [8 5]
]
>>

hiiamboris
10:38@melcepstrum copy/deep/types isn't implemented yet, see https://github.com/red/red/issues/2254
For now you should copy everything that isn't in the series! typeset, manually.
toomasv
10:38You can do this:
>> p: make o []
== make object! [
    a: 1
    b: [2 3]
    c: make vector! [4 5]
]
>> p/a: 6 p/b/1: 7 p/c/1: 8 p
== make object! [
    a: 6
    b: [7 3]
    c: make vector! [8 5]
]
>> o
== make object! [
    a: 1
    b: [2 3]
    c: make vector! [4 5]
]
hiiamboris
10:39Great workaround :)
toomasv
10:41:smile:
melcepstrum
10:55thanks!
toomasv
11:10:+1:
loziniak
11:23@melcepstrum you're welcome! Can you share an example of your #get usage for future generations? :-)
melcepstrum
11:33
osc: make object! [
	r: make vector! [1.0 0.0 1.0 0.0]
	setPhase: func [phase][r/1: cos phase r/2: sin phase]
	setOmega: func [omega][r/3: cos omega r/4: sin omega]
	run: routine [vec [vector!] n [integer!]  /local v r t  ][
		v: as float-ptr! vector/rs-head vec
		r: as float-ptr! vector/rs-head as red-vector! #get self/r
		loop n [ 
			v/1:  r/1
			  t: (r/1 * r/3) - (r/2 * r/4)
			r/2: (r/1 * r/4) + (r/2 * r/3)
			r/1: t
			v: v + 1
		]
	]
]

GiuseppeChillemi
11:36I have not understood what MAP! is useful for. I see a block of #(key value) pair which is its practical use ?
nedzadarek
12:21@GiuseppeChillemi a map! value is useful when you need only key-value container (e.g. value that describe person #(name: "Foo" surname: "Baz")) but you don't need to really on other values (object!) and you don't need complicated data structure (block!). It's easier to add to a map! than to a block! (it's currently impossible to add to an object!).
ps. you can shoot yourself in the foot while using a block!:
>> a: [a b b c]
== [a b b c]
>> a/b
== b
>> m: #(a: b b: c)
== #(
    a: b
    b: c
)
>> m/b
== c
12:22There might be difference in a speed but you have to test it on your own... on some bigger examples.
GiuseppeChillemi
12:40Could you have a map insidea map to replicate row/key/value working or is there another and better way of doing this ?
nedzadarek
12:58@GiuseppeChillemi yes:
m: #(
    1 #(x: 1 y: 2)
    2 #(x: 2 y: 3)
    4 #(x: 4 y: 1)
)

but in my opinion block + map combination is better to show numerical elements (without map's redundancy), e.g.:
bl: [
    #(x: 1 y: 2)
    #(x: 2 y: 3)
    #(x: 4 y: 1)
]
13:02If your rows have the same structure (e.g. have x & y keys, and numerical values) then you can use block within block:
bl: [
    [x 1 y 2] 
    [x 2 y 3] 
    [x 4 y 1]
]

Both have the same accessing syntax: / eg. bl/1/x.
13:05You can just as well delete x and y in the above example... but it would just obscure your code... I'm not sure if you want this.
GiuseppeChillemi
13:32I still don't understand the advantage of maps as I can actually change-add-remove key/value pairs on a block with function which replicate put and companions.
hiiamboris
13:59@GiuseppeChillemi https://en.wikipedia.org/wiki/Hash_table#Advantages
GiuseppeChillemi
14:14@hiiamboris
> If your rows have the same structure (e.g. have x & y keys, and numerical values) then you can use block within block:
>
> bl: [
>   #(x: 1 y: 2)
>   #(x: 2 y: 3)
>   #(x: 4 y: 1)
> ]
>

> Both have the same accessing syntax: / eg. bl/1/x.

So in the example above we have hash table only on the inner elements of the map blocks but not on the outer (block) element. While map-in-map have the hashtable everywhere advantage.
nedzadarek
14:26@GiuseppeChillemi with blocks you can do anything. You can use numbers for characters
> C uses char type to store characters and letters. However, the char type is integer type because underneath C stores integer numbers instead of characters.

[Source](https://www.zentut.com/c-tutorial/c-character-type/)

But you are using types like char! or string!.

What is important is:
- 1) what you cannot do
- 2) how you do it
- 3) how certain "name" suggest usage


1) You cannot mess your value - you cannot delete just a value, leaving a key intact. You cannot get wrong value (e.g. a key instead of a value - like I mentioned earlier).
2) It's easier to do some things with maps. For example set syntax (word: value) is more readable than calling a function (e.g. put or append).
3) When you use block! as type in a function declaration I'm not sure whenever or not you want to use it as key-value container or some other, esoteric, data structure. map! on the other hand suggest key-value container.

It may not be important for you but things like readability and limitations are somehow important for me.
SmackMacDougal
14:51@rebolek Thank you for that link.
14:58@toomasv Thank you Toomas. The spec was unclear to me: [Red Programming Language Documentation: vector!](https://doc.red-lang.org/en/datatypes/vector.html)

The examples shown were:

make vector! init-size


and

make vector! [ datatype! byte-size block! ]


So the doc was not clear to me that this is possible:

make vector! [ datatype! byte-size init-size ]


But thanks to you, it is clear now.



hiiamboris
15:09@gltewalt :point_up:
SmackMacDougal
15:31The [current documented specification for vector!](https://doc.red-lang.org/en/datatypes/vector.html#_runtime_creation) in the [Red Official Documentation](http://doc.red-lang.org/), which is "under construction" is written as:

<vector> ::= make vector! <vector-spec>
<vector-spec> ::= <block> | [ <type-and-size> <block>]
<type-and-size> ::= char! 8 | char! 16 | char! 32 |
                    integer! 8 | integer! 16 | integer! 32 |
                    float! 32 | float! 64 | percent! 32 | percent! 64


Should it not be written as this:


<vector> ::= make vector! <vector-spec>
<vector-spec> ::= <integer> | <block> | [ <type-and-size> <block> | <integer>]
<type-and-size> ::= char! 8 | char! 16 | char! 32 |
                    integer! 8 | integer! 16 | integer! 32 |


Examples that show what the updated doc spec should be written as:

### 1 ::=

>> make vector! 5
== make vector! [0 0 0 0 0]


### 2 ::=

>> make vector! [10 20 30 40 50]
== make vector! [10 20 30 40 50]


### 3 <vector-spec> ::= [ <type-and-size> <block>]

>> make vector! [float! 32 [10.0 20.0 30.0 40.0 50.0]]
== make vector! [float! 32 [10.0 20.0 30.0 40.0 50.0]]


### 4 <vector-spec> ::= [ <type-and-size> <integer>]

>> make vector! [float! 32 5]
== make vector! [float! 32 [0.0 0.0 0.0 0.0 0.0]]


#4 is missing from the doc spec as of now.
15:49In [current documented specification for vector!](https://doc.red-lang.org/en/datatypes/vector.html#_runtime_creation) in the [Red Official Documentation](http://doc.red-lang.org/), which is "under construction" is an example section written as:

If an integer! or float! value is supplied to make, a vector will be created of size N with values initialized to 0.

>> make vector! 3
== make vector! [0 0 0]

>> make vector! 3.0
== make vector! [0 0 0]


But if someone does the second of the two, as in:

>> v: make vector! 3.0
== make vector! [0 0 0]


Expectations will not be met by newcomers:

>> v  + 0.7
== make vector! [0 0 0]
>> v
== make vector! [0 0 0]


Because 0 is an integer!

>> float? 0
== false
>> integer? 0
== true


And as Boleslav Březovský (@rebolek) explained:

> Unlike block, vector is not composed from red values, but is allocated directly in memory.

So a future Red coder will need to know about how to overcome this unclear gotcha by this:

>> decv: make vector! [float! 64 3]
== make vector! [0.0 0.0 0.0]
>> decv + 0.7
== make vector! [0.7 0.7 0.7]


So if a vector creation (make) allocates memory directly, should the internals have a change to meet expectation as this:

>> ;; pseudo. does not work in Red, currently
>> make vector! 3.0
== make vector! [0.0 0.0 0.0]


In other words, should not make vector 3.0 meet users' likely expectations and allocate 3 float! (a 64-bit positive or negative number that contains a decimal point per the doc spec) and not allocate 3 integer! (32-bit numbers with no decimal point per the doc spec)?




toomasv
15:53But 3.0 indicates only the size of vector here, not its contents. It says: "Gimmy a vector with 3.0 elements." And it gives a vector of required size with default elements, as specific contents were not indicated.
SmackMacDougal
15:54OK, but does it not populate contents though by its use?
15:57
>> stuff-exists: make vector! 5
== make vector! [0 0 0 0 0]

Not only specifies a size (the memory alloc for 5 32-bit integer!) but also returns 5 zeros of 32-bit integer!

So it is doing more than merely the size.
toomasv
15:58Yes, it populates it with defaults.
SmackMacDougal
15:58Right, and it is unclear how it works. It is unclear in the docs and it is inconsistent in design.
toomasv
15:59I agree, that docs should be amended. Thanks for pointing this gap out! But how is it inconsistent in design?
SmackMacDougal
16:10How? I pointed it out already, but here goes again.

This "constructor" returns a default "config" of 5 zeros of 32-bit integer! In Red, all integer! are 32-bit

>> ivec: make vector! 5
== make vector! [0 0 0 0 0]


But this "constructor" does not return 5 zeros of 64-bit float! In Red, all float! are 64-bit.

>> fvec: make vector! 5.0


it should return:

== make vector! [0.0 0.0 0.0 0.0 0.0]


rather than what it does

== make vector! [0 0 0 0 0]


And there is your design inconsistency.

The current design implies this: "It does not matter what you put for the size, it always returns type 32-bit integer! with a zero as a placeholder.

>> make vector! pi
== make vector! [0 0 0]


Why return the zeros then if it is merely a 32-bit memory allocation of slots by count?





16:12Technically then, Red should let you do this:

>>make vector! #"a"


if it always return only an integer! allocation.
hiiamboris
16:13What on earth vector *length* has to do with vector *item type*?
SmackMacDougal
17:17Exactly.

This:

>> b: make vector! 5
== make vector! [0 0 0 0 0]


is a shortcut for this:

>> a: make vector! [integer! 32 5]
== make vector! [0 0 0 0 0]


As seen by:

>> type? a/1
== integer!
>> type? b/1
== integer!


Yet, why allow the first construction at all, if one can not do this:

>> c: make vector! 5.0
== make vector! [0.0 0.0 0.0 0.0 0.0]


Or why allow this?

>> d: make vector! 5.0
== make vector! [0 0 0 0 0]


Instead of returning this:

>> d: make vector! 5.0
*** Script Error: cannot MAKE vector! from: 5.0
*** Where: make
*** Stack:


Proper product design reveals consistency. Clearly, you can not have a count of 5.0 things in real life. You can have a count of 5 things.

The inconsistency, of course, is the overloading of the word size here. Typically, in comp sci, size specifies the memory allocation in RAM of a partitioned section of RAM for a kind of data in compiled languages. Hence, this is why in languages like C and Pascal, one specifies a type by an identifier, i.e. to tell the compiler at compile time to allocate memory of a size, which will hold datum of a specific type only.

In short, the programmer is responsible for memory and its use. If the programmer has done right, the compiler will follow his instructions, compile and the programmer's code in his program will work flawlessly.

But here with interpreters and their languages, such as Red, size, means count, i.e., the number of elements. Length, too, means count and not size (memory). To speak of the size or length of a block! in Red (or REBOL) is sloppy. It is adopted convention, perhaps, from another's long ago error, but it is a communication error still, or at least communication misleading. It is trying to take speaking language from compiled languages and applying it to interpreted languages when discussing things.

Sure, when one does a make vector! 5, the implication is make vector! [integer! 32 5], i.e., one wants slots for five integer "thingies" So if that is implied, then too, to be design consistent, make vector! 5.0 should imply make vector! [float! 64 5] or it should be disallowed to result with the implication make vector! [integer! 32 5].








hiiamboris
17:23Apparently float size support is just a convenience thing, so that one can omit an explicit to-integer conversion (if I'm using an expression to calculate the size).
SmackMacDougal
17:27But how it is a convenience? Why would anyone type 5.0 rather than merely 5 when typing make vector! whether in a file or at the REPL console?

A true convenience would be to to return this:

== make vector! [0.0 0.0 0.0 0.0 0.0]


from this:

>> make vector! 5.0



hiiamboris
17:28Like make vector! stuff / other-stuff + more-stuff * dont-forget-the-most-important-stuff
rebolek
17:36make vector! float! doesn’t seem like that bad idea to me. It’s an unexpected shortcut if you look at how things work in Redbol in general, OTOH it doesn’t break anything. But there can’t be such shortcuts for 8/16 bit integers (and I’m talking how sign fits there), so I’m not sure if it’s worth adding.
SmackMacDougal
17:37Agreed. There should not be shortcuts for the others.
17:42In the data sci world, working with decimals (human view of data) is predominant. e.g., expenditures, ratio results, etc. Working with integers more or less only comes up with population counts.

So make vector! 5.0 to get this == make vector! [0.0 0.0 0.0 0.0 0.0] would fit in with the work flow and well, be design consistent. Otherwise, it should result in an error, rather than return integer! 32 zeroes.
hiiamboris
17:45Will the resulting vector be of float32 or float64 type?
SmackMacDougal
17:51It ought to be float! 64 since in Red, doing this:

>> f: 99.9
== 99.9
>> type? f
== float!


Gets you this per the design of Red:

> A float! value represents a 64-bit positive or negative number that contains a decimal point.

see: [Red Doc Official](https://doc.red-lang.org/en/datatypes/float.html)
hiiamboris
17:56Sure.
17:57Make a REP if it's worth it to you. https://github.com/red/REP/issues
GiuseppeChillemi
18:08@SmackMacDougal
>> fvec: make vector! 5.0

The <type-and-size> is being abstracted by your mind and associated to other elements in the mechanism you are trying to understand. You concluded that expressing length number in a different way let change data type of the vector:

So:

5.0 -> size 5 , it is expressed as float -> vector elements type = float
5 -> size 5 it is expressed as integer -> vector elements type = integer

Instead:

5.0 is read as 5 from RED vector constructor and it represents only its *size(:lenght)* regardless of the type of number you use to express *size(:lenght)*

While to express type-and-size of the data of the vector RED uses only the type expressed inside the block specs.

[float! 32 [10.0 20.0 30.0 40.0 50.0]]

Looking at 5.0 while thinking about the creation of vectors, type-and-size caused this. Your neurons abstracted the *type and size* concept and you supposed that the type of data inside the vector depends on the way to express the number5 (association to the most compatible item). So, 5 should create [0 0 0 0 0] while 5.0 [0.0 0.0 0.0 0.0 0.0].

This effect depends from:
**---------------------------------------------------**

1) the following description: *[ <type-and-size> <block>]*

2) having 5.0 and 5 containing the concept of type-and-size of the vector block too

3) example blocks with both forms [0.0 0.0 ....] and [0 0 ...]

4) <type-and-size> being written in a generic way.

and

5) thinking about how vectors make constructor express type and size while looking at everything, included your own example blocks.
**---------------------------------------------------**

Being more specific (see later) would solve such kind of problems and restrict the association range.

Also, I think too the description should be changed to:

::= | | [ | ]

But I think it should be changed to:

<vector-spec> ::= <integer> | <block> | [ <type-and-size-OF-DATA> <block> | <integer>]

Explaining that integer represents *LENGTH* of the vector block

So <type-and-size> of datatype and vector block won't mix in newcomers heads with type and size of the number which, alone, expresses the block length.
SmackMacDougal
18:34@hiiamboris

> You can't perform that action at this time.

per Github
18:36@GiuseppeChillemi Yeah, I get how it works. It it an inconsistent design.

make vector! 5 is a shortcut to make vector! [integer! 32 5]

and anything put after make vector! that isn't a block!, Red tries to coerce to an integer!. That is a flawed design.
GiuseppeChillemi
18:39It doesn't coerce but I suppose it creates integers as defaults.
18:43 You can provide extended specs if needed if you give the constructor a block as argument.
SmackMacDougal
18:43It does not? How does 5.0, a float! 64 become 5, an integer! 32 if not by coercion in this?

>> a: [5.0]
== [5.0]
>> type? first a
== float!
>> make vector! first a
== make vector! [0 0 0 0 0]

GiuseppeChillemi
18:46You have to unrelate the type of the number to express the length to the vector data type.
18:47(corrected)
SmackMacDougal
18:48I get how it works. Are you confused because, wrongly, you think I am confused?

It shows design inconsistency. Where else in Red (or REBOL) are coercion of this type done?

GiuseppeChillemi
18:59RED perform this kind of code:

case [
  (type? ARG) = number! [create vector of INTEGERS of length = ARG]
  (type? ARG) = block! [create vector as provided spec]
   true [print ["Error, you have not provided a valid argument"]]
]


RED(REBOL) treats the integer as... number! it does not coerce, it is simply not interest wheter it is a FLOAT! or INTEGER!

Please take al look at the following code:

>> 5 = 5.0
== true
>>
 ```

Above RED is working on equality non being strict

And

Now on equality being strict `==`

>> 5 == 5.0
== false
`


19:02Experienced programmers will explain to you better this concept than me.
SmackMacDougal
19:02Fine but where in Red (or in REBOL) does constructor coercion happen? There is plenty of type restriction:

>> ? repeat
USAGE:
     REPEAT 'word value body

DESCRIPTION: 
     Evaluates body a number of times, tracking iteration count. 
     REPEAT is a native! value.

ARGUMENTS:
     'word        [word!] "Iteration counter; not local to loop."
     value        [integer!] "Number of times to evaluate body."
     body         [block!]


Clearly, this will fail

>> repeat 5 5 [print "5"]
*** Script Error: repeat does not allow integer! for its 'word argument
*** Where: repeat
*** Stack:


Because the Red interpreter only allows args of type [word!] to the first parameter.
19:04> Experienced programmers will explain to you better this concept than me.

I have worked as an experienced (paid) programmer, long before REBOL was in the imagination of Carl.

Are you trying to offer apologetics for what is clearly an inconsistency of design?
rebolek
19:05> There is plenty of type restriction

Right. Maybe there should be a restriction on vector length type. If it would be limited to integer only it would probably make things simpler to understand.
hiiamboris
19:07There's an opposite talk, of allowing every /part argument accepting a float! value
SmackMacDougal
19:07The fix is easy:

Either this:

>> make vector! 5.0
== make vector! [0.0 0.0 0.0 0.0 0.0]


or this:

make vector! 5.0
*** Script Error: cannot MAKE vector! from: 5.0
*** Where: make
*** Stack:


Because this:

make vector! 5.0
== make vector! [0 0 0 0 0]


is design-inconsistent.

**Behold**
>> loop 5.0 [print "see"]
*** Script Error: loop does not allow float! for its count argument
*** Where: loop
*** Stack:
GiuseppeChillemi
19:08@rebolek you should simply describe vector constructor in a different way:
<vector-spec> ::= <number!> | <block> | [ <type-and-size-OF-DATA> <block> | <number!>]

*Explaining that integer represents LENGTH of the vector block*
19:09(Note, I have changed the message above)
rebolek
19:10@SmackMacDougal I vote for the second option. You should make a ticket for it, so it won't get lost.
SmackMacDougal
19:10I tried the REP thingy, but after a 10 minute edit / write up, Github did not allow it to go through. Where is the ticket thingy?
rebolek
19:11https://github.com/red/red/issues
SmackMacDougal
19:11@rebolek Thank you.
rebolek
19:12but I guess that same Github rules would apply for it.
GiuseppeChillemi
19:15@SmackMacDougal
>
> make vector! 5.0
> == make vector! [0 0 0 0 0]
>

>
> is design-inconsistent.

It isn't as nowhere has be explained that vector type is inferred from the type of the number used to express its size

This would be inconsistent:


make vector! 5.0
 == make vector! [5 5 5 5 5]


;-)

Simply you are coming from language where implicit datatype information in the representation is used to buil things RED does not work this way. RED is flexible and this constructor does not use the TYPE information at all.
SmackMacDougal
19:17
Simply you are coming from language where implicit datatype information in the representation is used to buil things RED does not work this way. RED is flexible and this constructor does not use the TYPE information at all.

@GiuseppeChillemi Dude, you need to stop making assumptions about me. I let the first round of your assumptions slide by, but now I must put the brakes on you. Stop it already. Ask rather than assume, m'kay?

I'm coming from REBOL, with of years experience with it.
>
GiuseppeChillemi
19:17Someone else could come from another language and have a different way of interpreting this constructor. Doc simply have to be more descriptive.
SmackMacDougal
19:22It's flawed, design inconsistent.

Where else does REBOL (Red is supposed to be 95% compatible) or Red do this kind of conversion for someone?

And who would take the time to type as code: make vector! 5.0 when they can simply type make vector! 5.


There is no design justification for it. If it exists, then so too this should exist:

>> loop 5.0 [print "Red's design lets Red coerce consistently."]
Red's design lets Red coerce consistently.
Red's design lets Red coerce consistently.
Red's design lets Red coerce consistently.
Red's design lets Red coerce consistently.
Red's design lets Red coerce consistently.


which of course does not exist in Red as it returns an error:

>> loop 5.0 [print "Red's design lets Red coerce consistently."]
*** Script Error: loop does not allow float! for its count argument
*** Where: loop
*** Stack:

GiuseppeChillemi
19:22@SmackMacDougal I make assumptions because I have the needed knowledge to understand why you think in the way you think, how you decode visual symbols and build new neural structures the way you build them. ;-)
19:24Your:

>> loop 5.0 [print "Red's design lets Red coerce consistently."]
*** Script Error: loop does not allow float! for its count argument
*** Where: loop
*** Stack:


It's a good catch. I think too that float should work here but...
SmackMacDougal
19:25You do not know me. It is metaphysically impossible for you to know how I reason. If you were in my presence, you might intuit things based on body language, expressions and intonation, but reading five or six sentences on gitter.im chat and then telling me

You believe X because think Y because you have been conditioned Z

is more than presumptuous. **It is fu--ing rude.**

So stop it dude like right now.
GiuseppeChillemi
19:31RED and REBOL are context sensitive languages, and as context I do not refer as REDBOL machine context definition but as upper level context where you define the global working of the language and DSL.
19:32So it doesn't need to be coherent, it does have to be so only when needed.
19:33Otherwhise, coherency is a limit and RED does not suffer of this limit.
SmackMacDougal
19:33Here is another:

>> repeat i 3 [print "Design consistency helps programmers."]
Design consistency helps programmers.
Design consistency helps programmers.
Design consistency helps programmers.


For the rest of Red to be consistent with make vector! 5.0, then this should work:

>> repeat i 3.0 [print "Design consistency helps programmers."]
*** Script Error: repeat does not allow float! for its value argument
*** Where: repeat
*** Stack:


But it does not and rightly so. The specification for repeat requires an integer!.

>> ? repeat
USAGE:
     REPEAT 'word value body

DESCRIPTION: 
     Evaluates body a number of times, tracking iteration count. 
     REPEAT is a native! value.

ARGUMENTS:
     'word        [word!] "Iteration counter; not local to loop."
     value        [integer!] "Number of times to evaluate body."
     body         [block!]


The make vector! inconsistent design is this:

1. You can make a vector fast by make vector! 5.
2. It will even coerce a float! as the element count ("length", "size") as in make vector! 5.0
3. But if you truly need a vector! of float! initialized with zeroes, you must remember to do this 'make vector! [float! 64 5]`.

It does not fit in with the rest of the language. It adds yet one more thing to memorize to use this. Blech. That is weak design.


GiuseppeChillemi
19:36You could propose to use length (actually) size type, for vector type.
19:37Also, you could propose to use and round float loop and repeat #iteration values.
19:39Or to force the vector length? type to integer and give error otherwise.
19:39I like the last one.
SmackMacDougal
19:51On a side note, after hunting for examples to compare make vector! 5.0 the designer of repeat makes poor use of words.


This is an improvement:


>> ? repeat
USAGE:
     REPEAT 'word integer body

DESCRIPTION: 
     Evaluates body a number of times, tracking iteration count in an integer. 
     REPEAT is a native! value.

ARGUMENTS:
     'word        [word!] "Iteration counter; not local to loop."
     integer        [integer!] "Number of times to evaluate body."
     body         [block!]


Why? In the current native! definition, the word value is used. But value implies any kind of value. So when a programmer does a >> ? repeat the requirement of more mental processing arises.

I bet there are dozens if not many dozens of such flaws that could be polished to make Red even easier to learn and use.

A key goal of any language designer in the 21st century ought to be accessibility by domain specialists. After all, programming literacy is a must in many fields. Presumably, Carl designed REBOL for this by making it a messaging language that borrowed a LOGO-like front end with Unix-y OS concepts with function composition of Forth, but with function argument ordering of Lisp without the maddening mess of parentheses, regardless of the internal representation in C or whatever to make REBOL.

Surely that simplicity, which is superiority over most (if not nearly all) other programming languages appealed to Nenad and is why he wants to take REBOL to "11" with his Red (since 11 is one better than 10 [Eleven Is One Louder - Spinal Tap](https://www.youtube.com/watch?v=XuzpsO4ErOQ) ).

To strive to make Red something for people of the cult of Comp Sci rather than something for programming-literate practical domain specialists in the 21st century would be a profound error.

That is why >> make vector! 5,0 == make vector! [0 0 0 0 0] ought to be fixed as I have proposed here after having to waste good time sleuthing the design-inconsistent flaw.




GiuseppeChillemi
19:54You believe X because think Y because you have been conditioned Z is more than presumptuous. It is fu--ing rude.

Yes, but its my skill, and it could seem rude but we should extend this judgement on anyone else explaining how things works in any area using his skills, which is not good for diffusing knowledge. So, anyone will continue and it's up to the other take the explanation as is.
meijeru
20:18@SmackMacDougal It seems to me you are now lapsing into needlessly offensive language.
SmackMacDougal
20:19@meijeru [1] That is your opinion and [2] Your behavior is typical of someone trying to curry favor in a group so as to elevate his status at the expense of harming someone else, typically the outsider.

I ask you now to stop and refrain from further ad homimen attacks against me. M'kay. Thanks.
GiuseppeChillemi
20:21>> That is prima facie of how the Internet is a magnet for those suffering mind disorder inculcated into them by public education

@SmackMacDougal I could talk here about obsessive/compulsive disorder with a mix of paranoia into viewing into everyone the same "mental problems". This behavior is usually associated with high functioning Aspergers or not life blocking autism, which led to geniuses but limited set of response range. People in the coding area have an higher chance of being of this type (me not being immune). Also, having seen this pattern of flames starting multiple times in the past days, I see a lot of energy inside of aggressive/defensive type which usually reveals narcissistic traits and it is accompanied with deep feelings of not worthless shielded from feeling of grandiosity at the same time . People of this type are usually in danger of building depression, anxiety disorder, delusional feeling while at the same type they are able to achieve great results in life.

Now, I don't want either know if I am right of wrong, the answer will remain between you and you. **But please, could you stop starting flames and be a peaceful contributor to this community? **
meijeru
20:21@greggirwin @PeterWAWood Please review the above exchange.
SmackMacDougal
20:22@GiuseppeChillemi Stop already dude. Your talking about me is not warranted. Please stop. I should not have to ask you to do so.


Seriously, stop.
20:26> Now, I don't want either know if I am right of wrong, the answer will remain between you and you. **But please, could you stop starting flames and be a peaceful contributor to this community? **

No one is flaming here, certainly not me. But talking about me to my virtual face as if you know how I think is rude, dude.

I've asked you to stop. Move on. I have no interest in you, your comments, your beliefs and so forth.

There are good people associated with Red. I will rely upon them.

Oh and clearly not only I am contributing (e.g., the discussion of make vector!) but I have been for awhile, both helping others and asking for help, notably on GUI issues.

9214
20:35Here's what actually happened:
[![iOoy33S - Imgur.png](https://files.gitter.im/red/help/2kPR/thumb/iOoy33S---Imgur.png)](https://files.gitter.im/red/help/2kPR/iOoy33S---Imgur.png)
meijeru
20:37@9214 Thanks for conserving that. It has now disappeared but it was the reason for my earlier comment.
9214
20:37@meijeru see /chit-chat. @SmackMacDougal is prone to do that.
GiuseppeChillemi
20:45@9214 Thanks Vladimir, good job !
hiiamboris
20:45@SmackMacDougal Man, just think of it. Don't you have anything more interesting in your life than proving to some noname guys on the web how cool you are? ☺ @greggirwin will do you a favor of relieving you from this burden.
SmackMacDougal
20:47> @SmackMacDougal Man, just think of it. Don't you have anything more interesting in your life than proving to some noname guys on the web how cool you are? ☺ @greggirwin will do you a favor of relieving you from this burden.

And yet, here you are, trying to look cool on the web, trying to build your cred with the rest by attacking me. Thanks for the chuckle. Your obliviousness to your hypocrisy is noted.
20:49I came here to talk about vector! today and Giuseppe wanted to tell me how I think because he believes in a delusion that he knows how I think.

I've moved onward. If you guys can't you have hang ups. You're proving Red to be yet another insular cult like REBOL was. You're hurting the brand Red by doing so.

I will ask you and the rest of you lot to stick to Red questions and answers and refrain from further ad hominem attacks against me.

Thanks.
GiuseppeChillemi
21:04@SmackMacDougal here we have 4 patterns from you:
Deleting Chats
Talking about mental problems
Taking things personally
Criticizing RED author's choices.

We all have seen them and if you continue the community will surely point you to this list.

We could continue on this (elsewhere) or do the best adult people can do: lets try to build together. Some of your observations have ground (not all). Why don't you build a table with all the "incoherencies" you have spotted in RED ? We can discuss about them together with the authors and make RED a better language.
SmackMacDougal
21:07I deleted one comment to keep the peace in hopes that it would make others rise up and become better people. It has failed to work.

You continue to engage in ad hominem against me. You have problems, serious mental problems dude.

You need to stop trying to tell people what they should do, dude. You are powerless and your suggestions of this kind are useless.
GiuseppeChillemi
21:09Thanks informing me, I will visit a doctor in psychology. Now lets continue on RED!
SmackMacDougal
21:11

But what is clear is this: Any commentary that is misconstrued by Red Gitter trolls as criticism elicits a pitch-fork witch hunt by the trolls.

As to this:

> Taking things personally

You guys are the ones crying like girls going so far as to demand inquiries and supply screenshots. Talk about beta incel behavior ... lolz.

Please, I have asked you to move onward and no longer address me whatsoever. I am asking you now to do that yet again.>
GiuseppeChillemi
21:14@SmackMacDougal
>>I have given measured commentary about why something appears as inconsistent. It is not a personal attack on Nenad.

Please build the list of you observations, I will be happy to discuss about them with you and the other members of the community.
SmackMacDougal
22:25
Please build the list of you observations, I will be happy to discuss about them with you and the other members of the community.

Thanks, but I have seen your struggles on Stackoverflow. Thus, I shall decline, gracefully, of course, your offer.>
dockimbel
22:59@SmackMacDougal There have been several reports in the last days about your harassment and insults of our team members and other Red followers on several of our public channels on Gitter, and private channels. We have a zero-tolerance policy for troublemakers and our groups on Gitter are strictly moderated. After reviewing all your recent posts here and in other groups, including your anti-Red messages other forums, it seems clear that you are here only to cause trouble, and not to peacefully contribute to Red. So, to restore order in this group, you'll be banned, as you are from other groups already. The full report of your misbehaviors can be found [here](https://gitter.im/red/chit-chat?at=5dacc27b3e33a9652a04f0b5).
23:17@SmackMacDougal
> In other words, should not make vector 3.0 meet users' likely expectations and allocate 3 float! (...) and not allocate 3 integer!
> I get how it works. Are you confused because, wrongly, you think I am confused?
> It shows design inconsistency. Where else in Red (or REBOL) are coercion of this type done?
> Fine but where in Red (or in REBOL) does constructor coercion happen?
> It's flawed, design inconsistent.
> Where else does REBOL (Red is supposed to be 95% compatible) or Red do this kind of conversion for someone?

Float values are truncated and converted to integer when used as argument to make on any series!. Same rule as in Rebol2 and Rebol3. So, the current behavior for make vector! is _consistent_ with how floats are treated in the same code pattern for all the other series. E.g.:
>> make block! 5.0
== []
>> make paren! 5.0
== ()
>> make string! 5.0
== ""
>> make binary! 5.0
== #{}
23:30Now, your proposition for extracting the type information from the second argument and use it to populate the vector with default values of the same type, could eventually be an interesting syntactic sugar, but it would need to be properly studied in a REP (with arguments and not personal opinions). Obviously that would not work well for all types supported by vectors, like char!, percent! and maybe other scalars like time! and date! in the future. It would then introduce an inconsistency, so may not be worth supporting it.

nedzadarek
04:26@SmackMacDougal
> Why? In the current native! definition, the word value is used. But value implies any kind of value. So when a programmer does a >> ? repeat the requirement of more mental processing arises.
> integer [integer!] "Number of times to evaluate body."

Repeating types, as you did, is not good as well. If I want to check a type of an argument then I go to the definition (e.g. ? repeat). Names should suggest what they do or what they have. You don't name block of temperatures a block, do you?
04:29^^ and here I'm talking to the void.
9214
05:20WRT map! vs. block! question that someone ( @GiuseppeChillemi ?) asked yesterday, I authored [this](https://github.com/red/red/wiki/%5BDOC%5D-Comparison-of-aggregate-values-(block!-object!-hash!-map!%29) page as a reference to point newcomers to.
toomasv
06:00Great explanation!
BeardPower
09:22@9214 Much appreciated!
loziniak
13:35And what about vector!?
endo64
14:21@9214 Thanks! Very short & clean explanations! Would be nice to have vector! there as @loziniak suggested.
dander
17:51make has always felt a bit low-level to me. Would it be reasonable to have a vector helper function to assist with the construction of vector!s?
Oldes
17:56imho vector! deserves to have a special syntax, like map! has.
18:01Because even when there would be serialized form, it would be long and not much nice, like:
#[vector! float! 32 2 [0.0 0.0]]
18:17Maybe something like:
>> f32!: func[data [block!]][make vector! reduce ['float! 32 data]]
== func [data [block!]][make vector! reduce ['float! 32 data]]
>> f32![0.0 0.0]
== make vector! [float! 32 [0.0 0.0]]
18:20maybe there could be: #[float32! [0.0 0.0]], #[uint8! [1 2]] (but that is out of topic in /help room)
GiuseppeChillemi
18:28
@Oldes
I think they should be:

To create a vector of a specific type and initialized to the provided length

make vector! [float! 32 2]


or

To create a vector with predefined block and specific type:

Make vector! [float! 32 [0.0 0.0]]


Also , the basic form:

Make vector! 2


Could be changed to infer the vector item datatype from length number datatype

Make vector! 2


Make vector! 2.0


Or:

Make vector! 2 5.0


As

Make vector! <lenght> <init-value>

To create a vector whose type is the init value type>
Oldes
18:29@GiuseppeChillemi I know how it is, although I must often search for the right order.
hiiamboris
18:29make is not variadic
Oldes
18:30@GiuseppeChillemi Make vector! 2 5.0 is a nonsense.
GiuseppeChillemi
18:30@hiiamboris Please, fill my ignorance, what you mean as variadic ?
hiiamboris
18:31meaning can accept various number of arguments
Oldes
18:31@GiuseppeChillemi that make always requires 2 args and not 3 like in your last case.
18:33Also the problem is, that using this long construction is ugly when you want to work with pre-initialized vectors in code. Which is not a problem now, because not many people are using vectors for something like matrices.
GiuseppeChillemi
18:38I like the following:

make vector! [<type> <length-of-type>  <length-of-vector-block>  <init-value>]


While maintaining the following:

make vector! <length>

18:39With default initialization to 0
18:40Which also could be 0.0 if the length size is expressed as float but @dockimbel expressed some difficulties about this notation (If I have understood correctly)
18:41But why don't we move to the vector datatype gitter chat ?
nedzadarek
19:32@GiuseppeChillemi the more arguments you add the more it could be confusing. It's better to pass some key-value container e.g. [length: 1 type: float init: 42.0].
GiuseppeChillemi
19:36Type needs the byte size of it
greggirwin
23:59Great wiki entry @9214.

nedzadarek
17:25@GiuseppeChillemi and is there a problem?
GiuseppeChillemi
20:12Pardon, I have not understod the proposal. Now I have.

melcepstrum
11:42
c1: context [ a: 1.0 dbl: does [a: 2.0 * a]]
c2: copy c1
print c1/a
c1/dbl
print c1/a
print c2/a
c2/dbl
print c2/a

when compiled it prints:
1.0
2.0
1.0
1.0

this works as expected in the interpreter, how can I make it works the same when compiled?
hiiamboris
11:58It did not rebind dbl's body. make can be a workaround but my advice is stay away from OOP at the moment. It's real bad there.
12:00Best you can do right now is save your spec and rebuild every object from this spec. And better with make object! than context
melcepstrum
12:08@hiiamboris thanks
BeardPower
12:23@melcepstrum You could also try to compile with the encap (-e) option.
melcepstrum
12:30@BeardPower i know, but i have routines in my code so i have to find a workaround
12:35
c1: make object! [ a: 1.0 dbl: does [a: 2.0 * a]]
c2: make c1 []

this works
12:40
c: [1] c/1: make c1 []

but this does not
TheHowdy_gitlab
16:44Just interested: are there any numbers on the estimated size of the community? Like, the whole user base or so. (If this is not the right channel to post such question please forgive me, it's kinda confusing)
16:59Maybe at least the number of downloads of the red executable.
greggirwin
17:06This channel is for help with Red itself. Red/Red is the main room, where you can see that we have over 700 people. As with any community, only a fraction of those participate regularly. Another metric these days is stars on github, where we have 4.1K.
nedzadarek
19:14@TheHowdy_gitlab some time ago, I think, @rebolek has written some code to get the most active users.
greggirwin
19:18Yes, though it doesn't tell us about overall community size.
rebolek
19:49The stats I wrote will give you (very detailed) activity on Gitter but, of course, can't track users who don't use Gitter.
dander
20:04I found some interesting GitHub stats [here](https://blog.sourced.tech/post/language_migrations/). Obviously Red is not listed, but all the code for generating the graphs and the data source seems to be there. It would probably be possible to get some graphs of various growth metrics
GaryMiller
greggirwin
21:02Thanks @dander. Will follow up on that when I can.

@GaryMiller that chart is *fantastic*. Comic Sans *and* a moonshot for V. ;^)

I don't think the Advocacy wiki page is the right place for these, but we should start collecting info somewhere.
TheHowdy_gitlab
21:30Thank you all for the insights. @GaryMiller God, V. Not saying it's bad, but people nowadays are really stuck to c-like languages. Just my 2-cents, best wishes for you guys.
21:31(Do not interpret this as a critique to V, please ;)

AndreasWagnerBerlin
14:02Why is it necessary to add a load source to the following code fragment:
source: {
    ((((abc AND JKL) OR (def AND GHI))))/TI
}
probe parse load source [ [paren! /TI] ]

Here a string is loaded from memory into global context resulting in a block bound to the global context. But why is this necessary?
The code fragment does not work without load source.
Any pointers to further readings are welcome.
pekr
14:10I think it is related to the fact, that parse has two modes internally - parsing a string, and parsing a Red code (hence a block! notation)
14:10My explanation might not be accurate, but think along those lines. Also - you can find Rebol Core manual online, there is a parse explanation.
14:13If you probe your source string, you will see, it is a string. And your parse rules simply are not written correctly to satisfy your code rules. With string parsing, you can do basically any grammar, but you have to create rules, which will be able to understand the code provided, hence parens, nested parens, logical operators, whatever you need to decode etc.
endo64
15:32if you change source: {...} to source: [...] then probably it works (just guessing I'm on mobile now, you might need to fine tune your rules)
greggirwin
18:39Both @pekr and @endo64 are correct:
>> blk-src: [((((abc AND JKL) OR (def AND GHI))))/TI]
== [((((abc AND JKL) OR (def AND GHI)))) /TI]
>> probe parse blk-src [[paren! /TI]]
true
== true

melcepstrum
14:08I cannot change font in a draw command. I'm trying this but it doesn't work
f: make font! [ name: "Times New Roman" size: 18 ]
view [ canvas: base 150x150 white draw [font f text 50x50 "Hello!!!!" circle 70x60 40]]

I remember that I did it once but I don't remember how
hiiamboris
14:22It's a regression. Under some circumstances font is not applied. Please raise an issue for it ☺
14:25When it works, then matrix stops working on it ☺ No scale / rotate / translate.
14:25View is hopeless.
toomasv
14:36@melcepstrum Try this:
view [ canvas: base 150x150 255.255.255.1 draw [font f text 50x50 "Hello!!!!" circle 70x60 40]]

Matrix operations work too (W10). E.g.
view [ canvas: base 150x150 255.255.255.1 draw [translate 30x30 rotate 45 30x30 font f text 50x50 "Hello!!!!" circle 70x60 40]]

melcepstrum
14:47@toomasv thanks! works here too (W7)
toomasv
15:06:+1:
greggirwin
18:11Are these limitations and workarounds something we can document in, at least, the wiki? It may be a lower priority, but a ticket will help, and @qtxie can sometimes fix them very quickly.
toomasv
18:51I mentioned this solution in https://github.com/red/red/issues/3225
greggirwin
19:04Thanks @toomasv. A regression from there then, since it looks like @qtxie fixed it.
toomasv
19:21Seems to be different thing that was fixed, because @hiiamboris' tests work, but this font issue does not.
hiiamboris
19:35Likely because my tests didn't involve font choice :)

TimeSlip
15:40I'm getting a runtime error after running a compiled app that uses view/flags with one of the flags being 'modal. The script works from the red interpreter. I'd there a trick to using modal this way?
hiiamboris
15:43Tried -e?
greggirwin
17:40And if -e works, the smallest example that dupes it will help track it down or doc the reason.

TimeSlip
01:29Thanks @hiiamboris and Gregg. Just tried -e. It works with the example code but my code has some R/S and it complained: *** Internal Error: contains Red/System code which requires compilation. I'm moving on for now.
endo64
07:38@TimeSlip Can you share a minimal example? I tested with below code and it works:
Red [Needs: View]
test: routine [return: [integer!]] [42]

lay: layout [txt: text "---"]
view [
	size 300x300
	button "Do" [txt/text: form test view/flags lay [modal] ]
	button "Quit" [quit]
]

red.exe -t Windows -c test.red
07:39[![image.png](https://files.gitter.im/red/help/TKZC/thumb/image.png)](https://files.gitter.im/red/help/TKZC/image.png)
07:40Even with #system[ #import [ "user32.dll" stdcall [ ...]]]
TimeSlip
18:50When I get home I will. Thanks so much!

TimeSlip
00:17@endo64 Hmmm. It does work. I wonder if my libRedRT.dll was up-to-date. I re-compiled it sometime last night AFTER I had given up trying to get that part of my app working . Thanks so much Ol' Rebol friend.
endo64
05:45@TimeSlip Glad it worked!

hiiamboris
14:57I dig there was (?) a protect function in Red: https://github.com/red/red/wiki/[ARCHIVE]-Alternatives-to-Red-System-pre-processor-%23define#alternative-2

Does anybody happen to know the story behind it? I can't find any info on issue tracker or in old repositories.
rebolek
15:27@hiiamboris protect was in Rebol and hopefully will be in Red one day. The text is misleading.
hiiamboris
15:32I see. Thanks ☺

GiuseppeChillemi
00:58I have published my FORDATA function [here](https://github.com/GiuseppeChillemi/fordata)

Its purpose is executing a block of code making column data available on the word you have provided.

If you run the example on RED you will see the last line of the output is: none

...
----------- Nested usage and condition ------------
document:  OL  Person:  Jeff Bezos -- Interested in:  BOOK: How to keep you money safe from world taxation
document:  OC  Person:  Jeff Bezos -- Interested in:  BOOK: How to keep you money safe from world taxation
== none
>>


While in REBOL it isn't

Also, it isn't if you do not nest the fordata function..

I don't understand why the function returns none to the console
07:36I have isolated the cause:

fordata: func [
	"Iterate a block of code on data block where columns data is using column name"
	'data-name [word!]
	;Domanda: il contesto è quello principale, oppure è quello della funzione ?
	"The object name"
	data-block [block!]
	"the source with headings on top"
	code-block [block!]
	"The code to execute"
	/where
	"Condition for data filtering"
	condition [block!]
	"Block where you can use WORD/COLUMN in a condition to express valid ROWS"
	/local
	headings
	row-obj-specs
] 
[
	headings: copy first data-block
	data-block: next data-block
	row-obj-specs: copy []
	forall data-block [
		forall  headings [
			append row-obj-specs to-set-word first headings 
			append row-obj-specs data-block/1/(index? headings)
		]
		do reduce [to-set-word data-name make object! row-obj-specs]
		either where = true [
			if all condition [;<---------------------------
				do code-block
			]
		]
		[
			do code-block			
		]
	
	]

]


RED Propagates the NONE result of ALL of a failed test up to the end of the function. Don't know the reason as it is the test of the IF block.

07:50Testing ...

if 10 = 0 [print "10 is equal to 0"]

== none



07:53So, why IF is returning NONE ?
07:54It should return nothing
nedzadarek
09:20@GiuseppeChillemi I think they want treat if and other things as *expressions* (they return some meaningful value(s) that you can assign to a variable or something).
If it returned unset! (your "nothing") then you cannot use if because in some cases it will break your code.
For example:
a: if 2 = 3 [3 * 4] ; cannot set unset values (easily) - an error
print a ; a is unset - 2nd errro
GiuseppeChillemi
09:39@nedzadarek Yes, I can see why it works this way
10:26It is not explained directly in IF description in REBOL documentation but on its last example.
10:27Have updated the [FORDATA](https://github.com/GiuseppeChillemi/fordata) repository with a new version
nedzadarek
11:35@GiuseppeChillemi well... maybe there is some kind of info that everything (or at least "lots of things") are expressions?
GiuseppeChillemi
12:37@nedzadarek pardon me, I have not understood what you have written
meijeru
12:40If I may quote the spec document (https://github.com/meijeru/red.specs-public/blob/master/specs.adoc):
An important property of Red is that any Red program is a _sequence of Red values_, i.e. code and data are a priori indistinguishable. In other words, Red is homoiconic. Thus, execution of a Red program is tantamount to evaluating each of its constituent values in turn, according to the evaluation rules.
So yes, it is true that every constituent of a Red program is an expression that has a value.
nedzadarek
13:24@GiuseppeChillemi maybe there is some text (in the documentations or something) about expressions? Maybe you can find text like "99% things in the Red are expressions" .
13:28@meijeru Depending how you look at it(whenever or not you count unset! values), some things are not expressions. For example a: print 1 gives you an error. There might be other things that are not expression but I don't remember them at the moment.
meijeru
13:53From a formalistic viewpoint, a: print 1 _does count_ as an expression. I would not hesitate to say that 100% of Red is expressions.
GiuseppeChillemi
14:19@meijeru please define "expression"
meijeru
17:03May I again quote the spec document:
<expression>      ::= <operand>
                    | <operand> <op> <expression>
<operand>         ::= <value>
                    | <prefix-function> <argument>*
                    | <word-literal>: <expression>
<argument>        ::= <expression>

In other words, an expression is either a value (which is a literal of the language) or a prefix function application, or an infix function application (operation) or an "assignment" (this is not a term in Red) i.e. an association of an expression with a word (binding). I do not think you will ever find a proper fragment of a Red program that is NOT an expression in this sense.
18:30Meanwhile, I have been able to simplify the above formulae as follows:
<expression>         ::= <value>
         | <value> <op> <expression>
         | <prefix-function> <expression>*
         | <word-literal>: <expression>

This better reflects the precedence rules. Mind you, the familiar means of influencing precedecne by the use of parentheses is taken into account by considering a parenthesized expression as a single -- indeed it has a type: paren!.
hiiamboris
18:36Yeah, that's more correct indeed ☺
meijeru
18:57And it covers all of Red!
18:58By the way, in drawing this up I came to a finding that I will report in the /bugs room.
nedzadarek
21:36@meijeru I don't know what you mean by "formalistic viewpoint" but it causes an error.
@GiuseppeChillemi if you see term "expression" in other languages that means that you can use that as substitute for some value. Everywhere you want some value you can use an expression (that returns a value you want).
For example If you have syntax for associating name with value (e.g. setting variable) like this: name: value then those 2 are equivalent (with some exception, explained below)
1) name: some-value
2) name: exp1 where exp1 returns some-value Exception: - time/resource constraint: it may take too much time or resource(s) (e.g. RAM) to compute - no side effect - it can change/do everything, even some common operations; so, for example, by typing 1+1 you may "run" 1-1`.

I assume that you have enough time/resources and there are not "bad" side effects (side effects that you don't want).
21:39@meijeru ps. you have to say that and should return something except unset! value
meijeru
21:52@nedzadarek An expression that causes an error is still an expression: the result of its evaluation is a value of type error!. The strength of Red is precisely that "everything is an expression", and every (well-formed) expression yields a value.
nedzadarek
22:04@meijeru I mean the error from the assignment not expression (print 1). If I cannot set or pass it (print 1) then it's not an expression. Sure, you can try [...] but then not everything is an expression, not things likedo make error! "foo" but like try [do make error! "foo"]
hiiamboris
22:14If an expression fries your PC, it's not an expression too then?
nedzadarek
22:48@hiiamboris I mentioned about it in the :point_up: [November 2, 2019 10:36 PM](https://gitter.im/red/help?at=5dbdf6ecfb4dab784a519e93) about side effects. If X fries your PC every time you run it then it cannot be an expression. Why? Because you cannot continue your program every time you run X.
If there is a chance that X won't fry your PC and it "returns" something then it's an expression.
hiiamboris
23:01So it was an expression before you knew it's outcome, but stopped to be one when you discovered it? ;)
23:05Is f: blackbox an expression?
nedzadarek
23:20@hiiamboris
> So it was an expression before you knew it's outcome, but stopped to be one when you discovered it? ;)

No. You don't know whenever or not Y is an expression in the Red. You have to check it's source to know.
23:23It's the same with a: X: what is the type of a? You don't know until you run a code or check a source.
hiiamboris
23:32What about do input? An expression? You know it's source.

nedzadarek
00:48@hiiamboris it's an expression and a statement (I think that's how they say about code that don't return anything) at the same time. Schrödinger's "thing".
Depending on what input is you may deduce it. Input may be a string... or it could be user's input (input: ask "give me something").
meijeru
09:03Statements do not exist in Red. I think we are witnessing here the difficulty of trying to understand Red in terms of other programming languages with other paradigms. Note that assignments do not exist in Red either. The purest and most correct way to understand Red is to think in terms of expressions only. There is no "code" in Red that does not return anything. For instance print returns unset and if returns none if the condition is false. Literally every expression has a value, and every value has a type. Even types are values. I know it is difficult to get your head around that.
nedzadarek
09:24@meijeru It's not hard to understand but, yes, the problem is borrowing terms from other languages/paradigms.
While you are technically correct it is not very helpful for "normal programmers". Saying that "everything is an expression" while you cannot do things like "a: print 1" makes your statement at least weird. How do you name, in the Red, "expressions that you cannot pass/assign to word without special constructs (e.g. try or set/any)?
meijeru
09:36Why would you do a: print 1 when a: probe 1 will do the trick? Every built-in function has a specification which tells you what the (type of) result is.
nedzadarek
09:39@meijeru do input?
meijeru
09:40Or, at least, it SHOULD have this. The docstring of print, e.g., does not tell you its result is unset. Admittedly that might be added.
nedzadarek
09:40f: has [r] [ r: random 2 either r = 2 [ do make error! "some error" ] [42]]
meijeru
09:42In the case of this f it is up to you to provide a return: [integer! error!] spec. And I maintain that in all cases, f produces a value.
nedzadarek
09:43@meijeru what about do input?
09:51@meijeru my point is, sure you can tell an user about it's return value but telling them that everything is an expression will confuse them.
meijeru
10:02There is no other way to accurately describe the semantics of Red than to say everything is an expression. Pretending that some things are not expressions will in the end be more confusing.
nedzadarek
10:25@meijeru well, then you have to say something like this:
> everything is an expression but you need special construct to pass error! and unset! values

GiuseppeChillemi
10:50Could an object have elements other than words and values that remains after object creation ?

Example:

a: make object! [b: 22 [data1 data2 data3]]
>probe a

== make object! [
    b: 22
    [data1 data2 data2]
]


11:03Second question: is there an established way in RED/REBOL to have a placeholder in strings and replace them with RED data ?

example:

age: 100
annnounce: "you can purchase by credit if you are over 100 and accompanied by parents"
print [convert-holders announce] 
==you can purchase by credit if you are over 100 and accompanied by parents


nedzadarek
11:16@GiuseppeChillemi I don't think it's possible. I think an object! value is only key-value container, hence, you have to give [data1 data2 data3] some name, e.g. name: [...]. block! and not exactly map! (you can set integer as an identifier) cane be used. For example: [a: 1 [some data]]
11:24@GiuseppeChillemi as for 2nd question, there is no official "string interpolation" (e.g. like in ruby "I am #{100} years old.") so we are using something different.
a: 100 print ["I am" a "years old."]
; I am 100 years old.
rejoin ["I am " a " years old."]
; == "I am 100 years old."
GiuseppeChillemi
11:30@nedzadarek as for "interpolation" I would like to have it inside strings as it adds readability becaouse string is not split in multiple parts and (usually) editor with syntax-hylighting make "harlequin" lines with them.
11:32note: should it be "I am #{age} years old." ( I don't know Ruby, just imaging)
11:47Found REBOL3 alread has [REWORD](https://www.rosettacode.org/wiki/Category:REBOL)
12:01Here is the [source](https://github.com/rebol/rebol/blob/25033f897b2bd466068d7663563cd3ff64740b94/src/mezz/mezz-series.r#L153)
12:03Notes from CARL or whoever has written the code (at the bottom of the function source)
; It's big, it's complex, but it works. Placeholder for a native.
nedzadarek
12:20@GiuseppeChillemi I think Greg has written something like this.
As for "I am #{age} years old." - you can put anything in #{} - string, number, an expression... Same as with his solution, afair.
GiuseppeChillemi
12:51@greggirwin Is it true ?
hiiamboris
14:43https://github.com/greggirwin/red-formatting/blob/master/composite.red
14:43the sad emoji dialect
14:56I'm arguing however that macro approach is a better fit for this purpose, as using macros you get correct bindings for free
nedzadarek
15:10@hiiamboris ^^ does it matter for an user whenever you use macros or Greg's approach?
hiiamboris
15:17With Gregg's experiment you need to specify /with all the time. Especially ugly when you refer to function locals.
nedzadarek
16:41@GiuseppeChillemi interesting, I guess it is a bug... but I have not analyzed the source.
16:47^ it works with things like v: 1
giesse
19:03@nedzadarek re: expressions, I strongly disagree with you. Type checking does not mean that some things are not expressions.
You can't say that make unset! is not an expression just because:
>> a: make unset! 0
*** Script Error: a: needs a value
*** Where: a
*** Stack:

For the same reason that you can't say that 1 is not an expression just because:
>> copy 1
*** Script Error: copy does not allow integer! for its value argument
*** Where: copy
*** Stack:
GiuseppeChillemi
19:07@nedzadarek Have not undestood:

> @GiuseppeChillemi interesting, I guess it is a bug... but I have not analyzed the source.

nedzadarek
20:38@GiuseppeChillemi if composite ":(v):" works then composite ":(o/v):"` should work as well, but it doesn't work. Why? Is it intended (a feature) or a bug (not intended)?
20:58@giesse but copy 1 is malformed code. It's not valid code so I wouldn't talk whenever or not it's an expression or not.
On the other hand make unset! 0 is valid code. Correct me if I'm wrong, but expression means that you can pass it as any other value and assign it to the variable (word in the Red language). So, if make unset! 0 is valid... why I cannot assign it to some word?
And why you even mentioned type checking? The Red doesn't care about what kind of value you use (e.g. a: 1 a: "Foo" is a valid code).
greggirwin
22:06:point_up: [November 3, 2019 5:51 AM](https://gitter.im/red/help?at=5dbecd4c14d55a3785c8693d) @GiuseppeChillemi see [composite](https://gist.github.com/greggirwin/d40a0e3b4c8de31a7d3b82695b9b4b03)
22:07Ah, @hiiamboris beat me.
22:15@nedzadarek let me pull from Wikipedia:

> An expression in a programming language is a combination of one or more constants, variables, operators, and functions that the programming language interprets (according to its particular rules of precedence and of association) and computes to produce ("to return", in a stateful environment) another value.

Evaluating an expression, and producing a result, has nothing to do with assignment.

copy 2 can only be considered malformed in Red's built-in environment. With a couple lines, as you might find in a dialect, it's perfectly valid:
>> s: "abcdefg"
== "abcdefg"
>> copy 2
== "ab"
>> copy 6
== "abcdef"


GiuseppeChillemi
02:29Is there a way to have refinement with just one argument after it and the all subsequent are just normal function arguments?
greggirwin
02:53No. You need to put normal args first.
nedzadarek
05:26@greggirwin >Evaluating an expression, and producing a result, has nothing to do with assignment.

You want to do something with the result. The easiest way is to assign it to some name.
Sure, you can deal with expression without assigning them but even then, the Red, doesn't work.
05:27> copy 2 can only be considered malformed in Red's built-in environment. With a couple lines, as you might find in a dialect, it's perfectly valid:

Well, yes, but it's the same as with any other language. It won't be "the Red" but "the Red + some dialect".
05:32@GiuseppeChillemi you can just check if there is a refinement and change words' values (1st arg = ref's arg, 2nd arg = 1st arg .. etc)
giesse
05:50@nedzadarek That's a really weird way to define an expression. In pure functional languages, there is no assignment, yet, everything is an expression (or, a function, if you prefer).
1 is an expression and its result (which happens to be 1) is passed to copy in copy 1. Type checking happens for function arguments, therefore the error. copy 1 is a perfectly valid expression, it just so happens to throw an error because the type of 1 does not match the list of valid types for the argument of copy. If things that may throw an error are not valid expressions, then read http://red-lang.org is not a valid expression either because it may throw an error. IMHO, your reasoning makes no sense, but, whatever makes you happy.
set just does not allow unset! values. That does not make things that return unset! values "not expressions".
GiuseppeChillemi
08:28@greggirwin In my FORDATA the last argument should be the code block. Having refinements force me to put them after the code block which is horrible for readability, otherwise is not possible a code block it will be treated like a refinement argument.
It would be good if we could put an / to the functions specs meaning "refinement arguments ends here, now consider everything else, up to the next refinement, a normal argument", or any other character useful to this purpose.
08:34@giesse I always think that copy should duplicate nonseries argument and not throw an error. I do not know why it is limited. In a conditional loop which duplicates certain data of a block to another, you have to use a different word thank copy depending on your are treating series or not, where a simple COPY X would do its job.
greggirwin
20:26@GiuseppeChillemi I'm going to push back a bit here. You make suggestions which are easy to try at the mezz level, and which may prove to cause more issues than they solve. We all do this to some extent. It's very easy to look at our own use cases and assume they'll make sense to everyone else.

Refinements have a very clear and intentional design. What you're asking is for a way to work around that. I think that's a bad idea. Just as saying copy should duplicate non-series values. You need to understand the deeper implications. e.g., that non-series values are never copied, and that having copy behave differently may lead to code that's hard to debug. Red is already flexible enough in that regard. :^)

That said, Red's basic design here, from Rebol, gives us more design options when we write functions. In this case, I see a couple easy alternatives:
fordata: func [
	'name
	data
	where [word! block!] "'All or conditions"
	body
][
	...
	if any [
		where = 'all
		all [block? where  all where]
		all [word? where  cause-error ...]
	][
		do body
	]
]
fordata x y 'all body


fordata: func [
	spec [block!]
	body
][
	name: spec/1
	data: spec/2
	where: spec/where
	...
	if any [
		none? where
		all [block? where  all where]
		all [not block? where  cause-error ...]
	][
		do body
	]
]
fordata [x y where [...]] body
fordata [x y] body
nedzadarek
20:45@giesse an assignment is not requirement but it's the most common and the easiest way to use a value (from an expression). In functional languages you may pas it as an argument, but a value is still associated with some "name". There is a tacit programming but there is still way to say "this value".
ps.
>> a: make unset! 0
*** Script Error: a: needs a value

^ this still counts as setting wrong type to a?
greggirwin
21:02@nedzadarek there have been deep and heated discussions in the past about whether Redbol langs should even *have* unset!. It is a special case, and should not be "used" is most code.
21:03http://rebol.net/cgi-bin/r3blog.r?view=0024 has a few notes about it, but not much. Most deep chat on it was probably on CureCode, now gone I think.
GiuseppeChillemi
21:53@greggirwin there is a reason why I have chosen to have a /where refinement: developers are used to omit where when there is no filtering needed, this comes from SQL where clause. I am learning to enginer my code for **low cognitive load**. This is one of the rules I am establishing while being here. I am at the very beginning as I am building them self analizing mine and other thoughts, reaction and association while (re)learing REDBOL. Something which is natural and automatic to remember is better than a new expressive form until the old one becomes limiting, do you agree ?
For the above reason, came my request for /to mark the end of refinement. Also this choice had another support. Please look at this:
mycode: func [arg-here arg-word /refinement arg a-last-arg] []


mycode: func [arg-here arg-word /refinement arg arg2 / a-last-arg] []


Starting and ending slash could give a visual sense of starting and ending, a delimited space where refinement happens.

We could also use a special container like:

mycode: func [arg-here arg-word /refinement args![arg arg2] a-last-arg] []


If my UDT request will be implemented !

greggirwin
21:59@GiuseppeChillemi I understand your goal, but disagree with your proposed suggestions. Prove me wrong with *working code* you can defend when put to the test. Tell me how my second proposal doesn't work for you. You're asking for changes that *aren't needed*. They will make Red different, but not better (until you prove me wrong here).
GiuseppeChillemi
22:02@greggirwin Two arguments are overlapping: are you asking me to prove that the and ending slash "/" to delimit the refinement is not needed or that UDT! is not needed ?(or both ?)
greggirwin
22:03Why I ask for working code is because your / proposal has *deep* ramifications. Not just for making it work, but for every piece of code that uses it. Write some functions using your proposal, just examples that *pretend* it works. You may find, and others will give you feedback I'm sure, that suddenly you have to know what the function spec looks like to understand a given call, and the core of Red's free ranging evaluation may be shot entirely to Hell.
22:04This is only about refinements. UDTs do not apply, don't conflate them into this conversation.
GiuseppeChillemi
22:26Greg, the first an most meaningful example has already been reported by you:

fordata: funct ['data-name data-block code-block /where where-condition]


I want to have a where parameter which is a RED refinement with a sense of SQL where clause, replicating some of its working (absence = all, presence = filter data), and the visual aspect of a FOREACH loop.

This is the actual code without /where. It is very readable, isn't it ?

fordata row mydata [
      code code code code
      code code code code
      code code code code
]


Actually, with a where taking all the following parameters I am forced to write:


fordata/where row mydata [
      code code code code
      code code code code
      code code code code
] [condition]


If refinements and their parameters are not on the same line of the corresponding instruction you risk missing them.

You can only accomplish it with:


fordata: funct ['data-name data-block /where where-condition / code-block ]


So you can write:

fordata/where row mydata [condition] [
      code code code code
      code code code code
      code code code code
]


Which is far more readable and less dangerous than previous code.

I ask to you.

Having the following constrains:

Low cognitive load:
1) Have it a refinement to not force the developer to remember a new usage scheme
2) The usage pattern of where clause, which is present when a condition is needed or absent were it is not.
And last: A FOREACH aspect with the block of code at the end.

How would you write it with these requirement ? In your versions you had to change the visual aspect and the working moving of the code putting it far from standard RED way of expressing instruction parameters, which is not a good thing under the light of low cognitive load.


22:34Let's drop /, have you any other proposal to stop refinements eating all the subsequent parameters ?
greggirwin
22:39@GiuseppeChillemi you're just restating earlier messages. I *understand* your goal.

My proposal is "we're not going to do that until you (or someone else) shows that it's a good idea."
GiuseppeChillemi
22:40@greggirwin

This is the proof (in bold)

Having the following constrains:

**Low cognitive load:**
1) Have it a refinement to not force the developer to remember a new usage scheme
2) The usage pattern of where clause, which is present when a condition is needed or absent were it is not.
And last: A FOREACH aspect with the block of code at the end.
22:40*It's not the code, it's the aspect and working of the code*
22:44You are looking at my words with a standard coder mindset. You have to add some psychology and visual decoding. That's your dive in the new rabbit hole: will you believe me even if you do not see it ? I can show you the path but not the truth, you have to find it by yourself.
22:46However, every interaction with you is teaching me more things on this new science. Thank you for being active, even when you are negative, about my words. It helps me a lot !
greggirwin
22:47@GiuseppeChillemi what you offer is not proof. You haven't addressed any of my concerns, or said why *my* suggestion isn't suitable? I'm trying to help, but you're not helping me help you. Here's the deal, for *everyone*. If you suggest changes to Red, make sure you understand Red deeply first. Then, as the wiki page notes, defend your position such that we can't refute it.

If you believe I'm looking at this with a standard coder mindset, I will counter that I'm coming at this from a Reducer's mindset.

I have to stop responding, as I don't have time to go in circles.

GiuseppeChillemi
22:53@greggirwin I will stop responding too as I need to go to bed. We are in circles because it is a very new topic and it will take time to be understood (also I need to sharpen my skills, I admit). If you will have patience I will try to do my best to share my knowledge with you (if you want) as you did in the past to help me go down the rabbit hole to tearch me how RED is different.

giesse
06:11@nedzadarek a: is exactly the same as set 'a, therefore, it is exactly the same as passing an argument to a function. The generated error is special, for good reason, but it is exactly the same as type checking for function arguments, in other words, the code just checks if the passed value is unset! and causes the error if it is; there is no concept of "no value" or "missing value" - unset! values exist exactly because we can't have "missing values" in many cases. In a: make unset! 0 an unset! value is generated so, clearly, the value is not missing, it's just of the wrong type; the same is true for a: print 1, print *does* return a value, just one that a: will not accept. Therefore, print 1 is an expression, because it *does* return a value. Note that in other languages this is *not* true, and statements do *not* return a value, in fact, they cannot *syntactically* be used where an expression can; Red does not have syntax at this level, therefore, there cannot be a distinction between statements and expressions (that is a parsing-time distinction, not an execution-time distinction).
hiiamboris
09:35@GiuseppeChillemi man, why not just keep it easy? your /where argument is a block, your loop body is a block, just swap the two blocks in your fordata :) It's not standard but perfectly justifiable for your case.
if where [set [code-block condition] reduce [condition code-block]]
meijeru
09:40@giesse :+1: for that response. What this teaches us is that Red _is_ quite different from many more familiar languages. In fact, the less you know about other languages, the easier it must be to learn Red. But many people do know other languages, so the education effort is quite considerable.
GiuseppeChillemi
10:30@meijeru @hiiamboris I will answer later with a screenshot, actually I can't because I am deep in my daily work but have been here for few seconds to read your words.
19:31@hiiamboris , It a nice example of how RED let you find "another solution" :smile:
19:31But....
19:33Have you ever read [this article:]( http://www.rebol.com/r3/docs/concepts/scripts-style.html) ?
hiiamboris
19:51Oh my god.. THIS is a guideline:
either check [do something short][
    do something else]

I can't tell you how many times this thing tripped me up. Please everyone, never use this syntax! :D
19:51@GiuseppeChillemi So what's your point?
GiuseppeChillemi
19:52@hiiamboris I am writing it, I am not english native so it is taking time. Please don't interrupt me ! :smile:
hiiamboris
GiuseppeChillemi
20:09That document is plenty of chapters where CARL suggests (and I agree) what can be summarized [here](http://www.rebol.com/r3/docs/concepts/scripts-style.html#section-12)

*There are standard names in REBOL that should be used for similar types of operations*

If we generalize the rule: "Standard way of expressing code and words should be used for **similar types of operations** "

Block of code at the end of a function is a common expressive form in FOREACH and FORALL, and arguments receiving that block should be usable with no additional tricks in body code. So, while there could be 2^<RED developers> ways of passing and swapping arguments, the easiest to remember is to have the code block ARG at the end of functions interface definition and with no additional code. So while there are other solutions, here remains my sponsorship for a way to define a starting and ending area to declare the first and the last argument of a refinement. Because every time you need to have the visual aspect and mechanism of those FOR* code looping, and refinements at the same time, you have to use tricks.

Written this, I give you a BIG thank you for your **GREAT** and simple trick ! You have solved my needings which led me here.
20:11(Ah, I promised a screenshot but now it is time for dinnet, I'll take it later!)
21:23[![image.png](https://files.gitter.im/red/help/Hzl1/thumb/image.png)](https://files.gitter.im/red/help/Hzl1/image.png)
21:46In the Style Guide document, Carl Suggest that words should be concise, meaningful and we should limit line length to 80 columns *(green rectangle)*
Then I have seen my FORDATA example code that you can view in the attached picture (just below the green rectangle).

The content of fordata WHERE clause was distant and invisible (it was about under the *red oval*). I was not able to have all the pieces of my statement without scrolling back and forth, and this generated some fatigue when I had to reread my code after a day or two.

So I have understood the sense of Carl's words in that article: the statement must be completed before you move to the next piece of code because it must have a sense under the viewing spot of your eye. Good code is where your eyes do not move so much; you do not seek; where you express the code procedure using the least number of variations to the standard expectations, until that standard becomes limiting so you must use different expressive ways.

That's why and where my request has born. (I have written this just to share my experience and thoughts with you).

nedzadarek
05:37@greggirwin
> @nedzadarek there have been deep and heated discussions in the past about whether Redbol langs should even have unset!. It is a special case, and should not be "used" is most code.
http://rebol.net/cgi-bin/r3blog.r?view=0024 has a few notes about it, but not much. Most deep chat on it was probably on CureCode, now gone I think.

I am not against unset! but about usage of the term *expression* which does not fit into the Red in 100%

@giesse https://gitter.im/red/help?at=5dc11278fb4dab784a680b71 a: = set 'a => that makes sense from language's implementation site. It is not so clear (who knows that there is type checking in such cases) from someone less experienced in the Red. As in, if everything works, you can assign any "normal" (any-type! - unset! & error!).
> that is a parsing-time distinction, not an execution-time distinction

I think lots of people I have discussed this (recently) have thought about parsing-time distinction, and I have been thinking more about execution-time distinction. That might caused some misunderstandings. Thank you for pointing this out.
dander
05:45@GiuseppeChillemi in terms of improving readability, I can think of two options that could help. First is changing the /where refinement of fordata to a function, and use it to filter the data given fordata.
fordata row where mydata [condition][
      code code code code
      code code code code
      code code code code
]

The other option, if you find yourself doing a lot of scrolling to the front/end of that method is to extract the body into its own method (which can also help to document the code)
fordata/where row mydata [
      process-mydata-row row
][condition]

process-mydata-row: function [row][
      code code code code
      code code code code
      code code code code
]
greggirwin
05:53Good suggestions both @dander.
giesse
06:00@nedzadarek re: execution time distinction - sure, but, it's not like the interpreter sees print 1 and decides it's not an expression, therefore causing an error. Rather, the set native receives an argument, and decides it's not a valid argument; the print 1 expression has already been evaluated at that point - you can't say that it wasn't an expression if it has already been evaluated - it couldn't have been evaluated (ie. turned into a result value) if it had not been an expression.
That's why the concept of *statement* vs *expression* only makes sense at parse time, and why the distinction does not exist in Red.
GiuseppeChillemi
09:57

fordata row where mydata [condition][
      code code code code
      code code code code
      code code code code
]


Where is a function that should accept an argument which is the current ROW ?>
10:12The other option, if you find yourself doing a lot of scrolling to the front/end of that method is to extract the body into its own method (which can also help to document the code)

fordata/where row mydata [
      process-mydata-row row
][condition]

process-mydata-row: function [row][
      code code code code
      code code code code
      code code code code
]


I do not wan't the developer to handle to many concepts and keep the FOR* aspect where all the code is contained in a block at the end.
I will keep your suggestion for further improvements.
TimeSlip
16:20I have a pie chart and I would like to add a mouse click event to each slice. I'm using arc. Is that something relatively easy to do?
rebolek
16:32@TimeSlip it depends on your definition of "easily" :smile: I have an interactive pie chart style and from the event offset I compute the angle and check it against slices. It’s not hard IMO.
dander
18:13@GiuseppeChillemi There are different ways to do it. Some people make the condition a block to evaluate, but then you need some way to specify an argument, or do it dynamically somehow. Here's one way, which assumes you would have function to act as your condition to process the row
where: function [data predicate][
    collect [
        foreach item data [if predicate item [keep item]]
    ]
]

where [1 2 3 4 5 6] :even?
hiiamboris
19:54@GiuseppeChillemi try ? action! in console
19:55The idea is that each datatype has it's own set of implemented actions.
19:55The list is at the end usually: https://github.com/red/red/blob/1d32938a2c39286c14173a4ff78f21dd3c17d905/runtime/datatypes/block.reds#L1804
GiuseppeChillemi
20:43@hiiamboris
They seem like a meta language, a subset of words with associated code between upper and lower level with a relative working for each datatype.
hiiamboris
20:45Yeah, sort of ☻
20:49The key is that actions are dispatched based on datatype. Unlike natives and routines.
GiuseppeChillemi
20:50So each datatype has the same action with different code.
20:51Or, in other words, there is 1 action for each datatype that can or can't be coded whether the datatype handles is or not.
20:52The entry exists but there is no code for it if the datatype does not support the action.
hiiamboris
20:53In that case, it's an error to apply that action to it.
GiuseppeChillemi
20:58The first part of the source for each datatype has the code for each handled action, the ending part has all the action with handled, unhandled and I see INHERIT_ACTION. So this mean that this action come from an upper level...
meijeru
21:00Again, I quote from the spec document, this time section 4.2.6:
The notion of parent type arises in the implementation of actions, i.e. pre-defined polymorphic functions of up to two arguments with built-in evaluation, e.g. add, subtract, copy, find, etc. The implementation uses a dispatch table which contains a pointer to a specific run-time function for each allowed combination of action and type of first argument. These functions are grouped by the type to which they apply. Now for any action/type combination, such function may be designated as inherited from the parent type, and in this way two or more types may share the same implementation for that action.
GiuseppeChillemi
21:00Also I see the datatype name as comment. So it mean they have a positional mapping and no WORD associated to it like in RED [WORD action![code]]
21:02Yes, but null entry exists
21:05>> Now for any action/type combination, such function may be designated as inherited from the parent type, and in this way two or more types may share the same implementation for that action.

It like a library of actions where 2 or more types could point to the same handling action
meijeru
21:07Indeed!

hiiamboris
14:11How do you test if a typeset! is empty? convert it into a block?
meijeru
15:54Short answer: yes indeed. Long answer: make a WISH for empty? to be applicable to typesets, and bitsets for that matter.
toomasv
15:58But how would empty? work on bitsets? Checking that no bit is raised?
hiiamboris
16:01Yeah, why not. Three integer to zero comparisons.
16:02In case of bitset!, not typeset! - more than three :)
danieloff
16:04:), sorry I'm brand new at red here, just have a quick question, I'm trying to learn it and this example rebol code isn't working: http://www.rebol.net/cookbook/recipes/0051.html
when I try to convert epoch to date. I assume it is because the rejoin is creating a string and to-date isn't taking a string, but I'm not sure how it is supposed to work. Is to-date supposed to take a string or is rejoin not supposed to create a string? (I have a c++ background)
hiiamboris
16:05@meijeru just thought of another solution, that will also work on bitsets: compare to a brand new one :)
16:12@danieloff nor it works in R2
16:12@danieloff try changing
day "/" hours ":" minutes ":" seconds now/zone to
day "/" hours ":" minutes ":" seconds
danieloff
16:12ok, just a sec
16:14hmm, still getting this:
Script Error: cannot MAKE/TO date! from: "7-Nov-2019/16:14:6"
hiiamboris
16:17@danieloff use load instead of make date!. But it's strange.
16:20So, make date! only accepts blocks https://github.com/red/red/blob/1d32938a2c39286c14173a4ff78f21dd3c17d905/runtime/datatypes/date.reds#L626.
I wonder if it's intentional.
16:23@danieloff return day + now/zone + to-time reduce [hours minutes seconds] is more Red-friendly solution to that anyway
danieloff
16:26ah ok, yeah I was hoping there was a non unusual way. I was reading about the new lexer post, will that help the memory usage on the svg tiger demo or is that a separate thing? I don't mind if it uses memory just want it to have a cap or something... The load solution worked, trying the return day one now
16:28(the tiger demo memory only goes up with the transforms uncommented, so I assumed it was react related possibly)
16:30Yeah the return day method works just fine. Thanks! Off to more learning...
hiiamboris
16:49@danieloff no, new lexer has nothing to do with View memory leak ☺
danieloff
16:50haha, alright then, I was hopeful :)
pekr
17:11If there is any such finding, should be reported as a bug then?
danieloff
17:14I'm also curious, I don't want to log a bunch of nonsense that will just get fixed later as it is alpha, but It is something that I care about from my c++ background.
17:16(and I'm not good enough at red to determine if it is 'my code' or red that has the issue)
9214
17:17@danieloff can you maybe report the problem that you have in a bit more detail?
danieloff
17:17Sure just a sec
17:19I git cloned the code from the red/code repo and compiled the tiger demo to create the tiger exe. If I run it on my machine with the red-daily from about a week ago the memory keeps climbing is all. Otherwise it runs fine
17:20it also climbs with the 64 release
17:20*run the tiger.exe, compile with red-daily or 64
17:22and when I was trying to experiment with it, the memory is constant if I comment out the transforms, but leave the draw loop in
hiiamboris
17:22it grows if run from the console as well, about ~10MB/sec
danieloff
17:27the "particles" demo has the same behavior
hiiamboris
20:03Do you think there is an interpreted equivalent of #include? Or should I make a wish for one?
greggirwin
20:04:point_up: [November 7, 2019 8:58 AM](https://gitter.im/red/help?at=5dc43f272f8a03435751e722) I vote No for empty? on bitsets. A bitset always contains bits. Empty? isn't a good match, semantically. Any would be better, but that has other issues. There's a precedent there with find returning logic for bitsets though.
20:11Welcome @danieloff! Learning is good. If you just need the functionality, see [the date doc](https://doc.red-lang.org/en/datatypes/date.html#_epoch_time). On rejoin, it uses the first value to determine the output type. Non-string types become strings, but any-string! types keep that type:
>> type? rejoin [http:// 'ab.com]
== url!
>> type? rejoin [%/c/dev/ 'test.txt]
== file!
>> type? rejoin ["blah-" 'blah]
== string!
>> type? rejoin [123 456]
== string!
>> rejoin [123 456]
== "123456"
danieloff
20:14ah! very cool
greggirwin
20:16For learning, the REPL is your friend:
>> d: form now
== "7-Nov-2019/13:11:45-07:00"
>> d: mold now
== "7-Nov-2019/13:12:07-07:00"
>> load d
== 7-Nov-2019/13:11:45-07:00
>> to date! d
*** Script Error: cannot MAKE/TO date! from: "7-Nov-2019/13:11:45-07:00"
*** Where: to
*** Stack:

Here you can see that form and mold return the same format for dates. Other types may have different results between the two. Next, you can see that load works on a string, but to does not. It's by design. See also:
- https://github.com/red/red/wiki/%5BDOC%5D-Conversions-to-string
- https://github.com/red/red/wiki/%5BDOC%5D-%60to%60-vs-%60make%60

@meijeru or others might be able to point to a conversion matrix table. I can't find it at the moment.
nedzadarek
20:16@GiuseppeChillemi @greggirwin about refinements:
I agree that "refinements' arguments" might be confusing but such solution should be "good enough" to break old Red's code. [Giese's code](https://github.com/giesse/Project-SnowBall/blob/master/topaz/types/function.topaz) is interesting.
As for block as last argument:
What @GiuseppeChillemi wanted is supported (not exactly) in the Ruby. It has an implicit block of code (a lambda I guess).
[1,2,3].each do |n|
  puts "#{n}!"
end

Here, do ... end (can be written between { } as fair I remember; might be some exceptions) is not an argument but an implicit block of code. Each function has this thing. Lot's of functions
What if the Red supported something like this. For example:
f: func [] [print implicit-block] 
f -> [1 2 3]

Here [1 2 3] would be passed like an argument to the f. @greggirwin Is this doable in the Red? What do you think about this idea?
greggirwin
20:18:point_up: [November 7, 2019 1:03 PM](https://gitter.im/red/help?at=5dc47880f26ea4729d71508e) you mean rather than just treating it as do?
hiiamboris
20:18Yeah, I was thinking of macros (do forgets them):
>type 1.red
Red [] #macro ['NOT-EXPANDED] func [s e] [ [EXPANDED] ]

>type 2.red
Red [] #include %1.red probe [NOT-EXPANDED]

>type 3.red
Red [] do/expand %1.red probe [NOT-EXPANDED]

>red "2.red"
[EXPANDED]

>red "3.red"
[NOT-EXPANDED]
danieloff
20:19another question I ran into with things yesterday is how to create some memory, on the stack preferably, with red system.
I was playing with the fast fract demo and as an experiment I wanted to make the color scheme variable. It starts with red as the dominant color. So I got that coded up and I was able to do a literal array [ 1 2 3 4 ] to store the indexes I wanted to use for the color channels. But then I wanted to "randomize" them into another array. To do that I had [ 0 0 0 0 ], but I wasn't sure how to just reserve an array of 4 in red/system. I suppose I could have used make but again not sure of the syntax
hiiamboris
20:25@danieloff Literal arrays in R/S - [1 2 3 4] do exactly that - reserve some memory in the data segment, pre-initialized with your values.
greggirwin
20:25@hiiamboris worth a wish ticket so @dockimbel can weigh in.
pekr
20:26In the sense of an array R/S type, the docs state: "Currently literal arrays allow write access, but there is no bound checking as it is planned to be a feature of a future array! first-class datatype." - is the first-class array! type planned anytime soon, or will it happend later, if at all? Might be useful to those doing stuff just in terms of just R/S, where something like a block! type might be missing? ....
danieloff
20:29@hiiamboris right, but I was wondering if there is a syntax to reserve it, like in c for example int space[5]; without typing out zeros, imagining I had a bigger array
20:31mostly there are a lot more funny libraries already available with c interfaces, so I was trying to learn how I'd interact with c
20:31(or rust)
20:32I'm not worried about the safety myself for now, I am just curious how to do these things :)
hiiamboris
20:32@danieloff R/S is minimalistic right now, I don't think it's supported yet. You'll have to work around it for now ☻
danieloff
20:33is there a way to allocate some byte! s on the heap? I'm just not remembering the doc fully, I did read the spec once last week
20:33(I assume that would be one workaround)
hiiamboris
20:34Yes, allocate (which is malloc alias)
danieloff
20:35ah ok. And I know concurrency is a way off but can I call back into red from a different thread or would that be bad?
hiiamboris
20:36I think someone reported problems with that and GC. Can't recall, sorry ☻
danieloff
20:37ah ok. Sounds reasonable. I did have one more simple question though:
for this sequence
--== Red 0.6.4 ==--
Type HELP for starting information.

>> a: 1
== 1
>> b: 'a
== a
>> get b
== 1
>> :b
== a
>> b
== a
>>
greggirwin
20:38@danieloff there likely be Tygers there, but see https://static.red-lang.org/red-system-specs.html#section-6.6
danieloff
20:38what is the difference between get and :name?
20:40@greggirwin yeah that looks good, I thought I'd give that a try, but I wasn't sure if I was allowed to hand a function pointer to another thread and call back from there, ie if that is expected to work yet
greggirwin
20:40When you use get b, b is being evaluated, so get sees a as it's arg. If you use get 'b you'll see the same result as :b.
danieloff
20:40ah! that is the trick, b being evaluated in that context. Thanks!
greggirwin
20:40Don't be surprised by issues with threaded callbacks, but please report them, so we know.
20:41There are other evaluation tricks, because in Red "everything is data until it's evaluated." :^)
danieloff
20:41sounds good, When I get time I'll definitely be trying it out
20:41yeah [ a b ] is not evaluated
20:42so I made a 3 button interface and clicking a button changes all the labels on all three buttons
greggirwin
20:42Correct. And you can write funcs that don't evaluate their args, so you can write control funcs without having to quote args.
danieloff
20:42but for my 'update' function I originally was doing [ a 'text ] or something so I needed an extra get in that case when I selected to it
20:43once I learned blocks aren't evaluated it made sense, but I wasn't sure at first
greggirwin
20:43Seeing code helps. You may already be tripping over [this](https://github.com/red/red/wiki/%5BDOC%5D-Why-you-have-to-copy-series-values)
20:44Reduce is how you force evaluation, or compose if you want more control.
danieloff
20:47nice. Yeah the scoping rules are a little different too from what I've read, but I've been trying to catch up. I was hoping to make a little rest based time logger to see how all the pieces fit together
20:48just out of a curiosity how do I re-layout the vid window? My button text was longer when I changed the labels and I couldn't figure out how to refresh the layout. I assume it is in the vid doc somewhere
greggirwin
20:48Scoping is a *whole 'nother* issue, because it doesn't exist in Red. ;^)
danieloff
20:49haha, I've been enjoying how fun it is :). I code for a living, and I studied coding because I like it, but it would be nice if my day to day was a little more interesting than c++
greggirwin
20:49When you create a layout, the VID processors makes all the faces. They are then a tree of objects. That means you either need to reprocess the layout or manipulate the face objects in the tree.
danieloff
20:50For my purposes on this experiment I'd like to just reprocess the layout
greggirwin
20:50Fun is the key. Red lets you play and solve problems in so many different ways that it changes how you think.
danieloff
20:51Is the red book worth it for an organized newbie resource? I've red the nim and rust books, it is nice to have one stop shopping. But if the wiki is better I can stick with that
20:51or if a different rebol book would be good
greggirwin
20:52The Pakt book? Mixed reviews. Stick with the wiki and docs for now, and note what trips you up. We have a User Guide planned, but docs are a lot of work and we're spread thin.
20:52The Rebol Core Guide is great.
danieloff
20:52Sweet
20:53Yeah a "red for c programmers" chart like some languages have would help me, but it is really easy to learn so far anyway
greggirwin
20:55
spec: [
    below
    button "A"
    button "B"
    button "Add a new button" [
        repend spec ['button rejoin ["Added " now]]
        unview/only w
        view spec
    ]
]

w: view/no-wait spec
do-events
20:57Eh, overly complicated.
spec: [
    below
    button "A"
    button "B"
    button "Add a new button" [
        repend spec ['button rejoin ["Added " now]]
        unview
        view spec
    ]
]
view spec
20:59@danieloff be sure to join the main red/red room as well.
21:04:point_up: [November 7, 2019 1:16 PM](https://gitter.im/red/help?at=5dc47b9fe1c5e915084fdcea) @nedzadarek on implicit args, your answer lies in Ruby's end syntax. Red has free ranging evaluation, so that can't work. If you want variable arity handling (a single implicit arg is a subset of that), use a block as your arg.
danieloff
21:05Thanks! Yeah I can do that. The example works just fine too :). The other question I had now that I'm recalling it is the vscode plugin. Is there a version of red it works well with? I saw the issues on github and there were some problems. I've got syntax highlighting but none of the code completion features shown in the readme gifs
greggirwin
21:06The VSCode plugin was updated not too long ago, but the fast lexer work, when merged, will help. Maybe someone who uses VSCode regularly can say. Otherwise I'll have to dust mine off.
21:07If VSCode doesn't work with the automated build, please report it.
danieloff
21:08to provide more details, with the 64 exe the rls server crashed on startup, but I get neither startup crash messages nor code completion with the last auto build I tried. I'll report it then. The shortcut for compiling and everything works, but not any code completion features, at least for me
greggirwin
21:09:+1:
21:09@bitbegin :point_up:
21:10@danieloff you know about help and source, yes?
danieloff
21:10and what
21:10they are all great! :)
21:10saves a lot of time
greggirwin
21:11Cool. Poke around and have fun.
danieloff
21:11For sure, is the gist on the 'links' page the best source for a way to do oauth?
greggirwin
21:13Which one? Someone else may know better than I.
danieloff
21:13https://github.com/red/red/wiki/%5BLINKS%5D-Scripts-collection
GiuseppeChillemi
21:13@hiiamboris
> @GiuseppeChillemi man, why not just keep it easy? your /where argument is a block, your loop body is a block, just swap the two blocks in your fordata :) It's not standard but perfectly justifiable for your case.
> if where [set [code-block condition] reduce [condition code-block]]

The solution DIED when I added other refinements accepting words :smile:
danieloff
21:14that page and this link twitter-oauth.red https://gist.github.com/rebolek/a2bd8920432930e44bdab35b8218860f
greggirwin
21:16Thanks @danieloff. @rebolek is around and should be able to help if it goes south.
danieloff
21:17Thanks! I may try to set up something on my own server to hit, so not twitter, but I was hoping the code was good to learn from
greggirwin
21:18Bolek's code is always pragmatic and worth hacking on.
danieloff
21:18Sweet
GiuseppeChillemi
21:23@greggirwin
When you write:

>> Just as saying copy should duplicate non-series values. You need to understand the deeper implications. e.g., that non-series values are never copied, and that having copy behave differently may lead to code that's hard to debug. Red is already flexible enough in that regard. :^)

if I perform:
a: []
b: [x y z]

forall b [append a first b]


Isn't append a first b adding each word of b to a, making an exact copy of it, or is it doing something different ?
nedzadarek
21:29@greggirwin I'm sorry for the confusion. I meant the language that compiles "the Red's compiler/interpreter". I'm not good at compilers but I think it could be implemented at "Syntax Analysis" ([source](https://www.tutorialspoint.com/compiler_design/compiler_design_phases_of_compiler.htm) ). The things I'm asking are: how hard it is to implement it and will it (potentially) break something?
21:42> Isn't append a first b adding each word of b to a, making an exact copy of it, or is it doing something different ?

>> a: []
== []
>> b: bind [x y z] c: context [x: 123 y: 456 z: 789]
== [x y z]
>> reduce b
== [123 456 789]
>> forall b [append a first b]
== [x y z]
>> reduce a
== [123 456 789]
>> c
== make object! [
    x: 123
    y: 456
    z: 789
]
>> c/x: 123123
== 123123
>> reduce b
== [123123 456 789]
>> reduce a
== [123123 456 789]

I think if it would make a copy then a & b would be different.
9214
21:55any-word! binding and series! copying are two completely unrelated mechanisms.
greggirwin
22:07@nedzadarek there is nothing implicit in your example Ruby code:
[1,2,3].each do |n|
  puts "#{n}!"
end

is just like
foreach n [1 2 3][print n]


For your example of f: func [] [print implicit-block] , what is the result of this code, and what is printed?
blk: []
append blk f insert [1 2 3] [4 5 6]

22:23:point_up: [November 7, 2019 2:23 PM](https://gitter.im/red/help?at=5dc48b63ef84ab3786149d07) @GiuseppeChillemi, we can't spoon feed you answers. You need to dig in and learn what symbols (words) are, scalars versus series and aggregate types (like maps and objects), to understand why things were designed and implemented the way they are. Until then, it's not fair to ask for changes as you do. Once you take the time to understand these things, you will very likely change your mind, or suggest something different.

The onus is now on you to prove that you understand how something works before you ask for it to be changed. And that learning opportunity falls to you, not via Q&A here, but by exploring on your own. We're happy to see updates from you as you learn; and you have the option not to make that effort. Everyone is free to use Red however it suits them.
GiuseppeChillemi
23:25@greggirwin In the labyrinth of knowledge you can loose yourself and create a false sense correctness trying to understand its map. It happened to me with REBOL and I needed your help to rewire my mind. While many of you have been in the REBOL world with the pro's I have started in a time and situation where REBOL was dying and with no one answering my doubts. I know where I could end with no support and doing by myself. Also having a continuous flow of ideas at every level of knowledge is my personal trait. My ideas are inapplicable or full of conceptual errors at the very beginning but accurate in later stages. I don't want to stop this because I would stop my progress into RED and the flow of ideas. Also, please don't ask me to remain silent and do by myself because know I risk blocking myself completely as I work differently. It's up to you to be or not be my teacher and face this particular alumn that sometime is quite upsetting. I could make just on promise: I will read everything you will put in front of me in this chat either as explanation or as link to a document, like I did for every message of Vladimir at the beginning and then Toomas and all the other at later stages.
greggirwin
23:35It's a balance @GiuseppeChillemi. We all need to try and give as much as we take, and make each other self-sufficient. What we can't afford to do is go in circles, which is what I feel happens with you more often than not. Ideas are a dime a dozen (American idiom for "Cheap"). Execution is everything. What I'm asking is that you put in at least as much effort as we do, and that when we say "prove it", you don't ignore that request and respond with "But isn't this clearly better?" Does that sound fair?
23:37That is, if you have an idea or suggestion, as laid out in the "Red should..." wiki page, if we don't agree that it's a good idea, the burden is on you to prove it with deep analysis and working code.
23:40Let me also add that I'm not saying it's easy or will happen quickly. It can take time. Years even. But if you believe in something strongly enough, you will make it happen.
GiuseppeChillemi
23:47Greg it happened because we are discussing from a different point of view. While you answer from the pure RED coder and creator point of view, I come from knowledge about visual decoding. When I ask you a way to limit the number of arguments of refinements it's because I want to replicate the visual aspect of FOR* functions. You answer explaining to me there are a zillion of ways to pass arguments in RED, while from my side I see there is no way to have a VISUAL ASPECT of FOR* functions in presence of refinements. We are talking about apple and oranges.
23:48Let me explain from my POV:
23:55FUNCTION-NAME word word []

That's not RED, its a line with 4 mind slots: a function, 2 arguments and a block.

When the mind encounters this visual structure again it will go in "automatic mode" and it will immediately know what to do. It starts with for, it has a block at the end, the second is the assignment word. Then the only "stress" is to find out that the third word and the refinement stand for.

I am absolutely not talking about the coding point of view but from the visual decoding one and mind automatism. That because we are right from both sides !

GiuseppeChillemi
00:03About copy I would know totally change my approch as I am understanding why we ended up here:
00:12"Greg, I am thinking that inserting a word and copying is equivalent. Could you please point to me to some code examples and experiments I can do on the REP ?
And then, "why me and many other new developers are we falling on the same hole ? Is there something we could do to avoid this problem ?"
00:16Yes, before asking to implement something I will try doing some more research, I promise ! Then will come, if still applicable, any ideas which could arise to avoid the problem we are encountering. Is it better, isn't it ?
00:28Here is some reading about the importance of first and last element for our mind: http://www.mrc-cbu.cam.ac.uk/people/matt-davis/cmabridge/
00:28That's my POV
00:28Good night!
00:32(Note that there is a scientific debate on this as you will read, but it is the kind of thinks I manage each day as passion in my life)
rebolek
04:15@danieloff ae you interested in OAuth1 or OAuth2?
danieloff
04:20I saw the Twitter was probably oauth1. I had originally wanted to use my app to link to a spreadsheet in google docs but it looks like there are all kinds of approvals an app would have to go through if I released it with those permissions. So I thought I’d experiment with rolling my own and therefore it is probably flexible. Google looks like it uses oauth2 so I assume that is the latest and greatest. But none of my professional experience has touched web apis so I’m just reading mean stack books and so on to see what the “normal” way of doing things is
rebolek
04:24I see. Twitter is probably the only (bigger) service that still uses OAuth1, everything else is OAuth2. However, they are completely different. I have support for OAuth2 in my [HTTP tools](https://github.com/rebolek/red-tools/blob/master/http-tools.red), that OAuth1 gist is an unfinished experiment.
I've got some experience with using web APIs from Red, so if you need some advice, feel free to ask.
danieloff
04:26Being able to talk to a server running gitea would be nice, but that is a second project idea and I need to learn how to do the simple one first
04:27@rebolek cool! Yeah I saw http tools when I was glancing around. I’ll be sure to look into it. Thanks!
rebolek
04:42You're welcome!
04:44@danieloff Gitea API looks very accessible, it shouldn't be hard.
danieloff
04:46Sweet. Yeah it looked like a neat system to me, but my knowledge of web api technology isn’t up there yet so I wasn’t sure
TimeSlip
05:13@rebolek Sorry for the delayed response. Gitter only partially works on my phone. I was hoping I could make each slice interactive but I can see I'm going to have to brush up on my geometry to get it working. Thanks for the tip.
rebolek
06:59@TimeSlip I believe you can stack faces with one face per slice, but the question is, what's going to be easier. My choice was a bit of math :smile: See https://gitlab.com/rebolek/red-styles/blob/chart/pie.red#L51
bitbegin
08:33@danieloff i've updated a new version, it can work for simple Red folder (not forRed source code)
danieloff
14:03@bitbegin Thanks! I’ll give it a try as soon as I have a chance and let you know how it goes :). I appreciate it!
toomasv
15:13@TimeSlip Here is one example with stacked faces:
color: [brick aqua papaya mint orange leaf khaki olive 
	sienna tanned sky rebolor gold pink teal]
start: -90
view [
	below
	style sector: box 250x250 
	on-created [
		sweep: face/data/2
		radius: face/size - 50 / 2 
		face/draw: compose [
			pen (gray - 64) translate (face/size / 2) fill-pen (color/1) 
			arc 0x0 (radius) (start) (sweep) closed
		] 
		color: next color
		start: start + sweep
	]
	on-over [
		change radius: next find/tail face/draw 'arc 
			radius/1 + either event/away? [-10][10]
	]
	on-down [tx/text: face/data/1 nm/data: face/data/2]
	
			 sector data ["First" 63] 
	at 10x10 sector data ["Second" 85]
	at 10x10 sector data ["Third" 47]
	at 10x10 sector data ["Fourth" 70]
	at 10x10 sector data ["Fifth" 95]
	at 10x10 box 250x250
	pad 90x0 across tx: text 50 "" nm: text 20 ""
]
GiuseppeChillemi
19:06Experimenting:

z is UNSET!

R2

>> bound? 'z
>>

No result

RED

>> context? 'z
== make object! [
    datatype!: datatype!
    unset!: unset!
    none!: none!
    logic!: logic!
    block!: bl...



19:07Even if unset, RED is returning a context.
19:07While in REBOL it seems not existant.
greggirwin
19:16Very nice @toomasv!

@GiuseppeChillemi , Red matches R3's behavior, rather than R2's in this case.
GiuseppeChillemi
19:17@greggirwin So an unset word has a context too ?
9214
19:17@GiuseppeChillemi Rebol2 doesn't print out objects in console.
GiuseppeChillemi
19:17@9214 Thanks, I supposed "not printed" = "context not existant"
9214
19:18> So an unset word has a context too ?

Show us a research effort on that question before taking up all the bandwidth in one of the Gitter chats. No more spoonfeeding for you.
greggirwin
19:20Easy to check @GiuseppeChillemi
>> type? bound? 'z
== object!
GiuseppeChillemi
19:48@9214 I am doing my homeworks and experiments.

Question -1) Why is context? 'a returning a context even if unset ? Is it REPL wrapping an object around it ? -> I am experimenting working on an external script

Question -2) Has starting a script from the console the same result of starting command from the consolle because they work the same way or because they are both issued from REPL ? -> will be built and compiled a test script to investigate this scenario?

Question -3) How does passing arguments throught a function interface affect CONTEXT of the passed argument in presence of a quoted arg word in function interface specs ? -> will be built a script passing: a word, a lit-word!, a quoted lit-word!

Question 4) How does vary the passing of lit-words! and quoted lit-words! in both quoted and unquoted words in function interface ? -> script to built as before

Are they enough as proof ? Ask me any time you want but believe me I only ask when I am stuck.

Be Back Soon !

20:48Stuck Again, @9214 I do not have any way to understand the next issue other than asking to a creator. Feel free to avoid answering me but I think it is really the turn of a veteran of the red team:

20:54Here is the script I have created to test context of words and quoted words passed through and interface where you have QUOTED WORDS or WORDS:

learn: func ['arg] [print [" 'ARG: " arg " TYPE: " type? arg " VALUE: " value? arg " TYPE? Context: " type? context? arg]]

learn2: func [arg] [print [" ARG: " arg " TYPE: " type? arg " VALUE: " value? arg " TYPE? Context: " type? context? arg]]

Print "%% 1) learn z"
learn z
Print "%% 2) learn 'z"
learn 'z
Print "%% 3) learn quote 'z" ;big surprise here, found "QUOTE" in PRINT "ARG" result
learn quote 'z
Print "%% 4) learn quote z --- (CAN'T BE ISSUED) as quote does not work in presence of LIT WORD ARG interface word"

Print "%% 5) learn (quote 'z) --- yes, it works as parens content is evaluated even in presence of LIT WORD ARG interface word"
learn (quote 'z) 

Print "%% 6) learn---2--- 'z"
learn2 'z
Print "%% 7) learn---2--- 'z"
learn2 quote 'z


Here is the result:

>> do %LitArg.r
%% 1) learn z
 'ARG:  z  TYPE:  word  VALUE:  false  TYPE? Context:  object
%% 2) learn 'z
 'ARG:  z  TYPE:  lit-word  VALUE:  true  TYPE? Context:  object
%% 3) learn quote 'z
 'ARG:  quote  TYPE:  word  VALUE:  true  TYPE? Context:  object
%% 4) learn quote z --- (CAN'T BE ISSUED) as quote does not work in presence of LIT WORD ARG interface word
%% 5) learn (quote 'z) --- yes, it works as parens content is evaluated even in presence of LIT WORD ARG interface word
 'ARG:  z  TYPE:  lit-word  VALUE:  true  TYPE? Context:  object
%% 6) learn---2--- 'z
 ARG:  z  TYPE:  word  VALUE:  false  TYPE? Context:  object
%% 7) learn---2--- 'z
 ARG:  z  TYPE:  lit-word  VALUE:  true  TYPE? Context:  object


Why:

learn z

Returns:
'ARG:  z  TYPE:  word  VALUE:  false  TYPE? Context:  object


False as ARG value

And

learn 'z

Returns:
'ARG:  z  TYPE:  lit-word  VALUE:  true  TYPE? Context:  object


True at ARG value ?

nedzadarek
21:00@giesse
:point_up: [November 6, 2019 7:00 AM](https://gitter.im/red/help?at=5dc261677477946bad388865)
It makes sense but don't think this definition of an expression is very helpful. Well... it's just my opinion so I don't think there's a point in further discussion. Thank you for informations.
GiuseppeChillemi
21:18Here is the essence of my question:

>> arg: 'z
== z
>> value? arg
== false
>> arg: quote 'z
== 'z
>> value? arg
== true


Why value? ARG is false and true depending on being ARG set to a WORD using a lit-word syntax and as true setting a ARG to lit-word using quoted lit-word syntax ?
nedzadarek
21:21@greggirwin
:point_up: [November 7, 2019 11:07 PM](https://gitter.im/red/help?at=5dc495a5e886fb5aa270f6c4)

do..end is implicit because you don't define it (as an argument). Imagine the Red's code like this f: func [] [print implicit-block] and you call it like f ->[1]. It should print 1. Here -> would "pass" [1] to the f. f doesn't have implicit-block as an argument.
Here, I'm making a new syntax with -> (it could be another word if you want). -> will pass a block to the left function (no op!). You don't have to use it if you don't want it.
greggirwin
21:45@GiuseppeChillemi look at your two arg: lines. Is their result the same?
9214
21:48@nedzadarek do .. end is an anonymous function (aka 'block' in Ruby parlance) that you explicitly pass to each method. Your -> operator is apply in disguise, which Red does not have yet.
GiuseppeChillemi
21:48No, it isn't.
21:52I have tried the most simple code:

>> arg: 'z
== z
>> probe arg
z
== z
>> arg: quote 'z
== 'z
>> probe arg
'z
== 'z


So, could we say that ARG has a VALUE set in both as word and lit-word from this output ?

greggirwin
21:53@nedzadarek please implement your idea (at the mezz level is great), to show why it's better. I'm curious to see how it pans out, and what it means to all function authors that have to consider implicit args.

Is it apply @9214? I think @nedzadarek means something else. That is, he's not saying the implicit arg is a funcs normal args
21:55@GiuseppeChillemi, no arg only references the lit-word 'z.
GiuseppeChillemi
21:56Long answer:
21:56????????????????????????????????????????????????????????????????????????????????
9214
21:56@greggirwin "to each n in [1 2 3] apply func [n][print n]". I don't see any implicit arguments here, that would be point-free style. By "implicit block" here he means "object whose method was called", which is not applicable to Red at all, since it's not an OOP language.
dander
21:59@GiuseppeChillemi starting [around here](https://gitter.im/red/help?at=58c91845dd08b4b859d361a6) and going on for several pages is a great discussion on how words/contexts/binding works. I'd be curious to know if you find that useful
greggirwin
22:02Point-free is new to me. Not going to dive into it now though. My point...was that the Ruby code denoted an end...point, so there was no implicit/optional arg. I think we agree that it's not implicit simply because Red lets you shortcut to the body.
22:03Thanks @dander! Has that been pulled out to Guru Meditations or elsewhere?
dander
22:04I'm not sure... it's from 2 years back, but I remember that I had bookmarked some such discussion. Was that wiki page in existence then? :smile:
greggirwin
22:05@9214, that is, it's not implicit because foreach defines the "args".
22:05@dander should have been. Could I trouble you to check and pop that in there?
dander
22:06It's also worth watching @9214's mind being blown. Especially considering how far he has come in mastery of all this stuff since
22:07I will put it on my list to work on later to move it over there. It's a long discussion, so could probably use some cleanup for relevant pieces. I could see if I have any other discussions like that saved as well
9214
22:07@greggirwin I believe you saw Forth code - that's point-free style, where arguments are passed tacitly (hence the name, tacit programming) and all you do is just bead them thru a list of functions. I think I have a snippet for that someplace...

As for value?, it checks word!s only, returning true for the rest; deviates from Rebol, which accepts any-word! values, but I'm not sure if it's a bad thing.
greggirwin
22:07Fantastic. Thanks so much.
22:08@9214, the term was new to me, and initial search results were about Haskell and Category Theory, so I took a nap. ;^)
9214
22:14@greggirwin good dreams to you :japanese_ogre:
thread: func [body /local value][
    body: copy body
    get/any also 'value until [
        change/only 
            any [find/same body '. body] 
            set/any 'value do/next body 'body
        empty? body
    ]
]

>> thread [1]
== 1
>> thread [1 0 - .]
== -1
>> thread [1 0 - . . + 2]
== 1
>> thread [1 0 - . . + 2 form .]
== "1"
>> thread [1 0 - . . + 2 form . append . "4"]
== "14"
>> thread [1 0 - . . + 2 form . append . "4" reverse .]
== "41"
>> thread [1 0 - . . + 2 form . append . "4" reverse . 1 + load .]
== 42

22:16Clojure's threading macro does the same IIRC.
greggirwin
22:18Thanks. I'll go clean my brains up now.
22:22In Forth terms, your block is your stack, do/next pops, and . pushes, correct?
22:23In any case...yowza. That's a fun example.
9214
22:26@greggirwin . is just an eyelet to hook the result of the previous expression. In Forth that would be something like:
1 0 swap -  2 +  form  "4" swap append  reverse  load 1 +
GiuseppeChillemi
22:26@dander

Thanks Dander, it comes from a time I was not here. I will read it tomorrow morning as it starting to be time to go to bed.

Before going, I want to leave you and everyone a question.

Follow my sequence of thoughts:

If in a virgin REPL you type:

>> probe ARG
*** Script Error: ARG has no value
*** Where: probe
*** Stack: probe


RED warns you that ARG has no value and gives you no output. So you think that if you probe a word and you receive no output then it has no value and RED will inform you with this kind of error.

Then you perform
>> arg: 'z
== z
>> probe arg
z
== z
>> arg: quote 'z
== 'z
>> probe arg
'z
== 'z


In both outputs, you have an output value, while being it different. So, it is easy to think that ARG has value as you see a value as output and no error message.

Then you perform the last piece of code:

>> arg: 'z
== z
>> value? arg
== false
>> arg: quote 'z
== 'z
>> value? arg
== true


So, while probing ARG returns a value, red affirms ARG has no VALUE !

Am I a full idiot or I have my reasons for ending up stuck in confusion if I follow this path of thought which seem quite easy to take?



greggirwin
22:27@9214 got it, thanks. The eyelet metaphor is a good one.
9214
22:29@greggirwin point-free is actually quite problematic with Rebol convention of argument ordering ("the thing you operate on comes first").
GiuseppeChillemi
22:35If I have a starting argument and a sequence of functions whose first arg is implicit:

a: 2
apply-seq a [raise2 to-string duplicate append-word "ladies"]

== "44ladies"


Is it point-free ?

greggirwin
22:36@GiuseppeChillemi throw away quote. It's only confusing you. Focus on the basics.
>> arg: 'z
== z
>> value? arg  ; this is the same as saying `value? 'z`
== false

Now what happens if you set z?
>> get arg
*** Script Error: 'z has no value
*** Where: get
*** Stack:  

>> z: 1
== 1
>> get arg
== 1
22:37Don't go there (implicit args and such) @GiuseppeChillemi. Baby steps.
GiuseppeChillemi
22:40@greggirwin Just a question because I have created a function it does exactly what I have written: it applies a sequence of functions of any arity where first arg is implicit and it is the result of the preceding function. You have only to provide the remaining args of each function and the very first starting value of the queue. Just for curiosity I have asked if it could be considered point-free.
22:41Now back to the main topic.
dander
22:42The short answer for the quote situation is the same reason that
>> value? 3
== true

... but what is the purpose of value? with a non-word argument?
9214
22:44@dander a more permissive version of not unset? get/any thing I suppose.
GiuseppeChillemi
22:48@greggirwin I have read and the basic of reducing words is already in me:

I know that:

>> arg: 'z
== z
>> value? arg  ; this is the same as saying `value? 'z`
== false


This is 100% part of my knowledge.

The problem situation is arg: quote 'z

ARG is now 'Z, isn't it ?



dander
22:49My mind is reeling trying to think of a reason I would ever use it that way... I guess my actual question is "why is value? so permissive?" Why not enforce that it's argument be a word!?
9214
22:49@dander and until recently get worked with word!s only, which then was relaxed (https://github.com/red/red/commit/3fc8ef25b7328d8ddeff362761d0a21798047c82) to support any-word!. value? might be an oversight after that change, which is trivial to fix.
22:51@dander value? simply tells you if the given value will bite you back if you evaluate it; words that refer to unset certainly will.
dander
22:51@GiuseppeChillemi right, 'z is not a word!, it's a lit-word!. lit-word!s don't have a context, they are just values
9214
22:52> @GiuseppeChillemi right, 'z is not a word!, it's a lit-word!. lit-word!s don't have a context, they are just values

That's incorrect, all any-word! values are bound to context.
dander
22:53oh, my bad... so it's likely a bug then?
9214
22:53@dander what are you referring to? value? not working with lit-word!s?
dander
22:54I should stop at this point. I'm out of my depth :grimacing:
9214
22:55I already explained (twice) in passing why it is that way, [here](https://gitter.im/red/help?at=5dc5e73335889012b1d3fc20) and [here](https://gitter.im/red/help?at=5dc5f10fca778c1fbfcba9f8).
dander
22:57my apologies, I didn't quite understand what oversight you were referring to. Thanks for clarifying that
9214
22:57TL;DR value? should work with any-word!s (to be consistent with get change and Rebol behavior), but right now it works with word!s only, returning true for the rest.
GiuseppeChillemi
22:58@9214 I have skipped your messages as inside the point-free topic, reading them know.
9214
23:01@dander regardless, any-word!s _are_ bound to contexts. It's just that value? [fetches](https://github.com/red/red/blob/master/runtime/natives.reds#L1868) values for word!s only.
GiuseppeChillemi
23:02So,

>> value? quote 'z
== true


Because 'z is not a word value ! If it is it will be checked for a value !
23:04
if TYPE_OF(value) = TYPE_WORD [
			value: _context/get as red-word! stack/arguments
		]

greggirwin
23:07@GiuseppeChillemi does this help?
>> z: 1
== 1
>> reduce ['z quote 'z]
== [z 'z]
>> reduce reduce ['z quote 'z]
== [1 z]
GiuseppeChillemi
23:10@greggirwin The problem has been solved: [here](https://gitter.im/red/help?at=5dc5e73335889012b1d3fc20), [here](https://gitter.im/red/help?at=5dc5f10fca778c1fbfcba9f8) and [here](https://gitter.im/red/help?at=5dc5f3f3ea7d147cb3455a1b)
23:10Do you know the cause of the confusion ?
23:13The "other option":

I have thought all the time that value? AWORD checks if AWORD is SET, I mean as HELP AWORD: without evaluating it.
23:15This because when you see a function you don't know if its argument will be reduced or not. And for instruction checking words you could and up thinking its word will be not evaluated.
23:17Thanks to everyone
nedzadarek
23:32@9214
> @nedzadarek do .. end is an anonymous function (aka 'block' in Ruby parlance) that you explicitly pass to each method.

Is there a way to pass something implicitly?

> Your -> operator is apply in disguise, which Red does not have yet.

I don't think so. -> would just put a block into function's context. Function would do whatever it want with it.

> I don't see any implicit arguments here, that would be point-free style

Implicit block means it isn't in the function definition. I'm not sure whenever it's point-free style (yield does call a supplied function; it could be called how many times you want).

> "object whose method was called"

Objects, and OOP has nothing to do with it.

@greggirwin Let me think about implementing such mezz (little dsl I guess).
GiuseppeChillemi
23:35Another test is important:

USAGE:
     VALUE? value

DESCRIPTION: 
     Returns TRUE if the word has a value. 
     VALUE? is a native! value.

ARGUMENTS:
     value         ;no 'VALUE so it will be reduced

RETURNS:
     [logic!]


Also

The particular functioning of VALUE? on WORDS caused the additional confusion. You see Z and 'Z as output in my example, which are both VALUES former a WORD value, the latter a LIT-WORD value.

Again, a req.... proposal. Change the description of VALUE?

...
DESCRIPTION: 

     Returns TRUE if the word has a value. 
     VALUE? is a native! value.
...


to something like:

DESCRIPTION: 

If the reduced argument is a WORD, then it checks whether that word has a value in the context, otherwise it will  return false. VALUE? returns TRUE for all other type of values passed.


With the previous description:

....if the word has a value.

**Word** could be exchanged with the "VARIABLE" used as argument. The first time reader should be avoided this trap and explained that all other values returns TRUE.




23:36Good night to everyone, 00:36 here
Thanks @greggirwin , @dander and @9214
lucindamichele
23:37Ciao ciao!
GiuseppeChillemi
23:37Ciao @lucindamichele !
lucindamichele
23:39Ti parlo domani, probabilmente!
GiuseppeChillemi
23:44@lucindamichele Parli italiano ! :open_mouth:
lucindamichele
23:45Three quarters of study at UCLA demolished by 20 years of disuse!

9214
00:03@dander

> I should stop at this point. I'm out of my depth :grimacing:

Binding is quite a simple concept, I'm still puzzled why people fail to grasp it.

* Suppose you are jogging outside of town, in rural park of some sort. Another person runs towards you, pointing behind your back and yelling "rock!". You can deduce, from the _context_ where this phrase is spelled out (rural park, nature, trees, earth, rocks), that by "rock" he means "a solid mineral".
* Suppose you are on a music festival with your friend. Your friend point behind your back and says "rock!". You can deduce, purely from your surroundings (music, genres, nearby moshpit, guitar riffs that you hear), that by "rock" he means "musical genre".
* Suppose you are on some wrestling contest, as a spectator. The guy nearby you, who looks like a paparazzo, points behind your back and squeaks "The Rock!". Again, from the context, you can deduce that he probably just saw [Dwayne Johnson](https://en.wikipedia.org/wiki/Dwayne_Johnson) entering the ring.
* Suppose you and your teenage son decided to do some Jolly Cooperation in Dark Souls; you play together and then you hear him screaming "OMG it's The Rock!". From the context of the game's lore, you can deduce that you are about to get rolled in the ground by [Havel the Rock](https://darksouls.wiki.fextralife.com/Havel+The+Rock) and restart at the nearby bonfire.

In all of the examples, "rock" is a word that has a different meaning, depending on the context where it is used: "mineral" in the rural park, "musical genre" in the music festival, "Dwayne" in wrestling contest and "game boss" in Dark Souls.

Now, suppose you see the following phrase: "I slipped up on a rock while listening to rock and contemplating if The Rock would defeat The Rock on his first playthrough in DS". Each "rock" here has the same spelling, but different meaning, that is, they are [homonyms](https://en.wikipedia.org/wiki/Homonym). What determines the meaning of a given word? The context in which it is used. In plain English, you can infer it from surrounding words and phrases:

* (slipped, legs, ground) -> mineral
* (listening, music, festival) -> genre
* (defeat, person, wrestler) -> Dwayne
* (playthrough, game lore, Dark Souls) -> Havel

This is essentially what Red lets you do - to create homonyms. You can have [rock rock rock rock] block where each rock means a different thing, where it is _bound_ to a specific _context_. Not only that, but you can also change the meaning of any word, simply by altering its binding. Binding is this invisible thread weaven through each and every any-word! value; if you pull it, you find the meaning of a word (or absence of it).

>> rocks: []
== []
>> append rocks bind 'rock rural-park: context [rock: "mineral"]
== [rock]
>> append rocks bind 'rock festival: context [rock: "genre"]
== [rock rock]
>> append rocks bind 'rock wrestling: context [rock: "Dwayne"]
== [rock rock rock]
>> append rocks bind 'rock wrestling: context [rock: "Havel"]
== [rock rock rock rock]
>> reduce rocks
== ["mineral" "genre" "Dwayne" "Havel"]


This is why "scoping" and "variables" make no sense in Red.

Scopes form chains, but contexts are completely independent of one another; they are essentially namespaces ("semantic fields" if you wish). Rebol just tries to fake them, cloaking itself as a thing that "kinda-sorta looks like an Algol-family language with functions, lexical scope and conventional while loops and stuff".

Variables, in turn, are memory slots that can hold content that _varies_ (hense the name) over time. Words are not variables - the only thing that can change in them is their binding, but that's completely implicit. They are not memory slots, they are the _content_ of slots (value slots, that is) with an extra pointer to another value.
00:04And here is the punchline:
>> cutlery: [spoon spoon spoon spoon]
== [spoon spoon spoon spoon]
>> set cutlery 'spoon
== spoon
>> print cutlery
spoon spoon spoon spoon
>> phrase: split "There is no spoon" space
== ["There" "is" "no" "spoon"]
>> forall cutlery [bind cutlery context [spoon: take phrase]]
== [spoon]
>> cutlery
== [spoon spoon spoon spoon]
>> print cutlery
There is no spoon
00:48@nedzadarek maybe you should stop confusing us (and yourself) by mixing terminology. Red isn't Ruby, "block" here has a completely different meaning. Previously I thought that implicit_block means block! value which you want to print (f: func [][print implicit_block] f -> [1]), but now you are suddenly talking about {...} Ruby block and yield.

In Ruby, each method can take an optional block (Smalltalk term for lambda), which it can fetch from the call site with yield and then apply to some arguments; a callback, basically.

So, yes, as I said, Red's equivalent of yield would be apply; the rest is not applicable, because Red is not object-oriented, nor does it have optional arguments - if you need one, you use refinements. Moreso, what you ask for can be achieved either with closures (once we get them) or binding:
>> ->: make op! func [block value][do bind block context [implicit: value]]
== make op! [[block value]]
>> [print implicit] -> [1]
1
00:53@9214 [should be dark-souls: context [rock: "Havel"] tho'](https://gitter.im/red/help?at=5dc6026e4adf071a84f6afb7).
dockimbel
01:05@9214 Brillant explanation! Please save it in a wiki page, so it can be easily used for further references.
9214
01:07@dockimbel I have all this jotted down in my notes for a long-overdue blog post, which I'll eventually write at some point... but R&M season 4 comes first *burp*.
lucindamichele
01:08Lol. I was just asking offlist: I'd like to archive @9214 's post and possibly share it via social!
01:10There are at least three Rs in any Rick burp, @9214
danieloff
01:22@bitbegin btw I tried out the vscode extension briefly this evening, and it is working much better! Thanks again :)
greggirwin
02:15Very nice @9214.

Thanks for letting us know @danieloff.
GiuseppeChillemi
06:12Are "value slot" and "cell" homonyms?
nedzadarek
09:17@9214
> Previously I thought that implicit_block means block! value which you want to print (f: func [][print implicit_block] f -> [1]), but now you are suddenly talking about {...} Ruby block and yield.

Well, you mention point-free style as so I have to show how Ruby does it, hence yield.

> @nedzadarek maybe you should stop confusing us (and yourself) by mixing terminology. Red isn't Ruby, "block" here has a completely different meaning.

Both can be used as "do some code". The Red's blocks are more powerful, but they are not that different.

> So, yes, as I said, Red's equivalent of yield would be apply;

If you mean apply that can be called whenever and however you want (even 0 times) then yes.

> he rest is not applicable, because Red is not object-oriented

[Source](https://blog.appsignal.com/2018/09/04/ruby-magic-closures-in-ruby-blocks-procs-and-lambdas.html):
def each
  i = 0
  while i < size
    yield at(i)
    i += 1
  end
end

Where are your objects? Sure "an anonymous function" is an object of type Proc (as fair I remember). But it doesn't matter because it's just a code that you call (+ some arguments if you want).

> [print implicit] -> [1]

Sure it works but do you know why asked about those things? Because they are readable. Here you suggest to wrap whole function + it's arguments into some kind of wrapper (block! or paren!). Look how foreach would look like with "implicit" body argument:
[ foreach some-word some-series ] -> [
     print some-word
]

compare above with this:
foreach soome-word some series -> [
      print soome-word
]
hiiamboris
11:41@9214 this is so far the most confusing part:
> Variables, in turn, are memory slots that can hold content that varies (hense the name) over time. Words are not variables - the only thing that can change in them is their binding, but that's completely implicit. They are not memory slots, they are the content of slots (value slots, that is) with an extra pointer to another value.

And from what I can recall, every time words were compared to variables in this chat, it only added confusion. The best explanation you've had is the graphic one ☻ Or maybe it's better to step aside from English and accent the underlying structures instead, by saying that:
1. a *variable* in *interpreted* languages represents a tuple of [name, type, memory slot] (aka "boxed variable")
2. a *variable* in *compiled* strictly typed languages represents just [memory slot], since names and types are resolved at compile time
3. a *word* in Redbol is a pair of [name, context reference] whose value may be "get" from the referred context if it exists, contains the name, and associates a value (that is, a pair of [type, memory slot]) to that name. And further clarify that in the current implementation context always contains the name (it's checked by bind), and there's always a value (which may be of unset! type). And that our context can be indeed seen as a set of *variables* in the sense (1), though we prefer not to use this term.
9214
11:54@nedzadarek

> Well, you mention point-free style as so I have to show how Ruby does it, hence yield.

That's not what point-free style is, but whatever. I talked about one thing, you jumped to another.

> Both can be used as "do some code". The Red's blocks are more powerful, but they are not that different.

So, closures and heterogeneous lists are "not that different"? Mmkay.

> Where are your objects?

each is a method of top-level main object, previously it was a method of [1, 2, 3] array object; nothing to do with yield or procs, so, again, stop jumping from topic to topic.

> Because they are readable

Readable to whom? You're effectively derailing the topic into a matter of taste. Functions in Red do not (and likely will not) accept any implicit arguments, and all your made-up examples (in the last of which -> is completely useless, as it's the same as foreach some-word some-series [print some-word]) have idiomatic equivalents in Red: usage of refinements and leveraging of bindings. You're free to ignore all of that and continue to treat Red as Ruby - time has shown that you are more than OK with that. I myself wash my hands of this - time can be better spent elsewhere, and any attempt at technical discussion with you proved to be counterproductive.
12:31@hiiamboris the point is that "variable" is such an overloded term, coming with so many baked-in assumptions, that it does more harm than good then you label words as such. It starts with "oh, so it's just X like in language Y" and quickly snowballs into "blocks are lexical blocks", "existence of lexical scope", "call-by-value" and whatnot.
12:34There'is a level of indirection that exists in words, not found in variables. And "variable" itself can be data stored in another "variable" (a: 'b), so they can be both "container" and "content", even both at the same time (a: 'a).
nedzadarek
12:41@9214 >That's not what point-free style is, but whatever. I talked about one thing, you jumped to another.

You mentioned point-free style. I don't know why. I don't care whenever or not it's point-free style but you insisted on that so I mentioned yield - so you can fit into point-free style dichotomy.

> So, closures and heterogeneous lists are "not that different"? Mmkay.

You can execute code, carry some data. You have been using them like you would use Ruby's lambdas. So don't mkay me, ok?

> each is a method of top-level main object,

Man, you hate OOP, or something? Just because some function is a method doesn't mean you cannot implement it without classes. I mean, what is OOP about? Class/object = some data + functionality.
Here, the above code that you have to look for Ruby internals to prove that you are right. I have made it OOP-free:
yield: func [a] [print ['yeilds a]]
bl: [11 22 33]
each: func [bl] [
    i: 1
    while [i <= length? bl] [
      yield bl/:i
      i: i + 1
    ]
]
each bl


> Readable to whom? You're effectively derailing the topic into a matter of taste.

Maybe for @giuseppe... (something)? He wanted block as last argument. And **whole** discussion started because of taste.

> as it's the same as foreach some-word some-series [print some-word]

...

> You're free to ignore all of that and continue to treat Red as Ruby - time has shown that you are more than OK with that.

Lies.

> I myself wash my hands of this - time can be better spent elsewhere, and any attempt at technical discussion with you proved to be counterproductive.

You know what? The same goes for you sometimes. You are good at explaining things. When it comes to some discussions then it's worse. Gregg & Giesse are much better at discussions.
GiuseppeChillemi
12:42Word is associated to a value in a context. That is the most appropriate way or describing what is happening here
12:45Calling it a 'variable' has an associated mental context which evocates mechanisms which are not RED ones.
hiiamboris
13:14@9214 Agreed. It's just that since we are contrasting words to variables, we have to define both in a strictest way possible, and make this distinction very clear. Otherwise I'm afraid we will rather instill a (fragile) feeling of being knowledgeable about the matter than make people really know.
GiuseppeChillemi
13:18@9214 you are not loosing you time. Your are mastering the topic of meanings, words and contexts, in a great way. Your last notes could be used in an interchangeable way either in RED as in general linguistic, as in psychology. People with blocked mental context and meaning become patients of psychologist which create create new contexts and rebind the person to them. I am running as fast I can to be able to connect my knowledge to your words and merge both sciences. Hope that day you will understand your time has not been vasted in any way.
nedzadarek
13:26@greggirwin [implicit block in the Red implementation ](https://gist.github.com/nedzadarek/bb3614f8ee8d53bc6bbff21110ab4d73) at mezz level. Read comment for more information.
13:28@GiuseppeChillemi ^^ what do you think about it? You once wanted "block as last argument".
9214
13:33@hiiamboris my experience tells me that if people want to see (and call) them as variables - they will, no matter what arguments you lay on the table. We cannot help Dunning-Krugers, but when it comes to newcomers who want to actually learn Red (as opposed to "treat Red as X"), we ought to try, starting with definitions and terminology.
hiiamboris
13:34:+1:
14:09Should we have in support function contexts? I find myself mocking it as :f = context? bind word :f
GiuseppeChillemi
14:30@nedzadarek I am in mobile. I will take a look at it later.
toomasv
15:31On variables vs. words. One possibility is to declare that variables are this and that ontologically and there is no such thing in Red and to call it such is *anathema*. Another possibility is to say that words in Red may seem like variables in other PL-s but are much more. And then explain.
pekr
15:38Beware, Anathema is my most favourite band :-)
hiiamboris
16:26@pekr And what do you think of [these guys](https://youtu.be/oeW8gIKcoe8)?
pekr
16:43Never heard of them. Will look-up some songs, thanks :-)
greggirwin
17:16:point_up: [November 9, 2019 7:09 AM](https://gitter.im/red/help?at=5dc6c87eeeb63e1a8382463e) @hiiamboris function contexts only exist during their evaluation, correct? What are you using it for?
pekr
17:30Gregg, really? Wasn't there something called 'indefinitive extent', or something like that? That way function was able to accumulate values during the consecutive calls?
greggirwin
17:38@pekr, I'm referring to this behavior:
>> fn: func [a][bind 'a :fn]
== func [a][bind 'a :fn]
>> val: fn 1
== a
>> get val
*** Script Error: context for a is not available
*** Where: get
*** Stack:


17:39If you're thinking about the need to copy series, revisit the wiki page on that. Series are values in the body.
hiiamboris
17:55@greggirwin
> What are you using it for?

To check if the word I'm setting does belong to the function, and not to the global context. Though, I've changed the algorithm and have no need of that anymore. But should anyone require to do this, there's no simple way (like in). Either the solution above or finding that word in spec.
greggirwin
18:06:point_up: [November 9, 2019 6:26 AM](https://gitter.im/red/help?at=5dc6be985a979223c3a08fcf) thanks for mocking that up @nedzadarek. I think I'm missing something though. If you rely on -> there is still nothing implicit going on. You're simply creating a new syntax for a single, unnamed, optional arg (which must be a block?). If that's the goal, I don't think it adds value beyond the existing refinement approach. Different syntax, to denote where args end, but not strictly better IMO.

Tried a quick example. In straight Red:
imp-append: func [series value /with extra] [
    append series value
    if with [
        append series extra
    ]
    series
]
blk: [a b c]
imp-append imp-append/with blk 'x [1 2 3] 'y

With implicitly:
imp-append: func [series value] [
    append series value
    if block_given? [
        append series implicit-block
    ]
    series
]
blk: [a b c]
do probe implicity body: [
    imp-append imp-append blk 'x -> [1 2 3] 'y
]

Must have hit a bug (which is fine) because the implicit version doesn't work.

- If it requires an op-like separator, that's potentially confusing, and is just a different refinement syntax, but more limited.
- If it doesn't, I'd like to see chained call examples, because that's the thing I see as really problematic.
18:08@hiiamboris excellent use case. Would you please add your workaround to the Guru Meditations wiki page?
hiiamboris
18:08If you think it's worth it...
greggirwin
18:08I do. :^)
hiiamboris
18:08mkay ☻
greggirwin
18:08In case *I* need it. ;^)
endo64
19:49> Gregg, really? Wasn't there something called 'indefinitive extent', or something like that? That way function was able to accumulate values during the consecutive calls?

@greggirwin I think @pekr thinks that way, because R2 works like that:

; R2
fn: func [a /local b][bind 'a 'b]
v: fn 1
; == a
get v
; == 1


a few weeks ago @9214 explained this behavior for Red and R2 IIRC.
GiuseppeChillemi
20:04@endo64

>> a few weeks ago @9214 explained this behavior for Red and R2 IIRC.

Where ? Have you a link ?
greggirwin
20:05Thanks @endo64.
pekr
20:37Well, by "indefinite extent" I do remember some R2 functionality, which was maybe later replaced by closure? From one of the R3 blog articles: "closure! function with persistent local values (indefinite extent)"
20:38It was the ability to "remember" local values for the next function call ....
GiuseppeChillemi
21:05I think I have found the cognitive error which is happening quite often.

The description of value? function is:

"Returns TRUE if the WORD has a value"

Visibile part of the function:

Value? WORD

Element WORD is present as the final value in the mental visualization of the description of the function.

So, if value "Returns TRUE if the WORD has a value", Who is WORD here ? The one the outer eyes are perceiving or the word our inner eye is looking at?

When we try to resolve uncertainty, it seems the visible item recognized as WORD wins.

Generalizing, it happens when the value of the argument of a function has the same type of visual aspect of the argument (I mean the element after the function name) and the description is mentioning it as target.

Let's create a SPLIT function:

>> help SPLIT

USAGE:
     SPLIT path

Description:

     SPLIT divides the path in its parts and returns them as block.


ARGUMENTS:

     path


Example:

SPLIT MY/PATH


Which is the output?

I am 100% sure some of you has thought the result is

>>[MY PATH]


Instead it is the path value retrieved from MY/PATH which could be ANY/OTHER/PATH

>>[ANY OTHER PATH]


Please confirm is someone has thought about [MY PATH], even just for a moment.

greggirwin
21:39@GiuseppeChillemi please move to red/chit-chat or red/sandbox for thought experiments.
hiiamboris
21:48I'm wondering what was the reasoning behind making none/false/true/no/yes - words rather than values recognized by the lexer. Do we want to be able to change them like none: 420 (and it hangs up...) ?
greggirwin
21:51Syntactic cleanliness I imagine, with construction syntax when you needed exact semantic meaning. I don't remember if Carl ever wrote about that. Red has rules like any dialect, where words have meaning.
GiuseppeChillemi
22:05@nedzadarek
> @greggirwin [implicit block in the Red implementation ](https://gist.github.com/nedzadarek/bb3614f8ee8d53bc6bbff21110ab4d73) at mezz level. Read comment for more information.

Have not followed the full topic. Have to read it again. I have a little request: could you add a description to the gists ?
greggirwin
22:12:point_left: [Giuseppe's thought experiment moved to red/sandbox](https://gitter.im/red/sandbox?at=5dc73316fd6fe41fc05628fb)
GiuseppeChillemi
22:33@hiiamboris

>> a word in Redbol is a pair of [name, context reference] whose value may be "get" from the referred context if it exists, contains the name, and associates a value (that is, a pair of [type, memory slot]) to that name. And further clarify that in the current implementation context always contains the name (it's checked by bind), and there's always a value (which may be of unset! type). And that our context can be indeed seen as a set of variables in the sense (1), though we prefer not to use this term.

Great explanation. This part deserves a place into [guru meditations](https://github.com/red/red/wiki/%5BDOC%5D-Guru-Meditations) too.

I miss only 2 the explanation about 2 terms I have seen being used about this topic:

What is a *value slot *and a what is *cell* ? Are they any of the above mentioned or some other underlying structures?


hiiamboris
22:36Cell is basically a Red value. Just an R/S term for it.
22:39https://github.com/red/red/blob/1d32938a2c39286c14173a4ff78f21dd3c17d905/runtime/allocator.reds#L36
22:40where all the https://github.com/red/red/blob/master/runtime/datatypes/structures.reds values fit into
GiuseppeChillemi
22:46@hiiamboris Now the whole picture is quite complete. A cell is the building block/alias of type structures that holds the data in their wholeness and we recognize at RED level as type and value with its visual appeareance.
22:50Found the document on [values slot](https://github.com/meijeru/red.specs-public/blob/master/specs.adoc#directindirectfunction-types)
22:55Here is also a Vladimir message on [Value Slots](https://news.ycombinator.com/item?id=18866864)
greggirwin
23:42That last one is an excellent post, and is probably going to be in an article in the future.

danieloff
03:39Hi guys, quick question: would it be theoretically possible to add red to the codingame.com website? I am not too familiar with the site myself, just tried it for the first time last week. Looked like the site just uses standard input/output to communicate with the programs so I imagined it would be something that might work. (Also I have not asked on codingame yet)
nedzadarek
13:32:point_up: [November 9, 2019 11:05 PM](https://gitter.im/red/help?at=5dc738305eb2e813dbf68452) @GiuseppeChillemi here is your [comment](https://gist.github.com/nedzadarek/bb3614f8ee8d53bc6bbff21110ab4d73#gistcomment-3079092)
14:46@greggirwin I'm sorry for such huge text.
> If you rely on -> there is still nothing implicit going on.

Implicit from the definition side - you don't specify it. Sure, you have to explicitly pass it (using some kind of new syntax) but I don't think you can pass something implicitly (at least without confusing programmers).
Well, for the term "implicit block" curse Ruby people.

> which must be a block?

No, it could be anything. It's just block! is the most useful. It can hold a data and a code. Sure, you could pass something else... but I just wanted to make it simple for now.

> You're simply creating a new syntax for a single, unnamed, optional arg
> Different syntax, to denote where args end, but not strictly better IMO.

Think about it more as the last argument that doesn't change place when you use refinement(s). @GiuseppeChillemi wanted his block to be last whenever or not he has added refinements.

> Must have hit a bug (which is fine) because the implicit version doesn't work.

Pardon my laziness - I have forgotten to return the block. implicity have been just updating the block (which I have been doing instead of doing a return value from implicity). Here is [updated version](https://gist.github.com/nedzadarek/bb3614f8ee8d53bc6bbff21110ab4d73).

> If it requires an op-like separator, that's potentially confusing,

The way refinements are used with function are confusing as well. Well, at least for more complex examples.

> and is just a different refinement syntax, but more limited.

It's different than function-name/ref1/ref2/.../block arg1 arg2 arg ... some-block. Here you must keep /block as a last refinement.
It may be limited (only one argument) but it doesn't mean it cannot be useful. It may not be good enough for the Red thought.

> If it doesn't, I'd like to see chained call examples, because that's the thing I see as really problematic.

As for updated version, chaining works. However, I don't like chaining in the Red. So I would use some sort of parenthesis (e.g. imp-append (imp-append/with blk 'x [1 2 3] )'y). OOP-like syntax (obj.method(args).method2(args)) is much clean for chaining.
The idea is that an *implicit_block* goes to the most inner/closest function (f1 f2 f3 ->[..] would goes to the f3).
greggirwin
16:26Refinements are a different approach than other langs, but are consistent. My point about ops is that their evaluation is elevated above funcs. -> would be an exception to that rule, correct? Otherwise chaining won't work at all. I know you're not making it an op!, but it looks a lot like one. I also know ops don't have to be just special characters.

On the use of parenthesis, and coming back to the original goal, this is exactly what dialects are for. Other langs don't let you do this, so you have to use normal function interfaces, with refinements and such. Not so in Red. I always appreciate generalizing ideas, but this is a non-issue for Red. Red is already enormously flexible in how it lets you do things. It's design is a balance between trying to keep the rules manageable (if not simple), and providing a rich language.
nedzadarek
17:04> Refinements are a different approach than other langs, but are consistent. My point about ops is that their evaluation is elevated above funcs. -> would be an exception to that rule, correct? Otherwise chaining won't work at all. I know you're not making it an op!, but it looks a lot like one. I also know ops don't have to be just special characters.

I see your point, and yes, that's correct.

> this is exactly what dialects are for

Dialects are wield beasts (especially dialects based on String!). However they don't have functions' strong feature built-in:
- documentation
- type checker

Sometimes you just want some small things and you don't want to do whole dialect-thing. There is just huge gap between functions and dialects.

> Red is already enormously flexible in how it lets you do things. It's design is a balance between trying to keep the rules manageable (if not simple), and providing a rich language.

That's understandable.
pekr
17:13I do remember we have tried to come up with some ideas for the help system working with dialects. I was thinking about something like help/with "button" GUI, so that those could be registered modules to help system, but maybe those could work somehow automa(ti)(gi)cally ....
nedzadarek
17:14@pekr I think I had some ideas as yours as well.
greggirwin
17:23Documenting dialects, and higher level dialecting tools in general, is something we *really* want to offer. They are, as you say @nedzadarek, a lot more work than functions. But there are many small steps we can take in between. I offered one initially :point_up: [here](https://gitter.im/red/help?at=5dc08982f26ea4729d54c02c). So easy, and just add a doc string. Of course you don't get the normal type checking done for funcs, but it's a few lines to add that for any custom spec. We can even generalize that. I call it vet in my experiments, but it ties to both Design By Contract and Dependent (constrained) types, so more thought is needed.
GiuseppeChillemi
18:03@nedzadarek
>> I'm sorry for such huge text.

Considering the length of the messages I have written the last week, your is a simple tweet!
19:10@9214 I have tried to represent your [explanation](https://gitter.im/red/help?at=5dc6026e4adf071a84f6afb7) with an image. I hope it correctly represents your words.
19:10[![image.png](https://files.gitter.im/red/help/PJ5m/thumb/image.png)](https://files.gitter.im/red/help/PJ5m/image.png)
AiguyGary_twitter
19:59Wouldn't this just equate to the scope of a variable in another language?

A variable or function in a particular scope could be defined differently within a different scope.

So is scope and context the same thing?

So then is a dialect just a way of creating a new scope where words from other scopes including global are overridden?

I have not really used dialects yet but thought they were syntactical templates that you could define to make your code read more like naturally like English than it would look if you just embedded the code in a function.

Also I had asked before about the performance implications of dialects because it would seem that they would require additional parsing at least the first time they are used and my load times are up to 13 seconds already but when the Fast Lex branch is released that time should go away so maybe I could look at a dialect to replace my > 15,000 sections of Red code at that time.

''' CD: lev ShortestDist UserInput/text "That is a Ben Franklin quote isn't it?"
if CD < ShortestDist [ShortestDist: CD
AIResponse: rejoin ["The earliest version that I know of the current form of the proverb was printed "
"in John Clarke's Paroemiologia Anglo-Latina in 1639. but Franklin did popularize that "
"exact phrase in America in his Poor Richard's Almanac which was an annual journal "
"published by Benjamin Franklin under the pseudonym of Poor Richard between 1732 and 1758."]
AI/Memories: [AI/He: copy "Ben Franklin"]]
'''

GiuseppeChillemi
20:02@AiguyGary_twitter This is the representation of context and meaning generally. Give me a moment I will try to represent scopes like in RED...
nedzadarek
20:24> Dependent (constrained) types

I have built dependent types' system in the Red so I know more or less what you mean. However I don't understand *constrained* part.

> I offered one initially :point_up: here.

I'm confused. I don't see any suggestion about "between things". Maybe I'm missing something. If not is this correct link?

> vet

I'm curious how it join DbC & DT to document dialects. I get the feeling that both may not be enough. I may be wrong thought.
Still, DbC & DT could be nice thing to add to the language.
20:25@GiuseppeChillemi nice
GiuseppeChillemi
20:33@AiguyGary_twitter Here I am, just completed:
20:33[![image.png](https://files.gitter.im/red/help/5YmG/thumb/image.png)](https://files.gitter.im/red/help/5YmG/image.png)
20:36I represented made a block of code with words from different contexts.

If you perform:

probe get block/3
== "Champion"


20:39If you rebind that word to another context you have a different result.
20:40So, in RED when you assemble a piece of code can make it from words coming from different contexts that have a value tied to that context and a different value on another.
20:44There was an error in the title.
20:44[![image.png](https://files.gitter.im/red/help/WdJq/thumb/image.png)](https://files.gitter.im/red/help/WdJq/image.png)
20:45Here is the correct one.
20:48And to make thing simple here is the code with evaluation step:

probe get block/3    ;Third element of the BLOCK is the word - ROCK -
   v
Probe ROCK           ;ROCK context is number 3, it's value in that context is  "champion"
   v
=="Champion"

20:56(Pardon, I have made some modification to the code, now it is complete)
hiiamboris
21:05Lovely pictures ☻
GiuseppeChillemi
21:10@hiiamboris (My masters think I do not do my homeworks, so why not demonstrating them I read carefully each of their words, visually representing their explanations? This also let me give back to the community what I have received)
AiguyGary_twitter
21:40I do something a bit similar but with Object. If I had 3 objects declared Context1, Context2, Contest3,
my block would reference [Context1/Name Context2/Place Context3/Rock]

I do see the advantage of being able to use numbers to refer to contexts instead of Object names because then you can iterate through contexts like an array. I think I read a while back that arrays with numeric subscripts are on the roadmap but of course you can simulate them to some extent with blocks in Red already.

GiuseppeChillemi
21:50Gary, I supposed I need to change numbers to a word to avoid thinking that context could have numbers and... Bingo! No, contexts can't have number has name until you call them One, Two, Three 😉
22:03@AiguyGary_twitter
Here is a solution: anonymous contexts. If you store objects in a block as anonymous elements you can iterate through them using their position in the series:

>> mycontainer: copy []
== []
>> append mycontainer make object! [a: 22 b: 33 c: "Hello"]
== [make object! [
    a: 22
    b: 33
    c: "Hello"
]]
>> append mycontainer make object! [a: 44 b: 55 c: "world"]
== [make object! [
    a: 22
    b: 33
    c: "Hello"
] make object! [
    a: 44
    ...
>> probe mycontainer/1/a
22
== 22
>> probe mycontainer/2/a
44
== 44
>> probe mycontainer/1/c
"Hello"
== "Hello"
>> probe mycontainer/2/c
"world"
== "world"
>>


Here is an iteration code:

>> repeat idx length? mycontainer [probe mycontainer/(idx)/a]
22
44
== 44
>>


I hope it is what you were searching for.

AiguyGary_twitter
22:32Yes, that simulates or reproduces the functionality of an array rather nicely.

So if I referenced mycontainer/15000/a Would that be a sequential memory scan stepping over all preceding values or is the 15000 indexed as in a map.
GiuseppeChillemi
22:39@AiguyGary_twitter
>>Yes, that simulates or reproduces the functionality of an array rather nicely.

Yes, it is an array of anonymous objects.

Other members will reply as I do not have such deep knowledge about non hash! type blocks working.
endo64
23:03> "memory scan stepping over all preceding values"

No scanning, accessing by index is O(1).
GiuseppeChillemi
23:10@endo64 so RED will jump to the index position using a jump table without seeking?
endo64
23:38No seeking, it just gets the value in that offset: https://github.com/red/red/blob/master/runtime/datatypes/series.reds#L341

greggirwin
18:06:point_up: [November 10, 2019 1:24 PM](https://gitter.im/red/help?at=5dc871fbeeb63e1a838d7034) @nedzadarek, What I meant was that Dependent Types are reified constrained values. On the code, the example I posted, which maybe I messed up or confused in a reference, was this:
fordata: func [
    spec [block!]
    body
][
    name: spec/1
    data: spec/2
    where: spec/where
    ...
    if any [
        none? where
        all [block? where  all where]
        all [not block? where  cause-error ...]
    ][
        do body
    ]
]
fordata [x y where [...]] body
fordata [x y] body
18:21@GiuseppeChillemi an easy way to visualize contexts is as a 2-column table:
18:21[![image.png](https://files.gitter.im/red/help/G5JU/thumb/image.png)](https://files.gitter.im/red/help/G5JU/image.png)
18:22Your diagrams look nice though. :^)
18:23@AiguyGary_twitter did you get your context vs scope question answered?
TimeSlip
19:09@rebolek @toomasv Thank you two sooo much. You have no idea how long that would have taken me to figure out by myself. Appreciate it!
toomasv
19:59@TimeSlip There is a more versatile one [too](https://gist.github.com/toomasv/8de193279fe556b6bb4f7b67c7e18c22).
GiuseppeChillemi
20:47@greggirwin Thanks Greg, I will use that kind of table to describe some internal data structures in the future. I have used so much space and a large context rectangle to give a sense of the concepts and not a field-oriented technical document (But I could be wrong, of course)

TimeSlip
02:29@toomasv Thank you!
toomasv
03:57@TimeSlip You are welcome!
semiherdogan
07:37Hello,
i have builded red from source, i am using MacOS. (do/args %red.r "-r %environment/console/CLI/console.red").
After running builded console when i tried view got "Script Error: view has no value".
How can i add view when building console?
Oldes
07:47@semiherdogan you are compiling command line version of the console... if you want to include the View in it, add needs: 'view into header like [here](https://github.com/red/code/blob/master/Showcase/calculator.red#L6), save it into file console-with-view.red and compile it again.
pekr
08:07@semiherdogan You are using a wrong path imo. Try the following: do/args %red.r "-r -t Windows %environment/console/GUI/gui-console.red"
semiherdogan
08:12@pekr i am using macos and as far as i know gui console only exists on windows
08:12@Oldes thank you, its working now.
pekr
08:14ah, missed the part with MacOS, sorry ....
semiherdogan
08:23no worries :)
rebolek
13:50@semiherdogan GUI console exists on macOS too.
greggirwin
19:11@semiherdogan feel free to add notes to https://github.com/red/red/wiki/%5BNOTES%5D-Compiling-with-console-functions---input,-ask that may help others.

semiherdogan
13:49@rebolek thank you, i didn't know gui console exists on macOS too. (builded from source and its working)
@greggirwin i will add my notes there :thumbsup:
rebolek
13:50@semiherdogan you're welcome!
GalenIvanov
14:36I was trying to solve a question in the Code golf section of StackExchange using Red: [Format a swedish phone number
](https://codegolf.stackexchange.com/questions/195787/format-a-swedish-phone-number)
14:37Can someone spend some time and explain to me how to approach this type of parsing strings?
14:38My naive initial approach (for the numbers without area code) was this:
rebolek
14:38Funny rules :) I need to leave now, but I'll take a look at it later.
GalenIvanov
14:39
>> f: func[s][
[        digit: [skip]
[        two+one: [2 digit opt digit]
[        parse s [
[            [opt copy b two+one
[             copy c two+one
[             copy e 2 digit] (print[b c e])
[        ]
[    ]
== func [s][digit: [skip] two+one: [2 digit opt digit] parse s [
    [opt copy b two+one 
       ...
>> f "27983516"
279 835 16
== true
>> f "6278304"
== false
>> "627830"
14:44I only get the longest possible parts of the string and miss the backtracking. I'm sure I'm terribly wrong. The input is always valid one, that's why I'm not using #"0" - #"9" for the rule.
14:44@rebolek Thank you!
hiiamboris
14:57Backtracking is done by the | thingie. [2 digit opt digit] is the same as [2 3 digit]. I would do some dispatching using their rules (that 8 vs 1, 2, 3, 4, or 7 vs 5, 6, or 9 especially). Like ["8" (n: 2) | ["5"|"6"|"9"] (n: 4) | (n: 3)] n digit and such
GalenIvanov
15:01@hiiamboris Thanks! Yes, I realized the [2 3 digit] is the same thing as opt.... I'll try your suggestion later
hiiamboris
15:04:+1: let us know how it goes ;)
toomasv
21:17 :wine_glass:
>> rule: [opt area format]
>> foreach [number test] numbers [parse num: copy number rule print [pad form num = test 6 pad form num 15 test]]
true   279 835 16      279 835 16
true   627 83 04       627 83 04
true   62 78 30        62 78 30
true   118 65          118 65
true   0679-348 21     0679-348 21
true   0927-58 61 30   0927-58 61 30
true   037-482 10 96   037-482 10 96
true   042-80 79 61    042-80 79 61
true   046-298 73      046-298 73
true   08-971 063 84   08-971 063 84
true   08-185 93 02    08-185 93 02
true   08-37 94 51     08-37 94 51
true   0480-93 65 72   0480-93 65 72
true   095-702 41 68   095-702 41 68
true   060-572 91      060-572 91
true   04-80 97 14     04-80 97 14
true   0800-625 17     0800-625 17
true   09-10 65 74     09-10 65 74
hiiamboris
21:27Lovely ;)
Don't forget to shorten every word to 1 char ☺ And maybe obfuscate the code in some other way, you know, for solidarity with other contestants :D
GiuseppeChillemi
22:25I often find myself searching for KEY and changing the value next to it.
Obvoiusly change find/tail series value replacementis your friend here. Replace does a similar job without the additional find/tail. Is there a replace like command that let you change the value next to the found key without issuin multiple words ? Something like a replace/after but not PUT as it always add while a replace/after should fail if the searched key has not been found.
dockimbel
23:21@GiuseppeChillemi
>> list: [a 2 "b" 3 #c 4]
== [a 2 "b" 3 #c 4]
>> key: 'a
== a
>> list/:key: 0
== 0
>> list
== [a 0 "b" 3 #c 4]
>> key: "b"
== "b"
>> list/:key: 9
== 9
>> list
== [a 0 "b" 9 #c 4]
>> key: #c
== #c
>> list/:key: 99
== 99
>> list
== [a 0 "b" 9 #c 99]
GiuseppeChillemi
23:50@dockimbel Thanks Doc, this evening I focused too much on using change/replace/find and I totally forgot path notation word/:key: something or word/(key): something does this job !

toomasv
05:19@hiiamboris OK, here is the minimized/obfuscated rule:
[a ["0" ["8" a ["0" a ["0"]] 
    | c3 e: b a ["0" a ["0" :e]] | c4 e: b f: b a ["0" :f a ["0" :e]]
] a [s: e (5 > f s) (s: d s) :s a ["0" (s: d s) :s]] g "-"] [
s: e (5 < l: f s) (m: l % 3 n: 2 - m) m [3 b g " "] n [2 b g " "] 
    | 3 b g " "
]]
GalenIvanov
07:35@toomasv Looks cool! :)
toomasv
08:20@GalenIvanov :smile: In full form it has no chance to get close to *shortest* rule. Alas, neither can it contend for that title in this contracted form.
GalenIvanov
08:36@toomasv Red's parse has no chance to beat regex in terms of brevity. I know it's main advantage is readability.
I don't have much experience in parsing - I'll appreciate if you give me some directions how to tackle this problem (just for numbers with no area code).
toomasv
08:39Sure:
format: [s:
	if (5 < l: length? s)(m: l % 3 n: 2 - m) 
		m [3 skip insert " "] 
		n [2 skip insert " "]
	| 	3 skip insert " "
]
numbers: [
"27983516" 		"279 835 16"
"6278304" 		"627 83 04"
"627830" 		"62 78 30"
"11865" 		"118 65"
]

>> foreach [number test] numbers [parse num: copy number format print [pad form num = test 6 pad form num 15 test]]
true   279 835 16      279 835 16
true   627 83 04       627 83 04
true   62 78 30        62 78 30
true   118 65          118 65
GalenIvanov
08:48@toomasv Thank you! Now I see it's convenient case to use module arithmetic.
toomasv
08:57@GalenIvanov You are welcome! There may be shorter ways to do this, but that's how I considered it:
1) number can be 5 -8 characters long
2) there is only one way to group characters if length = 5, and 3 ways if length > 5, so the first test
3) if length > 5, we have three groups, longer ones (if any) first, shorter ones after
4) with modulo we find how many 3-groups are there (m), the reminder (3 - m) will be short groups
5) we don't need to insert space in the end, so we need only n: 2 - m insertions for short groups
GalenIvanov
09:24@toomasv Yes, I understood how it works - I wrote down a table with l, m and n and checked the four cases. Thanks once again!
toomasv
09:25:+1:
15:59How to change cursor on a face after it is created, e.g. when moving over some smaller region of it? Changing face/options/cursor doesn't seem to work. May be there is some other way?
16:10E.g.:
view [
   base 200x200 cursor 'Arrow all-over 
   draw [fill-pen red box 50x50 150x150] 
   on-over [
      cur: either within? event/offset 50x50 100x100 ['Hand]['Arrow] 
      if face/options/cursor <> cur [face/options/cursor: to-lit-word cur]
   ] 
   on-down [probe face/options]
]
hiiamboris
16:13view [box green options [cursor: 'cross] on-down [probe face/options/cursor: first head remove find copy [cross arrow] face/options/cursor change face/parent/pane face] ]
16:13the only problem is it's twinkling :)
toomasv
16:14@hiiamboris Thanks!
hiiamboris
16:15I guess you could work around that by making an almost transparent face which twinkling won't be visible ☻
16:16A workaround for a workaround :D
toomasv
16:16That's the spirit! :+1:
16:20Works nice and smooth.
17:06Unfortunately I can't eliminate twinkling on a more sophisticated face, and it's unstable -- after few twinks the face disappears :weary:
hiiamboris
17:15That's strange. Doesn't disappear for me
greggirwin
17:27Are you on Win7 @hiiamboris? Works fine for me on Win10. I think @toomasv means it has issues in his advanced scenario.
hiiamboris
17:28Yeah. Tried also area, text-list
toomasv
17:29Yes, simple one as above worked nicely, but the one with complicated draw and cursor-changing boxes all around goes mad.
hiiamboris
17:30You have a snippet?
toomasv
17:31I'll compose one. Original is er.. too much.
greggirwin
17:32The magic in Boris' example is change, correct?
toomasv
hiiamboris
17:32Indeed
greggirwin
17:33He distracts me with Red Herrings like first head remove find copy .... ;^)
hiiamboris
greggirwin
17:38I think @toomasv did a [cycler](https://gist.github.com/greggirwin/f58f82eb2ef4e6d9b1c40d3f319b8d83) as well. Should probably have used next as the func name there. But also did [this one](https://gist.github.com/greggirwin/c0fe722deffb7b448286b5a819e0ca2b)
17:38Can't believe I used also in there. ;^)
toomasv
17:43Old [rings](https://gist.github.com/toomasv?page=10)? Don't know if they are alive still.
greggirwin
18:23Ah, yes! So clever. :+1:
GiuseppeChillemi
23:28When you parse a RED block and you match a sub-block with your rules, how do you continue parsing the content of the sub-block?
greggirwin
23:29Use into.
GiuseppeChillemi
23:30Thanks
greggirwin
23:30parse [1 2 3 [a b c]] [3 integer! ahead block! into [some word!]]
GiuseppeChillemi
23:37Is also possible to change the parsed series with another while parse is running ?
greggirwin
23:56Not sure what you mean. You can modify the series you're parsing, but you can't parse a different series. Of course, the trick there is to modify the current series by inserting data from the other series. But then you have to copy it back out to mod the original, and it's ugly. Not recommended.

GiuseppeChillemi
00:11I meant just date but it is not a needing, just a curiosity. Sometime in fantasies has appeared the idea of continuous parsing data streams and jumping from a flow to another if a match is found. This inside the same parse rule. So I was asking.
00:12*I meant just that
toomasv
04:20You can include parse in parens of another parse and so jump between parsing multiple inputs.
04:41Silly example:
input1: [1 2 3 4 5 6 7 8 9 0] input2: "abcdefghijk"
parse input1 [some [i: 
    if (find [3 7] i/1) (
        j: i/1 parse input2 [j skip insert (form j) input2:]
    ) skip | skip
]]
head input2
== "abc3defghij7k"

greggirwin
04:43Good point. I was thinking of using the current rules and switching inputs, such that they worked like nested function calls.
toomasv
05:01Ah, yes, I didn't get the "same rule" part.

fvanzeveren
08:42Hello all, sorry if this question has already been raised before, but what is the equivalent of system/options/cgi in red? Thank you.
toomasv
09:45Hello @fvanzeveren ! I believe [this wiki page](https://github.com/red/red/wiki/%5BDOC%5D-Using-Red-as-CGI) will help you.
fvanzeveren
13:14@toomasv thank you for the link. I tried http-tools.red with IIS 10, but the http-headers object returned has all its attributes set to none. make object! [ server-software: none server-name: none gateway-interface: none server-protocol: none server-port: none request-method: none path-info: none path-translated: none script-name: none query-string: none remote-host: none remote-addr: none auth-type: none remote-user: none remote-ident: none content-type: none content-length: none user-agent: none other-headers: #() ]. The code of the chi script is the following:
Red []

do %http-tools.red
print "content-type: text/html^/"

print [<!doctype html>]
print [<html><head>]
print [<title> "HTTP Headers from http-tools.red" </title>]
print [</head>]
print [<body><p> mold http-headers </p></body>]
print [</html>]
toomasv
13:15@rebolek ^
fvanzeveren
14:46regarding IIS 10, it seems that the piece of code call/wait/output "printenv" o: "" does not return the http headers under IIS 10...
14:47printenv seems to be a linux thing, not a windows...
14:50let's try set instead
16:00set is working fine. After making some adjustments on http-tools.red, it is working fine on IIS 10
16:04I have another question, what is the red equivalent to rebol -cs to allow access to all files?
hiiamboris
16:25No builtin security yet. No flag needed.

greggirwin
01:38@fvanzeveren if you would update the wiki, so others can learn from your experience, that would be great. Thanks!
fvanzeveren
06:58@greggirwin I will try :) but this will be the very first time for me ;)
GiuseppeChillemi
07:00@fvanzeveren which are "some adjustments" you made?
fvanzeveren
07:02@GiuseppeChillemi
I updated get-headers in %http-tools.red
get-headers: func [/local o os cmd] [
	os: os-info
	cmd: either find/match os/name "windows" ["set"] ["printenv"]
	call/wait/output cmd o: ""
	http-headers: parse-headers o	
]

07:07Yesterday, I made the required adjustments to magic350.cgi so as it works with Red... to make Red Server Page on IIS, Apache, etc... Works fine so far. I will try to check with Olivier Auverlot (original author) if I can take over the dev of his scritpts and distribute a new version on github.
rebolek
08:24@fvanzeveren thanks for info. I'm working on some changes to HTTP-tools and you've probably hit some partially/non-working version. I'll check it and fix it.
fvanzeveren
12:22Hello again. Is there some libraries out there allowing for MySql/MariaDB connection in red?
rebolek
12:23@fvanzeveren port support is required for connecting to MySql/MariaDB, so you need to wait a bit more
fvanzeveren
12:25@rebolek thank for the info. To be able to replace rebol by red as cgi back-end, db access is a must! Hope to see this soon :)
viayuve
13:23this i can not figure out I want to copy month folder in E:\share\any-name-of-computer\month-wise-BKP-folder(Nov)\datewisefolder(1-1-2020)
13:25First I want to copy like Nov only after that check all files are okay and delete Nov directory.
13:26from original directory.
endo64
13:51@viayuve It's difficult to understand what you are trying to do, what problem do you face and how it is related to Red, can you give more info?

GiuseppeChillemi
19:49So, when parsing a block Red loses the ability to differentiate between words and lit words in the parsed block. Do you confirm or am I missing something?

>> parse ['a] ['a]
== true
>> parse [a] ['a]
== true
>> parse ['a] ['a]
== true
>> parse ['a] [quote a]
== true
>> parse [a] [quote a]
== true


toomasv
19:55You are missing /case.
GiuseppeChillemi
19:58Back in the Red doc cave, see you soon!
20:27@toomasv I have found a reference in Red by example. Is there someting more complete?
toomasv
20:38I quickly looked and it doesn't seem comprehensively treating /case. I think little experimentation is best teacher here.
hiiamboris
20:45https://github.com/red/red/issues/3029 https://github.com/red/red/issues/4101
GiuseppeChillemi
21:24Also https://github.com/red/red/issues/3554

toomasv
11:21@GiuseppeChillemi
Here is a pretty complete overview of parse behaviour while matching any-string!s, any-word!s and any-path!s:

**Parsing any-string!s**

1. First thing that strikes me is that while parsing any any-string! value, you can match it with any any-string! that value could be transformed into but tag!! And tag! can't match even exactly same tag! itself!
>> string-parse "abc"
                 string url    tag    email  file
                 "abc"  abc    <abc>  abc    %abc   
string "abc"| true   true   false  true   true   
url    abc  | true   true   false  true   true   
tag    <abc>| true   true   false  true   true   
email  abc  | true   true   false  true   true   
file   %abc | true   true   false  true   true


2. If match and rule are of same case, /case refinement doesn't affect matching, i.e. any-string! is still matched by any-string! except tag!.
>> string-parse/case "abc"
                 string url    tag    email  file
                 "abc"  abc    <abc>  abc    %abc   
string "abc"| true   true   false  true   true   
url    abc  | true   true   false  true   true   
tag    <abc>| true   true   false  true   true   
email  abc  | true   true   false  true   true   
file   %abc | true   true   false  true   true


3. Neither is the result affected by using quote in rule.
>> string-parse/quote "abc"
                 string url    tag    email  file
                 "abc"  abc    <abc>  abc    %abc   
string "abc"| true   true   false  true   true   
url    abc  | true   true   false  true   true   
tag    <abc>| true   true   false  true   true   
email  abc  | true   true   false  true   true   
file   %abc | true   true   false  true   true

4. Nor by changing case.
>> string-parse/upper "abc"
                 string url    tag    email  file
                 "ABC"  ABC    <ABC>  ABC    %ABC   
string "abc"| true   true   false  true   true   
url    abc  | true   true   false  true   true   
tag    <abc>| true   true   false  true   true   
email  abc  | true   true   false  true   true   
file   %abc | true   true   false  true   true


5. When any-string! is in block and parsing case-insensitively, all any-string! rules match it, even tag!, independent of quote and differing case.
>> string-parse/block "abc"
                 string url    tag    email  file
                 "abc"  abc    <abc>  abc    %abc   
string "abc"| true   true   true   true   true   
url    abc  | true   true   true   true   true   
tag    <abc>| true   true   true   true   true   
email  abc  | true   true   true   true   true   
file   %abc | true   true   true   true   true


6. With /case, any differences in case between value and rule result in failure, in both string-parsing and block-parsing.
>> string-parse/upper/block/case "abc"
                 string url    tag    email  file
                 "ABC"  ABC    <ABC>  ABC    %ABC   
string "abc"| false  false  false  false  false  
url    abc  | false  false  false  false  false  
tag    <abc>| false  false  false  false  false  
email  abc  | false  false  false  false  false  
file   %abc | false  false  false  false  false


7. When block-parsing case-sensitively value is strictly matched by rule.
>> string-parse/block/case "abc"
                 string url    tag    email  file
                 "abc"  abc    <abc>  abc    %abc   
string "abc"| true   false  false  false  false  
url    abc  | false  true   false  false  false  
tag    <abc>| false  false  true   false  false  
email  abc  | false  false  false  true   false  
file   %abc | false  false  false  false  true
GiuseppeChillemi
11:38@toomasv This is GREAT ! It should be added top the wiki parse chapter
hiiamboris
11:54Great research @toomasv :+1: Can you compare that to R2 and highlight the differences? To be sure that when we deviate from it, we do it intentionally.
11:56The first thing that looks like a bug is separatist tag!
toomasv
11:56**Parsing any-word!s**

1. In simple block-parsing lit-word! matches corresponding word! and lit-word!, but not set-word! or get-word! values. (word!, set-word! and get-word! are keywords in parse and cannot be used for matching without quote.)
>> word-parse 'abc
           'abc   
abc   | true   
'abc  | true   
abc:  | false  
:abc  | false


2. Same with /case.
>> word-parse/case 'abc
           'abc   
abc   | true   
'abc  | true   
abc:  | false  
:abc  | false


3. lit-word! doesn't match anything if case differs.
>> word-parse/upper 'abc
           'ABC   
abc   | false  
'abc  | false  
abc:  | false  
:abc  | false


4. With quote without /case all rules are matching except that lit-word! doesn't still match get-word! and set-word!.
>> word-parse/quote 'abc
           abc    'abc   abc:   :abc   
abc   | true   true   true   true   
'abc  | true   true   true   true   
abc:  | true   false  true   true   
:abc  | true   false  true   true


5. With quote and /case when cases match each type matches strictly its' own type + lit-word! matches also word!.
>> word-parse/quote/case 'abc
           abc    'abc   abc:   :abc   
abc   | true   true   false  false  
'abc  | false  true   false  false  
abc:  | false  false  true   false  
:abc  | false  false  false  true


6. With quote and /case but differing cases lit-word! doesn't match anything but other any-word! types match all other types.
>> word-parse/quote/upper 'abc
           ABC    'ABC   ABC:   :ABC   
abc   | true   false  true   true   
'abc  | true   false  true   true   
abc:  | true   false  true   true   
:abc  | true   false  true   true


7. With /case and differing cases nothing matches.
>> word-parse/quote/upper/case 'abc
           ABC    'ABC   ABC:   :ABC   
abc   | false  false  false  false  
'abc  | false  false  false  false  
abc:  | false  false  false  false  
:abc  | false  false  false  false

12:51**Parsing any-path!**

1. any-path! are matched strictly. It is true also when using quote and when cases differ but /case isn't used.
>> path-parse 'a/b/c
           a/b/c  'a/b/c a/b/c: :a/b/c 
a/b/c | true   false  false  false  
'a/b/c| false  true   false  false  
a/b/c:| false  false  true   false  
:a/b/c| false  false  false  true


2. With /case differing cases don't match.
>> path-parse/upper/case 'a/b/c
           A/B/C  'A/B/C A/B/C: :A/B/C 
a/b/c | false  false  false  false  
'a/b/c| false  false  false  false  
a/b/c:| false  false  false  false  
:a/b/c| false  false  false  false
13:30@hiiamboris I couldn't run my script in R2 because of too many discrepancies. But I tried manually few things.

tag! behaves same
>> parse <tag> [<tag>]
== false

In general string-parsing is similar to Red in R2 and parsing strings in block is strict (differently from Red), but some things in word- and path-parsing didn't make any sense for me :(. E.g.
>> parse [:a/b/c][quote :a/b/c]
== false
>> parse [a/b/c:][quote a/b/c:]
== false
>> parse [a:][quote a:]
== false
>> parse [:a][quote :a]
== false

But in Red:
>> parse [:a/b/c][quote :a/b/c]
== true
>> parse [a/b/c:][quote a/b/c:]
== true
>> parse [a:][quote a:]
== true
>> parse [:a][quote :a]
== true
hiiamboris
14:21Could you add a link to your experiments to one of parse-related tickets?
toomasv
14:25OK, added to #4101
hiiamboris
14:30:+1:
toomasv
14:43[Used funcs](https://gist.github.com/toomasv/dbee79a944fd12eee53a8353a1ce5472)
endo64
15:31Great research @toomasv !
toomasv
15:47Thanks, @endo64 !
tag! quirk is probably connected to the fact that tags are usually parsed not separately but in the text:
>> parse "<tag>" [<tag>]
== true
>> parse "<tag><abc>" [<tag><abc>]
== true
>> parse/case "<tag>" [<tag>]
== true
>> parse/case "<tag>" [quote <tag>]
== true
>> parse/case "<tag>" [<Tag>]
== false
>> parse "<tag>" ["tag"]
== false
>> parse "<tag>" ["<tag>"]
== true
>> parse [<tag> <abc>] ["tag" "abc"]
== true
>> parse [<tag><abc>] ["tag" "abc"]
== true
>> parse [<tag><abc>] [<tag> <abc>]
== true
>> parse "<tag><abc>" [<tag> <abc>]
== true
hiiamboris
16:03Ah! So is treated as "tag" and parse checks against "" and there's no match
16:07In other words, parse [..] is meant to parse the contents between < .. > rather than match it literally. Which makes sense.
toomasv
hiiamboris
16:12Then apart from known word-parsing bugs, I don't see any :) Good. We already have quite a collection of parse-related tickets...
toomasv
16:19Match from inside tag is still tag:
>> parse <tag source="Neverland"> ["tag " "source=" {"} copy src to {"} skip] src
== <Neverland>
hiiamboris
16:20Interesting
toomasv
16:20
>> parse <tag source="Neverland"> ["tag " "source=" copy src thru end] src
== <"Neverland">
LFReD_twitter
19:01so we using 'append' to concatenate strings instead of join now?
toomasv
19:14There is no (official) join
>> ? join
     rejoin          function!     Reduces and joins a block of values.
endo64
19:18Also remember that append modifies it series argument while join (in Rebol) returns a copy.
LFReD_twitter
19:28yeah, append is wrong. sooo we need to put two strings into a block and rejoin them?
19:29
n: "one" p: "two" q: rejoin [n p]
19:30that's it?
endo64
19:33Yes, or append copy n p.
LFReD_twitter
19:34What are the odds of joining two strings using the + operator like javascript?
19:35"one" + "two"
19:35Seems very Redbol way of doing it.
toomasv
20:24@LFReD_twitter Well, you can also rejoin strings directly:
>> rejoin ["one" space "two"]
== "one two"
20:32
context [+: make op! func [a b] [rejoin [a space b]] set 'join func [b][do bind b self]]
join ["one" + "two" + "three"]
;== "one two three"

context [+: " " set 'join func [b][rejoin bind b self]]
join ["one" + "two" + "three"]
;== "one two three"
LFReD_twitter
20:42txt: "one" + "two" <- I'll have one of these please :)
hiiamboris
20:48Overriding + globally won't get you anywhere, but why not use ~ for joining (like in D), or ++
LFReD_twitter
21:12Works ok in javascript
1 + 1 -> 2
"one" + 1 -> "one1"
var txt = "two"
21:13txt + 1 "two1"
21:14"this" + "that" -> "thisthat"
21:16I suppose it could impact math functions if everytime it comes across the + operator the function needs to determine whether is a string, integer etc
21:19Of course, could just skip the whole thing and use join :)
hiiamboris
21:28add (which is +) is an action! so it is dispatched on datatype basis. any-string! could support it, if we had a strong use case ;)
I just mean don't do +: something yourself in Red (globally) or it'll likely crash ☻
endo64
21:42+ is an op! and works on scalar! values only (+vector! which is a special case), it's a design choice and very unlikely to change.
"javascript supports" is not a good argument.
And I would never want "one" + 1 -> "one1" :)

LFReD_twitter
01:20@ne1uno is a bot
ne1uno
01:21you're sure enough to spam about it?
LFReD_twitter
01:23 well, that or a very active lurker :)
01:23my apologies if it's the latter.
ne1uno
01:24sure, we'll still go with if
LFReD_twitter
01:26I just noticed that you read every post within seconds it seems.. day or night.
ne1uno
01:28irccloud. what do you have against bots? 90% of gitter is lurkers or bots
01:28scrollup
greggirwin
20:01@toomasv great stuff. Glad it's not going to be lost to time.
20:02:point_up: [November 23, 2019 12:34 PM](https://gitter.im/red/help?at=5dd989abd2c92c2275e34a86) Zero. Red walks a fine line WRT flexibility. This is one we won't cross.
toomasv
20:39But why not try some other symbol, e.g.
&: make op! function [a [any-string!] b [any-string! block!]][
   case [ any-string? b [rejoin [a " " b]] 
                block? b [o: copy a foreach e b [o: rejoin [o " " e]]]
]]

>> "one" & "two" & "three"
== "one two three"
>> <one> & ["two" "=" {"three"}]
== <one two = "three">
>> %file?q= & [The title]
== %file?q=%20The%20title
GaryMiller
21:18I agree! If + interferes too much with existing semantics & was used as the string concatenation character by Visual Basic perhaps the most beloved of all programming languages until Microsoft tried to pound a square peg in a round hole and make force it into VB.Net Many other higher priced Basic dialects came along and tried to take it's place but none had the following or third party market size that VB did. Right now I just counted the number of rejoin strings in my Red program with Notepad++ at 309
So I'd have saved typing 1,527 characters with & even more with the [] eliminated. The ones that kills me a bit more is copy though. I searched on ": copy" for assignments and got 21,668 in my same program so I would have saved typing around 68,000 keystrokes so far if assignment was doen with a '=' like most other languages but we've got to take the good with the bad! It's not all gloom and dom though because in more cases I could copy and paste the code section and just change the parts that need changing. I'm sure that it slows down the lexing a bit though but with the new Lex branch being 30 times faster, that will keep me humming along for quite some time.

CD: lev ShortestDist UserInput/text "Yes, I'm still here. What were we talking about again?"
if CD < ShortestDist [ShortestDist: CD
if (AI/It <> "Unknown") [AIResponse: copy rejoin ["I thought we were talking about " AI/It "."]]
if (AI/They <> "Unknown") [AIResponse: copy rejoin ["I thought we were talking about " AI/They "."]]
if (AI/CurrentTopic <> "Unknown") [AIResponse: copy rejoin ["I thought we were talking about " AI/CurrentTopic "."]]
AI/Memories: []]

greggirwin
04:29As someone who loved VB more than most, I'm not terribly concerned about saving keystrokes. & is one of the few ASCII characters not in use by Red right now, and we need to deeply consider where it will provide the most value.
04:31@GaryMiller that is a *lot* of copy statements. If you're doing copy rejoin that many times, why not just write your own simple shortcut for it?

This is also part of the format design discussion.
toomasv
05:13I meant this not as standard op! but as a drop-in into your project if you are going to do lot of rejoins. :)
greggirwin
06:22:+1:
Oldes
06:28@GaryMiller There is no need to use copy rejoin, because rejoin makes its own copy.
06:28
>> a: "aaa" b: "bbb" c: rejoin [a b]
== "aaabbb"
>> a
== "aaa"
>> b
== "bbb"
>> append a "a"
== "aaaa"
>> c
== "aaabbb"
06:29
>> source rejoin
rejoin: func ["Reduces and joins a block of values." 
    block [block!] "Values to reduce and join"
][
    if empty? block: reduce block [return block] 
    append either series? first block [copy first block] [
        form first block
    ] next block
]
06:32Btw.. Rebol3 introduced ajoin native to avoid the use of slower rejoin mezzanine:
>> a: "aa" ajoin [a 2]
== "aa2"
>> a
== "aa"
>> source ajoin
ajoin: make native! [[
    {Reduces and joins a block of values into a new string.}
    block [block!]
]]
GaryMiller
10:42Thanks for the good tips!

nd9600
13:30I can't seem to read a specific URL, it fails with Access Error: invalid UTF-8 encoding: #{8B746865}:
read http://www.iwritewordsgood.com/apl/patterns/apl007.htm
13:30it works ok in Rebol
13:31I can't see anything in the issues about it
13:31hopefully the page is just odd
13:40actually quite of those pages break it, like http://www.iwritewordsgood.com/apl/patterns/apl011.htm and http://www.iwritewordsgood.com/apl/patterns/apl014.htm, but _not_ http://www.iwritewordsgood.com/apl/patterns/apl012.htm
toomasv
14:00@nd9600 Crude hack:
clean-url: function [url][
    bin: read/binary url 
    while [error? err: try [str: to-string b: bin]][
        while [b: find b err/arg1][remove b err/arg1]
    ] str
]
clean-url http://www.iwritewordsgood.com/apl/patterns/apl014.htm
;== {<HTML>^/<HEAD>^/<TITLE>14 Indentifiable Neighborhood</TITLE>^/^/^/^/<link rel="stylesheet" href="../patternlanguag...
14:12Oops! remove b err/arg1 -> remove b
nd9600
14:15thanks
14:15do you have any idea what's wrong with the page, that it breaks read?
toomasv
14:21These encoding problems have been noted here somewhere earlier. Don't remember exactly.
Oldes
14:58@nd9600 problem is, that Red requires UTF-8 encoded content to be loaded as a string so far.. These pages probably contains some not valid chars. What is worst, they even don't specify encoding in the http header from server and also not specified in the header using meta tag. In these cases the encoding should be considered to be iso-8859-1
15:00Even Chrome does not display it correctly:
15:00[![image.png](https://files.gitter.im/red/help/xuMl/thumb/image.png)](https://files.gitter.im/red/help/xuMl/image.png)
nd9600
16:12Ah right
16:13I did notice a few different mistakes in the source when I was looking through it, that probably explains it
hiiamboris

GiuseppeChillemi
19:46Is there a way to create an object which has either set word elements and one or more blocks without a set word ?
19:49This:

my: make object! [a: 22 [hello]]


..does not work (and I know why...) but is there a way to retain an object which is not referenced from any set word ?
hiiamboris
20:07how are you going to access something that is not referenced anywhere? and what is the point?
GiuseppeChillemi
20:42In my FORDATA I use to map each column to an object word. I want to have extra data too but I face the risk of using a word that will be used as column as those names come from external databases tables and I can't establish what won't be used. To avoid any possibility of having a duplicate name I imagined I could use a block with no reference as container, something which remains after object creation. I could access using positioning words like first/last.
20:44Also a find object block! could be used if block could be stored with no reference but this notation has been removed.
20:45(Just my imagination....)
hiiamboris
20:47Well, object doesn't hold any data except a bunch words, so it's not gonna work. Make a hash! instead, put every object there: make hash! [object block object block ...] and fetch blocks as select/same/skip hash obj 2
GiuseppeChillemi
20:56@hiiamboris I will study this solution.
hiiamboris
21:00:+1:

greggirwin
00:35@GiuseppeChillemi just use a block, as you would a spec for an object. Not a drop-in replacement, depending on your needs of course. In the future spec-of *may* return the spec value, but that hasn't been decided yet.
GiuseppeChillemi
07:23I am trying to understand fully which difference I could have using a block in place of a dynamically created object to store values. Here are some I see

* both could be accessed using get and set paths;
* objects have (are) a context while blocks don't have it;
* both store and manage the data but objects could have only set words;
* objects automatically execute all "free" code;
* blocks can be extended and manipulated.

This is what I see from my minimal knowledge

Could you add other differences?
When do you suggest using one or another ?

Oldes
08:19I don't understand what is purpose of having object as a key?
08:22If you are going this way, you will be doing things very un-efficiently!
08:23The common use of _primary index_ in databases is there by purpose.
hiiamboris
09:03@Oldes object's hashkey is it's memory address, so it should be more efficiently looked up than any other type
GiuseppeChillemi
09:05@hiiamboris 😮
21:26Just a note: I have a function that should receive at least 8 parameters. When they become so numerous everything starts to be messy ! It is better to put them in a block with just a key before them.

I would pass parameters via

myfunc reduce ['paramater-name value]

and then access them via paths. I fear having duplicated words in blocks as a reduced block could have one of his words reduced to the same name of a parameter key. Is there already a tecnique to manager function parameters in this way and avoid this danger ? I remember some post of Gabriele Santilli regarding this topic.

hiiamboris
10:36looks like you're fighting against the language ;)
Oldes
11:19@GiuseppeChillemi I would think that function which requires 8 and more parameters is bad designed function in any language.
hiiamboris
14:40Interesting. I didn't know objects are ordered:
>> (object [x: y: 1]) = object [y: x: 1]
== false
Oldes
15:07Because if something was not changed, object internally holds block of keys and block of values. And the order is static.
rebolek
15:37@hiiamboris this is an implementation detail and may change in the future.
GiuseppeChillemi
20:12@Oldes I think it isn't but I have to provide options for alternative words other than default one and eventually provide upto 4 conversion function.
20:13Add the 3 static args and we are to 9
20:14I am thinking to pass the conversion functions in a block with a key before them. Maybe I'll be able to reduce to 4 or or 5.
endo64
21:43@GiuseppeChillemi You can reference a value in a block that is used to create the object, from outside:

> Is there a way to create an object which has either set word elements and one or more blocks without a set word ?
> my: make object! [a: 22 [hello]]

o: object head b: [a: "one" [append a random 9] [print a]]
c: third b
d: last b
do c
do d
probe o
;== make object! [
;    a: "one7"
;]

GiuseppeChillemi
22:03Not tried I am far from the REPL but I imagine external word value is set stored in the context but word is not visible.
22:04That's black magic!
22:57@endo64 Tried, so an object retains its original block data. You can access it as a block or as a object and value of the words is taken from the context.
23:00@endo64 I have a monster for you:

>> o: make object! bl: [a: 22 [print ["My value is: " a]]]
== make object! [
    a: 22
]
>> do bl/3
My value is:  22
>> bl/2: 33
== 33
>> probe bl
[a: 33 [print ["My value is: " a]]]
== [a: 33 [print ["My value is: " a]]]
>> do bl/3
My value is:  22
>>

23:02Lesson learned!
23:07Experimenting:
23:10
>> f: func sp: [arg] bd: [b: 22 print ["Arg is: " arg "B is: " b]]
== func [arg][b: 22 print ["Arg is: " arg "B is: " b]]
>> f 33
Arg is:  33 B is:  22
>> probe sp
[arg]
== [arg]

>> probe bd
[b: 22 print ["Arg is: " arg "B is: " b]]
== [b: 22 print ["Arg is: " arg "B is: " b]]

>> sp/1
== arg
>> sp/1: 33
== 33
>> sp
== [33]
>> f 44
Arg is:  44 B is:  22
>> bd/b: 55
== 55
>> f 44
Arg is:  44 B is:  22
>> bd/1: 55
== 55
>> f 44
Arg is:  44 B is:  22
>>


23:11Either function blocks and object blocks are detached from their bodies once created.

GiuseppeChillemi
07:58Which is the correct way to have a function in a block and have it usable using a path ?

I have tried everything and only reduction of the block worked:

>> f: func [a][print [a "Is the value"]]
== func [a][print [a "Is the value"]]
>> z: ['fu :f]
== ['fu :f]
>> do z/2 22
== 22
>> z/2
== :f
>> do reduce z/2 22
== 22
>> z2: reduce z
== [fu func [a][print [a "Is the value"]]]
>> do z2/2 22
22 Is the value
>> do z2/fu 22
22 Is the value


Is there a way to have it working using a path notation ?
greggirwin
08:04
>> f: func [a][print [a "Is the value"]]
== func [a][print [a "Is the value"]]
>> z: reduce ['fu :f]
== [fu func [a][print [a "Is the value"]]]
>> z/fu 123
123 Is the value
GiuseppeChillemi
08:25@greggirwin yes, I had already found it. I was asking if there is a way to do it without reducing the block first, using a path. The path should reduce the accessed element.
08:58@hiiamboris @greggirwin I remember a discussion where Hiiamboris were against having a path autoreducing selected elements if used in a path but can't reproduce that working.
hiiamboris
10:03It is accessible via paths after you've reduced it. And your objects do NOT hold any extra blocks. Your object spec does.
GiuseppeChillemi
10:54@hiiamboris In my mental representation spec block once reduced creates a context specific for that block. Still not have understood if object is equivalent to context.
10:56@hiiamboris also, I remember clearly a discussion where using a number as last element in a path let that element be reduced. Is it just my imagination?
hiiamboris
11:19no, it was about z/2 123 in the above snippet
Rebol2Red
11:41In REBOL i can load an image inside the source like this:
REBOL []

r:  load to-binary decompress   64#{
    eJzt1z0WwiAMAODoc1Wu0OfkOVycvIOncOZoHTwQk2sMBAehL8mzqTqYFlH6Pegj
    2J/j+b6FElcqByonKhcqK9iU9kjHbzsurxHLDjFylTf6Mo4j1bkFyw6IXOUtN9HH
    vu2qi/UwoBZpCKpBcDDBxyTwMZCChyEBquH8iSanK2iGh5NMyp3AfPMccb4x5QIM
    ufAxkECfQwB9Dn0MHQ1q3t3WfB3xb75joGvqTUmjaEiEVrUG8rJqGpufqd4jPmGQ
    iXg+1FHeUDSmOUzt2SxonHI6FX/zW6bP4luGL/iiSf0fajFTb4iymVjlyxnLPGth
    M/VBaLapD2aK6S6AvZm44vSmDCcbVFJqNk5rnh/sPYwSJmN5J7K8Wz0AAI/VC/YN
    AAA=
    }
view layout [image r]

Can i directly load or convert the compressed data in Red somehow?
hiiamboris
11:51Compress it using Red's compress, and it should work ;)
Rebol2Red
11:54@hiiamboris I do'nt get this. Can you explain how to do this.
hiiamboris
12:01On a second thought, you don't need compress here..
i: draw 100x100 [line-width 10 pen red circle 50x50 30 30]
bin: save/as #{} i 'png
? (load/as bin 'png)
Rebol2Red
12:06@hiiamboris I do not understand how i can use this with the given data of the image in my example of Rebol. How can i draw the compressed image?
hiiamboris
12:07Did you try my snippet?
Rebol2Red
12:08Yep, but i do'nt see a picture of a playing card ;)
hiiamboris
12:09Well, assign i to a picture of a playing card and repeat :)
12:09Your data is just from R2, and not in a format Red understands.
Rebol2Red
12:25I can load the picture in REBOL and than write it to a file like this:
REBOL []
im:  load to-binary decompress   64#{
    eJzt1z0WwiAMAODoc1Wu0OfkOVycvIOncOZoHTwQk2sMBAehL8mzqTqYFlH6Pegj
    2J/j+b6FElcqByonKhcqK9iU9kjHbzsurxHLDjFylTf6Mo4j1bkFyw6IXOUtN9HH
    vu2qi/UwoBZpCKpBcDDBxyTwMZCChyEBquH8iSanK2iGh5NMyp3AfPMccb4x5QIM
    ufAxkECfQwB9Dn0MHQ1q3t3WfB3xb75joGvqTUmjaEiEVrUG8rJqGpufqd4jPmGQ
    iXg+1FHeUDSmOUzt2SxonHI6FX/zW6bP4luGL/iiSf0fajFTb4iymVjlyxnLPGth
    M/VBaLapD2aK6S6AvZm44vSmDCcbVFJqNk5rnh/sPYwSJmN5J7K8Wz0AAI/VC/YN
    AAA=
    }
write %clubace.red im

After doing this i put a header inside the clubace.red file. Give the data a name and then load this data to use it in a view.
The problem is the size of this data (+/- 41kb). Way to big to do this for all 54 cards, so i need to use only the compressed data in the Red file.
hiiamboris
12:31In my snippet you set bin to compressed data. Inline bin into your code. PNG can't be big. It's one of the most efficient image storage formats.
Rebol2Red
12:32@hiiamboris Wait a minute. I can give this data a name and than use compress in Red and use this data.
I now have a way to do what i need to do. Thank you very much!
hiiamboris
cloutiy
15:39I'd like to get some opinions on the best approach on something.

I have a text file with simple "markup" (see below for example). I purposefully tried to keep the structure similar to a Red program. Anything that starts with a @ has an equivalent function (I preprocess the string prior to load to replace the @ with .). The intention was 1) load the file as a block, then 2) reduce to transform the text within blocks (ex: inserting HTML or LateX tags, depending on intended output.)

The issue is loading as a block makes everything either a block or a word, and things like punctuation ("." or "," at the end of a word), and most english punctuation are not valid Red words, and so give error on load.

I realize using PARSE to parse the file as a string would work. In fact I initially tried modifying the HTML parser example on the website to suit my needs - and thus get as a result an EST (Executable Syntax Tree ;) operating on blocks of strings rather than blocks of words. But I just can't get the nested things to collect properly (@b[bold text @i[bold italic text.]])...Which is why, after much struggle, thought maybe a "simpler" approach would be to just load as a block, and doing so, I would get blocks and nested blocks for free.

But english punctuation is now the thorn in my side. Frustration is setting in. I'm not looking for anyone to solve for me. Just consulting to see what is the best approach.

doc: {
@chapter    [The Firefly House]
@toc-entry  [Fireflies]

    There was once, a grey goose with @i[italic text @b[bold italic text]] and regular text. -- Author

Now another paragraph.

    A tab before text indicates this is a quote.

Now a normal* paragraph. An asterisk at end of word means there's a footnote.

@footnote [
    What is @i[normal] is @b[quite @i[subjective]] for all intents and purposes.]}
hiiamboris
16:38You could use parse to identify where your formatting markers are, and where is the plain text, then wrap all plain text into quotes and load it.
cloutiy
16:48@hiiamboris Yes I suppose that could work. Essentially anything before any @ and ] and after any [ and ] would be "text" and should be a string. I'll give that a try.
GiuseppeChillemi
21:20So here is another difference between REBOL and RED:

REBOL

>> a: make object! [b: func [arg] [print [arg " I am the arg!"]]]
>> a/b 2
2  I am the arg!
>> bl: ['ff :a/b]
== ['ff :a/b]
>> c: reduce bl 33
** Script Error: b is missing its arg argument
** Where: halt-view
** Near: :a/b
>>


RED

>> a: make object! [b: func [arg] [print [arg " I am the arg!"]]]
== make object! [
    b: func [arg][print [arg " I am the arg!"]]
]
>> a/b  2
2  I am the arg!
>> bl: ['ff :a/b]
== ['ff :a/b]
>> c: reduce bl
== [ff func [arg][print [arg " I am the arg!"]]]
>> c/ff 123
123  I am the arg!


What has changed ? Why Rebol is not able to manage it as Red does ?
hiiamboris
21:28:a/b is not a get-path in R2. It's a normal path with a get-word.
GiuseppeChillemi
21:32@hiiamboris So how it could work in Rebol2 ? I ask becouse I am creating a code which must run in both worlds.
cloutiy
21:35@hiiamboris Just wanted to say thanks. After some fiddling around with the rules I'm getting exactly what I was looking for.
hiiamboris
21:35You're welcome ☺
21:36@GiuseppeChillemi try get 'a/b
GiuseppeChillemi
21:41@hiiamboris Tried:

>> bl: ['ff get 'a/b]
== ['ff get 'a/b]
>> c: reduce bl
** Script Error: get expected word argument of type: any-word object none
** Near: get 'a/b


No success
hiiamboris
21:44get in a 'b ?
GiuseppeChillemi
21:47@hiiamboris: I am near to write a terrible thing to say to another man:

>> bl: ['ff get in a 'b]
== ['ff get in a 'b]
>> c: reduce bl
== [ff func [arg][print [arg " I am the arg!"]]]
>> c/ff 1
1  I am the arg!


I love you !
21:48Thanks, you have unblocked me.
hiiamboris
GiuseppeChillemi
22:20I am near to complete complete my FORDATA v2 with auto conversion: now I can pass a block of functions through the interface ed execute it on block of data. My skill in dynamic coding increased! Thanks to everyone.

Rebol2Red
10:35@hiiamboris Can you please explain how your code works
i: draw 100x100 [line-width 10 pen red circle 50x50 30 30]
bin: save/as #{} i 'png
? (load/as bin 'png)

I can do this:
view [image i]

or
save %test.png i

but i do not understand your code
hiiamboris
10:37Okay, which part you don't understand?
Rebol2Red
10:37Why is a view executed without using view?
hiiamboris
10:39? executes View when it it is given an image:
>> ?? ?
?: 
func [{Displays information about functions, values, objects, and datatypes.} 
    'word [any-type!]
][
    print help-string :word]
>> ?? help-string
....
                image? :value [
                    either all [in system 'view :system/view] [view [image value]] [
                        _print/fit form-value value
                    ]
                ]
10:39And (load..) expression returns the image
Rebol2Red
10:40Ok, but if i do

help ?

i get nothing about an image?!
hiiamboris
10:40? is a shortcut for help-string
10:41But I guess this info just didn't fit into the docstring ;)
Rebol2Red
10:41Aha, where did you find this?
hiiamboris
10:41I think I found it by accident ;)
10:42But it's a pretty convenient shortcut
Rebol2Red
10:43Are there more nice things you found out by accident? :)
hiiamboris
10:44Perhaps, but I don't recall right now
Rebol2Red
10:46Well, now it is a kind of documented. I think there is good use for it. Keep on "accidenting" :)
12:17When i compile a program with this statement: red.exe -r -t Windows test.red
An acquaintance which does not has Red installed says the resulting
program test.exe is asking to install some sort of a runtime.
He doesn't say what it was asking so i do not believe him.

btw. He programs in c sharp for his work and he told me once Red does not has .net functionality so it can't be good. I think he is to stubborn to recognize something good.

I can not verify so could this be true?
hiiamboris
12:45I have no idea how does one verify if something is "good" or not :D

But let me say this. When I encounter a DotNet program on the web, I just keep searching for an alternative. Partly because DotNet programs usually require a *latest* version of it, and that version usually either fails with an error during installation, or just quits without any message, or says that I need to upgrade from W7 to W10, buy more RAM, and slow my PC three times so they at Microsoft will be happy ;) Not to mention that it requires me to download and install ~500-700MB of bloatware. So I have not the slightest idea what part DotNet is "good" ;)

The idea of DotNet wasn't totally bad - they wanted Windows programs once written to run on all versions of Windows, but they approached complexity with more complexity, which is "good" in terms of providing more jobs, but not at all "good" at providing reliable, portable and easy to write software.

So, put shortly, your acquaintance was obviously brainwashed by the money Microsoft directs into "education".
12:49As for runtime, compiled Red programs do not install any runtime. Perhaps he downloaded Red and Red tried to install a runtime, but he mixed it all up.
ne1uno
12:55include the dll/so?
Oldes
13:09@Rebol2Red you are missing libRedRT.dll file... this file contains the Red runtime, so when you compile your app, you don't have to compile full Red too.
13:12Although red.exe -r -t Windows test.red should not require this dll.
Rebol2Red
13:18@hiiamboris I meant to verify if the program asks for a runtime but you figured that out. If i need a functionallity out of .net i can program this with a few lines of code and Red already has the most common statements of .net aboard. I can easily do without .net.

"So, put shortly, your acquaintance was obviously brainwashed by the money Microsoft directs into "education"." Exactly!

@Oldes So to be on the save side i have to give my acquaintance libRedRT.dll and let him place it at the same location of test.exe? (maybe the runtime is needed by some statements)
hiiamboris
13:23You sure you compiled it with -r? It looks like you did without it, or with -c
Rebol2Red
13:54@hiiamboris Asking me?
hiiamboris
13:55Yeah
Rebol2Red
15:43I am not **absolutely** sure but inside the compilation bat file it is. I usually use a bat file to compile. Btw. When i open the resulting exe file and watch with taskmanager i do not see it needs something. Is there a way to determine if the exe file is compiled with -r?
hiiamboris
16:15Well, simplest way to tell is by it's size. If it's > 1MB then it was -r, if <100kB then not
Rebol2Red
16:22It is 1012 Kb (exactly 1.036.288 bytes) so i assume it is compiled with -r. Then it does not use libRedRT.dll?
hiiamboris
16:25That's right.

LFReD
08:35I knew this once.

red: ["hello"]
blue: ["world"]
blk: [red blue]

foreach col blk [print col]

Where the output is 
"hello" 
"world"

?
GalenIvanov
09:26@LFReD
09:26
>> foreach col reduce blk [print col]
hello
world
>>
09:28
>> foreach col blk [print do col]
hello
world
>>
LFReD
09:46@GalenIvanov cool, thanks!
GalenIvanov
09:48@LFReD I'm glad it works for you!
greggirwin
10:04For simple lookups, prefer get over do. Safer and more efficient.
dander
22:12@Rebol2Red there is an [experimental .net bridge](https://github.com/red/code/tree/master/Library/dotNET) to call into .NET from Red, and it is possible to [load and call Red from .NET through the libRedRT.dll directly](https://gist.github.com/dander/a02c8837e12e70ec24396da3a18b1168). They are both fairly bare-bones interfaces though
22:18Speaking as a dotnet developer myself, I think they are going in a somewhat positive direction. They now support building a self-contained executable with the runtime built in. But hello-world comes out to something like 40 MB after being trimmed down. If you start using the various APIs it rapidly grows. I wish I could be working in Red instead...
GiuseppeChillemi
22:27Is there any difference between a context created with context and words context? I ask because words could be bound to a different context, so it could be expanded, while context created with context [] returns an error for operations like append
dander
22:38@GiuseppeChillemi context is just a simple wrapper that produces an object!, and I don't think there is any difference. Maybe the error is because only the system context can be expanded?
>> ?? context
context: 
func ["Makes a new object from an evaluated spec" 
    spec [block!]
][
    make object! spec]
>> ?? object
object: 
func ["Makes a new object from an evaluated spec" 
    spec [block!]
][
    make object! spec]
GiuseppeChillemi
22:52@dander

>> a: context [fn: does [print c]]
== make object! [
    fn: func [][print c]
]
>> c: 33
== 33
>> bind 'c a
== c
>> a/fn
33


I have checked and c is not bound to a

>> probe c
33
== 33
>>

22:53It should return an error...
hiiamboris
22:54Only system/words object can be extended, and it's done internally. No interface for that.
dander
22:56in this
a: context [fn: does [print c]]

c is bound to the global context (same as print). If you want it bound to a's context, it needs to have a set-word! in there
22:56
a: context [c: none fn: does [print c]]
GiuseppeChillemi
22:57@hiiamboris
So bind is not enlarging the a context but it returns no error
hiiamboris
22:58Bind returns the word unchanged if it cannot be bound to a given context.
GiuseppeChillemi
23:02@dander It is now clear, it can be done only upon creation. So, even a set in a function executed after function creation will be bound to system/words.

LFReD
01:19Ok @Oldes .. what do you think.?

data: [db1 %db1.txt db2 %db2.txt] 

foreach [dat path] data [
set to-word rejoin ['dat "-sv"] get 'singlev
	]
01:20it works, but the set and get doesn't seem right some how?
03:17In that piece of code, how can I pass the dat value to the get function 'singlev ?
03:18OR, now that I've created the db1-sv word, how can I set a function body with it that includes dat?
toomasv
04:41@LFReD Something like
db1: [1 2 3]
db2: ['a 'b 'c]
ata: [db1 %db1.txt db2 %db2.txt] 

singlev: func [x][print x]

foreach [dat path] data [
	new-func: to-word rejoin [dat "-sv"]
	set new-func :singlev
	do reduce [get new-func dat]
]

Can't really say without seeing singlev or where and how you want to use created funcs.
07:17Or may be:
data: [db1 %db1.txt db2 %db2.txt] 

singlev: [spec [/local x] body [x: none print x]]

foreach [dat path] data [
	new-func: to-word rejoin [dat "-sv"]
	body: copy singlev/body
	body/x: data/:dat
	set new-func func singlev/spec body 
]
db1-sv
; db1.txt
db2-sv
; db2.txt
LFReD
08:55@toomasv
Those work but I need to pass the name and the path to new-func so I can do a file save within the function. (clear as mud, right)

The goal:
- foreach [name path] of data, create a new function using name and append "-sv" to it. db1-sv

- copy an existing function eg: sv to the new db1-sv function

- at the same time, I need to pass the name and path arguments to the new function without ending up with this;
db1-sv "hello" "db1" "%db1.txt" as that really kills the buzz.
Oldes
08:57@LFReD I don't think... I don't know what you are doing... I would not do anything like this. polluting global name space with database names is not a good habit.
LFReD
08:59@Oldes Well, I can't think of a better way to do something like this

db1-sv "hello" "world"

db2-sv "goodbye" "cruel world"
08:59where each saves to a unique file
09:00It's about simplicity.
Oldes
09:00Again.. I don't understand you and don't see anything interesting in db1-sv "hello" "world"
LFReD
09:01the first part db1, is a hash! of triples.. sv adds a new triple to that. After adding it, it saves the hash! blk to a file that matches the path.
09:02Each name is a database, so you can load as many as you please, and interact between them.
09:03the sv part is one of eight CRUD operations.
09:04so.. two database db1 and db1 would create 16 crud functions.. yeah, some pollution there, but given the '-' in the function names, not a big deal
09:07When the script is first run, that data file is processed and, in this case, two hashed! blocks are created.

db1: make-hash []
db2: make-hash []

Oldes
09:08I would do it this way probably:
my-data: context [db1: db2: none]
load-dbs: function[ctx][
	foreach name keys-of ctx [
		file: rejoin [%databases/ name %.txt]
		print ["Loading DB from:" file]
		ctx/:name: either exists? file [load file][copy []]
	]
	ctx
]
load-dbs my-data
probe my-data

save-dbs: function[ctx][
	foreach name keys-of ctx [
		file: rejoin [%databases/ name %.txt]
		print ["Saving DB into:" file]
		save/all file ctx/:name
	]
]
LFReD
09:09But when I save the hash, I need to know the name and path
09:11also the path and the name could be different [db1 %somfile.txt]
09:14keys-of, now there's a new one!
Oldes
09:17You can extend it.. it is just an example.. you may use something like:
my-data: context [
	db1: object [file: %somewhere/db.txt data: none modified: none]
	db2: object [file: %elsewhere/db.txt data: none modified: none]
]

load-dbs: function[ctx][
	foreach name keys-of ctx [
		spec: ctx/:name
		print ["Loading DB from:" spec/file]
		spec/data: either exists? spec/file [
			spec/modified: modified? spec/file
			load spec/file
		][
			spec/modified: now
			copy []
		]
	]
	ctx
]
load-dbs my-data
09:18just not polluting global name space.
LFReD
09:29How is it any different? you still end up with db1 and db2 in the global namespace?
Oldes
09:30The difference is, that you don't end up with db1 in global, but only in the my-data
LFReD
09:30yeah, but I need to abstract that away for end users.. this isn't for Red gurus.
Oldes
09:31Sorry... that is your fight.. I have my own work to do.. good luck.
LFReD
09:31I have a version of this in PHP and javascript and they all work the same way.. 8 simple functions.
09:32and MAYBE a block of databases and paths, including MySQL
09:32 I appreciate your help.. but my question was 'is it possible to pass arguments to the new function using set?'
Oldes
09:33I don't understand your question.. maybe someone else will continue.
LFReD
09:36I'm going to go with the answer being 'no' and use a different tack.
09:39@Oldes for global namespace sake, once finished it could all be dropped into an object.

atomica/db1-sv "hey" "there"
atomica/db2-sofp "test"
09:40at least that's abstracted enough.
Oldes
09:41I really don't understand what do you mean with _pass arguments to the new function using **set**_
09:42But the above examples forced me to write this: https://github.com/red/REP/issues/58
LFReD
09:45
data: [db1 %db1.txt db2 %db2.txt] 

foreach [dat path] data [
set to-word rejoin ['dat "-sv"] get 'singlev
    ]


09:45but In that process I want to pass the dat and path arguments to the new db1-sv function (which is a copy of the body of 'singlev
09:46that new db1 function needs to have those two arguments
09:46I can't think of any other way to explain it.
09:47I don't even know that it's possible,.
Oldes
09:49You are probably doing something wrong when you even cannot explain it. Or at least to me. Sorry. Looks like you are over engineering it or you brain is modified by using PHP.
09:50And you also never showed us, what is singlev which you want to get
hiiamboris
09:50@LFReD https://github.com/red/red/wiki/[NOTES]-Closures does this help?
LFReD
09:52This is the current singlev

singlev: func [s1 p1][

	db: head db
	cleanit s1 p1
	if error?  try [return third find/skip db reduce [s1 p1] 3][return none]
]
09:54and that's what I want for the db1-sv function.. BUT i need to change the db: to match the db1 name (i don't need the path on this function but with others i do)
09:54currently db is a global namespace of a single block
Oldes
09:55
db-spec!: context [
	file: data: modified: none
	info: does [print ["INFO:" file "modified:" modified]]
]
my-data: context [
    db1: make db-spec! [file: %somewhere/db.txt]
    db2: make db-spec! [file: %elsewhere/db.txt]
]
load-dbs: function[ctx][
    foreach name keys-of ctx [
        spec: ctx/:name
        print ["Loading DB from:" spec/file]
        spec/data: either exists? spec/file [
            spec/modified: modified? spec/file
            load spec/file
        ][
            spec/modified: now
            copy []
        ]
    ]
    ctx
]
load-dbs my-data
my-data/db1/info
LFReD
10:00@hiiamboris yeah, something like that... need to play with it.
Oldes
10:00
with: function [obj body][do bind body obj]
with my-data/db2  [
	modified: 1-1-2003
	info
]
LFReD
10:04Life would be easy if i could somehow pass some arguments while set and get. But I'm fairly certain by adding the singlev function while I'm creating the new db1-sv function will work.
10:11Ok. one last question :)

data: [db1 %db1.txt db2 %db2.txt] 

foreach [dat path] data [

	set to-word rejoin ['dat "-sv"] {a function here}
]

10:11How do i add the code of the function once the dat-sv has been created?
10:12at least I can add my dat and path arguments to the code, or can i?
10:14In short, I want to create a new 'word by rejoining dat and "-sv", and then turn that word into function with some code.. I can't think of any other way to explain that.
10:15maybe set is the wrong way?
hiiamboris
10:19it's a very old experiment of mine, may be bugged:
Red []

extend-func: func [f arg1 /with arg2 /local vars spec protospec] [
	set [vars spec] reduce either with [ [arg1 arg2] ][ [[] arg1] ]
	probe func compose [
		(protospec: spec-of :f) (either find protospec /local [][/local]) (vars)
	]	compose [
		super!: does (reduce [copy body-of :f])
		(spec)
	]
]

f: function [/r1 /r2 /r3] [ prin "f " k: does [reduce [r1 r2 r3]] prin "super!!" k ]
probe :f

g: extend-func :f [ prin "^/g " prin ["<" super! ">"] ]
unset 'super!
h: extend-func/with :f [var][ prin "^/h " super! var: k prin ["(" var ")"] ]
unset 'super!

f/r1/r2
g/r1/r3
h/r2/r3

print :var
Oldes
10:23@LFReD
my-func: does [print "hello"]
set to-word rejoin ['dat "-sv"] :my-func
dat-sv
LFReD
10:25hehe ok.. but i need it to print 'dat instead of hello
10:25er dat rather
Oldes
10:26:point_up: [December 4, 2019 10:55 AM](https://gitter.im/red/help?at=5de7829f5ac7f22fb55b1ac2), but as you still want to have global namespace polluted with strange functions, than you must play with function body bindings, like :point_up: [December 4, 2019 5:41 AM](https://gitter.im/red/help?at=5de738ec46397c721c82292e)
LFReD
10:30im only polluting it for now.. as I mentioned, can drop the whole thing into an object once done.
10:30or paths of nested blocks, whatever
Oldes
10:34You probably don't understand, that when you write foreach [dat path] ..., the dat and path are local variables of the foreach context, which are destroyed when the cycle ends and so you cannot use it easily outside of the loop as a local args of function.
10:38@LFReD but if you really want this strange (not recommended by me) way:
foreach [dat path] data [
	dat-func: function [] compose [
		dat:  (to-lit-word dat)
		path: (path)
		print [dat mold path]
	]
	set to-word rejoin [dat "-sv"] :dat-func
]
db1-sv
LFReD
10:45I don't know what's so strange about it?
Oldes
10:47It is not optimal and bad structured code.
LFReD
10:47I don't want to have to create functions all the time.. I want a bot to do it for me dynamically
10:48why bad structure? at the end of the day i get the equivalent of `db1-sv: [dat][print dat]
Oldes
10:49I was writing _bots_ in Rebol years ago and never needed something like that.. Even bots like to live in own contexts.
LFReD
10:49it's ok if I write it out, but to make it dynamically is wrong?
Oldes
10:49db1-sv: [dat][print dat] is a nonsense.
LFReD
10:50it's just an example
Oldes
10:50I give up. This is the way I would choose :point_up: [December 4, 2019 10:55 AM](https://gitter.im/red/help?at=5de7829f5ac7f22fb55b1ac2)
LFReD
10:52:point_up: [December 4, 2019 2:34 AM](https://gitter.im/red/help?at=5de78bbfd64a052fb6b2c61d)

This works... I don't see what's wrong with it. Stick it in an object for namespace sake atomica/db1-sv
10:53Where I went wrong was with compose
10:53thanks!
GaryMiller
12:01Question - In my view program that emulates a chat window if my processing takes longer than a few seconds the program name caption at the top of the console window gets the string "(Not Responding)" appended to it but the program is still processing and that string gets removed when my program gives its next reply. I do not see this if my program replies quickly. It there a way to prevent the "(Not Responding)" from appearing? I wish to prevent users from thinking the application has locked up and keep them from exiting prematurely.
hiiamboris
12:25Do do-events/no-wait sometimes, like every second or so
LFReD
12:41@Oldes

data: [db1 %db1.txt db2 %db2.txt]

atomica: copy []

foreach [name path] data [

	funcname: to-word rejoin [name "-sv"]
	
	append atomica compose/deep[(funcname) [print rejoin [(to-string name) " and " (path)]]]
]
12:41do atomica/db1-sv
do atomica/db2-sv
12:41Not digging the 'do part
Oldes
12:48You have really strange coding patterns.
LFReD
12:53I'm a noob.
12:53If I was a coding expert, I wouldn't use Redbol HA!
12:54However, it does what I need.. and it's wrapped up in a nice namespace for you.
12:59The last computer programming course I took required me to color in little boxes on punch cards with a pencil.. one for each line, queue up behind 30 students, load my stack of cards into an IBM computer with a single line led output, and wait for it to crash because my pencil mark went outside the tiny box.
13:07
10 Print "Hello World"
20 GO TO 10

That little program meant coloring in 27 boxes. Circa 1977
Oldes
13:08You must be pretty old than... anyway.. it's good to remember that it is good to avoid using set and do functions if it's possible.
LFReD
13:09Yeah I don't like the do bit, but at least I have the name and path args at my disposal.
Oldes
13:10But I understand that using eval is common in PHP and JavaScript, so it explains your inclination.
13:10[![image.png](https://files.gitter.im/red/help/lMeJ/thumb/image.png)](https://files.gitter.im/red/help/lMeJ/image.png)
13:11https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
LFReD
13:11It's only bad if you don't have complete control of the code being EVAL
13:12I mean, everything is EVAL
13:18If someone arbitrary user can fire up do, then they can 'do anything.
13:45> But I understand that using eval is common in PHP and JavaScript, so it explains your inclination.

I know, PHP and Javascript suck.. not sure why the top 10 sites use Javascript on the front end, and Facebook, Yahoo, WordPress and Wikipedia use PHP on the backend. Weird.
rebolek
13:49JS and PHP are *good enough* technologies (IMO PHP is not even good enough, JS is light years ahead of PHP). And the history of technology teaches us that *good enough* is unfortunately almost more successful than *great*.
LFReD
15:47@Oldes I've tried every which way with the solutions you suggest, but keep hitting a wall. I know my suggestion works, but involves using 'do

Rather than trying to fix pieces of code, I'll lay out exactly what I'm trying to accomplish

I have blk called data: [db1 %db1.txt db2 %db2.txt]

I use the script below that either loads an existing db or creates one..
loadit: does [
	foreach [name path] data [
		either not exists? path [
			set :name to-hash []
		][
			either rebol [
				set :name load path]
			[
				set :name to-hash load path
			]
		]
	]
]


The result, in this case, are two blocks.. db1: make hash! [] and db2: make hash! []
15:50if they have loaded data, they're triples
db1: make hash! ["one" "two" "three"]
db2: make hash! ["three" "four" "five" "six" "seven" "eight"]
15:53Now, I want to be able to manipulate this data using CRUD functions, where the functions are made up of the name and the function.. in this case it would be db1-sv and db2-sv

the sv function...
singlev: func [s1 p1][

	db: head db
	cleanit s1 p1
	if error?  try [return third find/skip db reduce [s1 p1] 3][return none]
]

*this works perfectly fine if I only have one database named db*
15:57I need to replace the db in that function so it can access the existing db1 and db2 blocks in global space. This particular function takes two arguments.. the first and second values of the triples, and returns the third. At the end of the day, it should work something like this..

db1-sv "one" "two"
\>> "three"

db2-sv "six" "seven"
\>> "eight"
16:03The data block could be anything and is end user generated.
hiiamboris
16:20parse body-of :singlev rule: [any [change set word ['db | quote db:] (to type? word 'db2)| into rule | skip]] :)
Oldes
16:42@LFReD I've already sent you my solution, but again:
db-spec!: context [
	file: data: modified: none
	info: does [print ["INFO:" file "modified:" modified]]
	singlev: func [s1 p1][
	    ;cleanit s1 p1
	    if error? try [return third find/skip head data reduce [s1 p1] 3][return none]
	]
]
my-data: context [
    db1: make db-spec! [file: %somewhere/db.txt]
    db2: make db-spec! [file: %elsewhere/db.txt]
]
load-dbs: function[ctx][
    foreach name keys-of ctx [
        spec: ctx/:name
        print ["Loading DB from:" spec/file]
        spec/data: either exists? spec/file [
            spec/modified: modified? spec/file
            load spec/file
        ][
            spec/modified: now
            copy ["three" "four" "five" "six" "seven" "eight"] ;= using some default values here
        ]
    ]
    ctx
]
load-dbs my-data
my-data/db1/singlev "six" "seven"
16:48Or if you really want global functions:
db1-sv: :my-data/db1/singlev
db1-sv "six" "seven"
;== "eight"

GiuseppeChillemi
18:55@dander
> in this
>
> a: context [fn: does [print c]]
>

> c is bound to the global context (same as print). If you want it bound to a's context, it needs to have a set-word! in there

So I need a set-word with the same name, otherwhise it will be never bound to that context.
LFReD
22:57@Oldes Well Oldes, there's no malarkey in that code! I've never been a fan of OO coding, so just studying Redbol's way of doing things there. Thanks for your help and a special shout out to Joe Biden!

greggirwin
00:46@LFReD I fear you are making this waaaayyyyy too complicated. You say there are 8 general funcs needed. I'm guessing CRUD (that's 4), and CRUD for DBs themselves (the other 4, with RU being save/load). Is that correct?
LFReD
02:15@greggirwin Well, 2 are very common, but could be mezzed.
There's 2 that both create and update, and 3 for read, and 1 delete.
02:17The actual Atomica I worked on and used for years using PHP, MySQL and JS. I had some old experimental stuff for Rebol back in 2010ish
02:17The problem I'm having is Redbol syntax.
GaryMiller
02:20@hiiamboris Thanks for the do-events/no-wait it worked like a champ!
greggirwin
02:46@LFReD I ask because, if you can post what the funcs are, and what they need to do, we can offer much better suggestions for how to go about it.
LFReD
06:17@greggirwin https://gitter.im/AtomicaDB/community
06:23This will give you a gist of things.. HA!
https://gist.github.com/LFReD/af286d491d18052d55a4833478b006e0

check out the comment

Also this is really experimental and I've made some changes, so that gist is already long in the tooth, but gives you an idea.
greggirwin
06:26I think the answer here is simple @LFReD, but my 5s glance may miss something:

--> Pass the db as a param to funcs.
LFReD
06:47Yeah, that's an obvious one, but there's two goals .. As simple as possible and same functions work regardless of language and dbms

Right now, if you wanted the email all the contributors of Red
contribs: sofpandv "isa" "redcontributor"
foreach person contribs [print singlev person "email"

06:49Now that would be a single db, which is the most common scenario. so adding a third db argument would bloat it. BUT.. knock singlev to sv, and add the db to the function..

db-sv "bob" "email"

I could live with that.
07:02All i need is a function that can tell me the name of the function (which is the name of the db) so I know which db to update
07:03Guess what happens when you try this..
a: does [type? a]
07:05Once things start getting into objects and paths of blocks, then it loses the ability for a bot to use it
liangliangsun
11:32**parse T false, I do not know why , any one here, help meeeee**
'''
T: read %/D/Red/AA290119B00001_20190131100323.txt
== {T3p3 - NX35L7504 v2.0.0.2^-20190131^-100323^-152.051^-NX35-L7504^-NONE^-AA290119B00001^-^-^-P^-^/CheckLIB^-0.0^-0.0^-0.0^-P^-0.116277^/ApplyPower^-0.0^-0.0^-0.0^-P^-0.067513^/WaitForOS^-24.0^-99.0^-3.0^-P^-34.809894^/}

number: charset "1234567890"
letter: charset [#"a" - #"z" #"A" - #"Z"]
dash: charset "-_"
dott: charset dot
spacee: charset space
item-string: union union union union number letter dash dott spacee
rules: [start: some item-string some #"^-" finish: (print copy/part start finish) ]
line-rules: [ some [some rules #"^/" ] ]

parse T line-rules
'''
;;console output
T3p3 - NX35L7504 v2.0.0.2
20190131
100323
152.051
NX35-L7504
NONE
AA290119B00001
P
CheckLIB
0.0
0.0
0.0
P
== false

Rebol2Red
12:13@dander I'm interested in read-pattern.red but can not figure out how it works so can you give me an example how to use it please
(Say i want to find all files with 'print' in it)
Respectech
13:30Aaaaaaaaaaaaaaaaaaaa
Oldes
15:37@liangliangsun use any instead of some:
rules: [start: some item-string finish: (probe copy/part start finish) any #"^-"]

There is no ^- after -34.809894 value.
15:46Or better:
line-rules: [ collect any [collect some [keep some item-string any #"^-"] #"^/" ] ]
result: parse T line-rules

== [["T3p3 - NX35L7504 v2.0.0.2" "20190131" "100323" "152.051" "NX35-L7504" "NONE" "AA290119B00001" #"P"] ["CheckLIB...
15:54But above is not perfect, as you are missing the empty fields!
15:55The data looks like tsv (tab separated values).. I thing that there should be codec based on csv which would handle it without need to use parse.
15:56@rebolek why csv codec cannot be used?
16:15@liangliangsun what about this:
...
item: [s: any item-string f: keep (copy/part s f) [#"^-" | #"^/" break]]
item-line:  [ collect any item]
line-rules: [ collect any item-line ]
result: parse T line-rules
foreach line result [probe line]

["T3p3 - NX35L7504 v2.0.0.2" "20190131" "100323" "152.051" "NX35-L7504" "NONE" "AA290119B00001" "" "" "P" ""]
["CheckLIB" "0.0" "0.0" "0.0" "P" "0.116277"]
["ApplyPower" "0.0" "0.0" "0.0" "P" "0.067513"]
["WaitForOS" "24.0" "99.0" "3.0" "P" "34.809894"]
greggirwin
19:26@liangliangsun in this case it won't make a big difference here, except that getting all the union calls counted it a bit of work, but helper funcs are great. If you find yourself unioning bitsets a lot, you could do something like this:
bitset+: function [
	"Returns a bitset that is the union of all bitset! values in spec"
	spec [block!] "Bitset! specs or values (reduced)"
][
	result: make bitset! 1	; create an empty bitset to start
	foreach set! reduce spec [result: union result make bitset! set!]
	result
]

e.g.
>> item-string: bitset+ [number letter dash dott spacee "~`" [256 - 260]]
== make bitset! #{000000008006FFC07FFFFFE1FFFFFFE200000000000000000000000000000000F8}
dander
19:46@GiuseppeChillemi
> So I need a set-word with the same name, otherwhise it will be never bound to that context.

That seems right to me :+1:
LFReD
20:05Is it possible to dynamically create a function and associated 'word, and pass arguments to it in the creation process?
20:13I understand most would say "why?" as there's always other ways to do things, but that's not the question.
20:16One 'blue ocean' opportunity is using AI and semantics to write code dynamically.
20:1750 years from now, there will be no such thing as programmers. Mabye sooner :)
20:20And it won't have any issues like naming conventions, namespace conflicts...
20:21(taking the rest of this to chit-chat)
20:52Oops, I misspelled maybe above! Good thing our brains have built-in syntax correction or you would have no idea of what I meant... like a computer program.
greggirwin
20:52
>> do reduce [fn: func [a b][probe add a b] 1 2]
3
== 3
>> ? fn
USAGE:
     FN a b

DESCRIPTION: 
     FN is a function! value.

ARGUMENTS:
     a             
     b
LFReD
20:54cool.. i was reading about reduce in the red cods an hour ago and thought the answer must lie there somewhere.. thanks
20:54you know what red cods means, right?
20:57program languages have a very narrowly defined context.. ripe for AI correction.

GiuseppeChillemi
00:09@dander
> @GiuseppeChillemi
> > So I need a set-word with the same name, otherwhise it will be never bound to that context.
>
> That seems right to me :+1:
[Here](https://github.com/meijeru/red.specs-public/blob/master/specs.adoc#637-built-in-bind-function)
*For each word to be treated it will search for the presence of an equally spelled word in the given context, which is supplied in the form of a word (whose context will be used), or of an object, error or port value or a function. If an equally spelled word is found, the function bind will change the context of the treated word to that given context and will adapt the index of the word; otherwise, the word is left untouched.*

One more step done.
00:11I have a problem interpreting those chapters. I can't find a suitable meaning to the word **yield** I am learning just now.
liangliangsun
01:13@Oldes Thank you a lot, you have given me all what I need.
I have learn Red several weeks , about bitset+ function, is difficult for me to read it now, I will keep learning to figure it clear in my brain.
LFReD
11:07@greggirwin OK, a compromise

data:["db1" "%db1.txt" "db2" "%db2.txt" "db3" "%db3.txt"]

sv: func [sub pred][

	path: second data
	print [sub pred path]
]

sv2: func [sub pred db][
	
	path: second find data db
	print [sub pred db path]
]

if (length? data) > 2 [
	sv: :sv2
]

if there's only one DB and path in data...

sv "gregg" "fname"

if more than one..

sv "gregg" "fname" "db3"
11:10I'm ok with the extra db argument as 99% of the time there's a single db anyway.
18:35One issue I keep coming across..
Using the code above we add...
db1: ["one" "two" "three"]
 ```
And an updated sv2 function

sv2: func [sub pred db][

path: second find data db

return third find/skip db reduce [s1 p1] 3
]
Using this function call sv "one" "two" "db1"` In the return third/find line, I need the db variable to point to the db1 block

18:37I've tried converting db to 'word, then set it, set and get.. everything I can imagine, but no go.
18:38If I use the global db1 in the return line, it's fine. How do I convert the "db1" argument so it becomes the global db1, which is the db1 block?
addos
19:01Hi, when I set a value to a date, how do I see how I get to various components of the date? Like the day, time, month, year, etc?
toomasv
19:06@addos
>> d: now
== 6-Dec-2019/21:02:26+02:00
>> d/1
== 6-Dec-2019
>> d/2
== 2019
>> d/3
== 12

>> foreach refinement system/catalog/accessors/date! [print [pad mold to-set-word refinement 10 d/:refinement]]
date:      6-Dec-2019
year:      2019
month:     12
day:       6
zone:      2:00:00
time:      21:02:26
hour:      21
minute:    2
second:    26.0
weekday:   5
yearday:   340
timezone:  2:00:00
week:      49
isoweek:   49
julian:    340
greggirwin
19:28@addos also: https://doc.red-lang.org/en/datatypes/date.html
19:29And while help's formatting isn't great for this, you can use ? datatype! and see the accessors for types that have them.
19:33@LFReD I suggest you take some time to learn more Red fundamentals. Get a sense for idiomatic Red, use of datatypes, and then revisit Atomica once you have a firm grasp on things. e.g., if your data block, everything is a string, which is almost always a bad way to go about things in Red. You're fighting the language when you do that.
addos
19:46@greggirwin I tried ? date! and it shows me my value and the date
19:46but how do I access the components of the date?
19:48how do I get help to show me those accessors that you have listed in that html page you sent me to?
greggirwin
19:56Standard refinement syntax.
>> d: now
== 6-Dec-2019/12:55:59-07:00
>> d/date
== 6-Dec-2019
>> d/time
== 12:55:59
>> d/weekday
== 5
>> d/week
== 49
addos
19:58ok, how do I get help to tell me what refinements are available?
greggirwin
19:58Help (aka ?) shows you the existing values when given a datatype. So you can, for example, do help char! and see all predefined char! values. That's why it shows your date value, and why ? datatype! shows all the datatypes (with a bit of extra info).
addos
19:59yeah, but I am trying to figure out what refinements are date! has using help
19:59a date! has
greggirwin
19:59Did you try the example I posted?
addos
19:59yeah, I mean, i see that they work, but how do I know to use /week or /weekday or /time or /date
19:59how do I get a list of those using help
20:00? date! doesn't show me that
greggirwin
20:00That's what docs are for. Help is meant to be brief.
addos
greggirwin
20:04Here you go: :^)
datatype-help: func [type [datatype!]][
	browse rejoin [https://doc.red-lang.org/en/datatypes/ type %.html]
]
datatype-help date!
datatype-help integer!
datatype-help map!
addos
20:17that might be a nice inclusion. :)
20:25thanks @greggirwin
LFReD
20:33@ gregg :point_up: [December 6, 2019 11:28 AM](https://gitter.im/red/help?at=5deaabe026eeb8518f79f744)

I'm under a number of constraints with Atomica including ...
- ease of use, and easily automated
- consistency across languages and data silos,

In the other languages, strings are used for all the arguments.. they know nothing of 'words.
20:53I used all datatypes in the data block data:[db1 %db1.txt db2 %db2.txt] and arguments like
sv "one" "two" db1

And yeah, I get the correct results... but I have no idea how to use sv "one" "two" "db1" and get the same results. Why is this so difficult?
greggirwin
20:59Because you're fighting the language. I offered a suggestion, and stand by it.
21:00It's certainly possible to do what you want, but you need to dig in and figure it out.
LFReD
22:09@greggirwin Well another constraint is time. I'm not prepared to go deep in learning Red at this time. I would rather pay a bounty. From here I need to move on and finish the Python version, then on to Ruby
22:13And I don't even know Ruby HA!
GiuseppeChillemi
22:42@LFReD you need to have patience. People is warm here and helps you a lot but you have to learn Red way of doing things. I think that you will be able restructure your idea once you will go deep with the language. You are not a rookie but a good developer embracing in a difficult task that needs time. I see the light at the end of the tunnel is near, why turn back an go in the dark again?
LFReD
22:59Hey, I have absolutely no problem if any of my questions are left unanswered. Everyone's busy. I can't answer anyone's question either.. I would if I could, but they're too deep for me.

What I do know is Atomica is more than meets the eye, and I've used it with some fairly large projects, including the entire University of British Columbia's Go Global program from online application to application sorting and evaluating student acceptance criteria.

All that said, I think once you use Atomica, you'll see the benefits and and at the end of the day, everyone here will have a db that they can use with Red today. (The single DB version is available now..my hang up is with an experimental multi db system)

AND it's an OS project.. by not helping me is no skin off of my nose. I already have an advanced version using with PHP and MySQL, an old Cheyenne build, Node and JS.
22:59https://students.ubc.ca/about-student-services/go-global
23:09My only criteria is the consistency across language.. I haven't determined namespaces etc, but the most consistent method is probably dropping it into an object

billemail: atom/sv "bill" "email"

hiiamboris
11:31Best way to get help is to present here a **minimal** snippet of code that you expect to do X and that does Y instead (and show us what it does). We will offer a fix.
11:33As for Atomica, you should understand that anyone of us can write a DB like that in an hour. If you could, would you rather write one, or use one written by somebody else, who to all your knowledge has no idea how the language works? ☺
GiuseppeChillemi
13:19@LFReD Last year I have started implementing a DB structure and faced a couple of limitations too. The first one was the head of the path that could not be written as (WORD)/word/word/word. So creating relative paths for 2 DBs was not possible. Now I know I can use compose. Take your time to learn Red deeper and your idea could take shape as you want.
LFReD
16:59@hiiamboris :point_up: [December 6, 2019 10:35 AM](https://gitter.im/red/help?at=5dea9f7ac3d6795b9f355d7d)
17:15>who to all your knowledge has no idea how the language works? ☺

Well, that's a bit ignorant. I wrote this in 2001 (and it still works on Windows)

https://github.com/LFReD/Rebol-Q/blob/master/UniQ/uQ6.r

That was nearly 20 years ago. What happened? I realized Rebol was headed to Nowheresville. And dropped it for more conventional languages including NodeJS, Python, PHP, and mostly full-stack web development. In that time, Redbol has been scrubbed from my memory. It's like learning a second language.. use it or lose it.
17:20>If you could, would you rather write one, or use one written by somebody else
:point_up: [December 6, 2019 2:09 PM](https://gitter.im/red/help?at=5dead19c9319bb5190f17927)
17:33One thing I have learned, there's no money in syntax. It's all about the algorithms. I've subcontracted out bits over the years (heck, I even paid @dockimbel $100 to add some Cheyenne code for me once). Software developers are a dime a dozen.. especially in India (however I don't recommend using Indian developers.. those who have probably know what I mean ;)

In Nashville, you can find 10,000 really good singers. But good songs are rare. Write a good song, and the top 10 singers will climb over each other for the rights to it. Of course you could write Atomica in an hour. The AtomicaDB is just the start. The real power lies in the next bunch of algorithms that have probably never crossed your mind, like a good song.
18:21AtomicaDB is OS, starting with Red. Instead of giving me 'tips' on how to improve my code (Which I do appreciate!) why not contribute instead? However, if the functions not something like atom/sv "bob" "email" then it's not Atomica.. I know there's a 'Red' way of doing things. I'm happy to discuss name space issues etc, but whatever changes made here need to be cross language compatible as much as possible.
GiuseppeChillemi
18:25@LFReD As it has been a long discussion scattered in multiple chats I have not understood what has been the limiting factor for your previous approach.
LFReD
18:27@GiuseppeChillemi I'm sure any issue can be overcome, but I've considered a better method. The multiple DB issue isn't important.. we'll get to that at some point.
18:29>As it has been a long discussion scattered in multiple chats ...

I was just thinking about how lousy this method is.. it's like Altme.. a room for this, a room for that.
With Atomica, you could easily build a discussion method where you click on a particular post, and that could follow related posts, like tags, but done automatically by a bot.
18:31Remember.. "The real technology, behind all the other technology, is language" Carl's motto.
18:31http://www.rebol.com/what-rebol.html
GiuseppeChillemi
18:33Yes but it's all we have. Someday we will have instruments to track a discussion scattered over multiple groups, until then we must concentrate our discussion as much as possible on a single page.
LFReD
18:34Yes, but starts as a simple comment becomes a long discussion with a 'take it to chit-chat' thang.
18:35Like this one!
hiiamboris
18:59@LFReD I understand all that. No need to tell me ;)
Write a whole "symphony", however crooked it will turn out to be. I'll help you tune it at "performance" level.
Spacious philosophical debates won't get you to that goal, and are unfit for this room.
LFReD
19:59Are you saying 'take it to chit-chat'?
greggirwin
20:34Yes please.
20:34Help to keep this room focused on answering specific technical questions.
LFReD
20:52:point_up: [December 7, 2019 10:34 AM](https://gitter.im/red/help?at=5debf0d09319bb5190f8c58b)
I was being sarcastic as I had just said the same thing.

Rebol2Red
16:56@GiuseppeChillemi
:point_up: [November 3, 2019 12:03 PM](https://gitter.im/red/help?at=5dbeb40de886fb5aa246d388)
"Second question: is there an established way in RED/REBOL to have a
placeholder in strings and replace them with RED data ?"

I think your question holds the answer to it

string: "I am #age years old, #age is not that old"
age: ask "age: "

replace/all string "#age" age
print string


The placeholder is #age and the data is age
Not established, but it is a way
GiuseppeChillemi
17:05@Rebol2Red I have adopted $name$
Rebol2Red
17:13@GiuseppeChillemi I think #age is better because age is an integer after all
GiuseppeChillemi
17:25But it can be a string as #name. Why do you prefer #name over $name?
17:42I am again on contexts. Do you confirm that context of functions arises at function launch and dies when the function returns ? I suppose that if you return a block with words defined locally in the function's context the context remains independently from the function ?
17:43I suppose unreferenced contexts are garbage collected.
LFReD
17:54This is a fairly serious conversation in my book, as I use bots to scan code looking for these.
17:58age is both a noun and a predicate. There should be a distinction depending on use like =age= for nouns and °age° for predicate.. (or whatever, something that's unique.
hiiamboris
18:25:point_up: [October 10, 2019 6:55 PM](https://gitter.im/red/help?at=5d9f5473940b4c2fc0abfafd) and next @GiuseppeChillemi
18:26you can test what's garbage-collected and what's not with recycle/off
GiuseppeChillemi
18:35Thanks @hiiamboris I have totally forgotten that message. I am working again on persistent data between function invocations, so this needing.
hiiamboris
18:46What's the use case?
GiuseppeChillemi
19:05@hiiamboris I have a function whose purpose is to extract data from blocks. It contains library of functions inside blocks in the form lib: ['Word func [] [] ]. Once I reduce the block for the first time I don' t want to be reduced a second time at the second function run. So am investigating if function context is persistent between invocations to maintain the block in a reduced form and save cicles.
19:07The functions block contains different version of the same accessor for different data geometries, just like the action! code for different data types.
endo64
19:07> I suppose that if you return a block with words defined locally in the function's context the context remains independently from the function ?

@GiuseppeChillemi Functions context are available only during function is invoked:
>> f: has [a] [a: 1 [a]]
== func [/local a][a: 1 [a]]
>> b: f
== [a]
>> print b
*** Script Error: context for a is not available
GiuseppeChillemi
19:12@endo64 ok, I supposed it was available. Why it has been opted to have it inline only when function is running?
ne1uno
19:15case for use?
GiuseppeChillemi
19:54@ne1uno I see we have no USE in RED. Only in Rebol
greggirwin
19:56Correct. Use hasn't made the cut for being a standard function yet.
hiiamboris
19:58> Why it has been opted to have it inline only when function is running?

I guess it's just much faster to forget argument values than to garbage-collect a context with them after **every** function call
GiuseppeChillemi
20:04I suppose garbage collector activaties only after a threshold has been reached so you can remove each reference to the context and garbage collect it and everything else later...
20:05I intend something different:
20:08As :point_up: [December 8, 2019 9:04 PM](https://gitter.im/red/help?at=5ded576a26eeb8518f8b0fd7) Vladimir explanation, context in R3 is always available thanks to something called closure. So I am curious to understand why "closures" are not in RED.
hiiamboris
20:10I just tried to answer that ;)
GiuseppeChillemi
20:19Ok, so closure has not been implemented by design constraints but for deliberate choice.
20:25I see a limitation in this if a block of code to be passed around is composed inside a function using functions local words too. So if you have a function you use to forge code-blocks it must be carefully designed to avoid local words, which could prove to be very hard for certain tasks.
hiiamboris
20:30I still don't understand your use case. So you have a function with a block of functions. Why do you want functions arguments to persist after the call?
GiuseppeChillemi
20:31We are talking about different things now:
20:36My actual use case is

xtract: func [data geometry info] [
			getters: reduce  [
				'base 		reduce ['headings func [mydata] [first mydata]]
				'as-records 	reduce ['headings func [mydata] [first data]]
				'as-columns 	reduce ['headings func [mydata] [first data]]
				'as-ph 		reduce ['headings func [mydata] [first data]]
				'as-object	 reduce ['headings func [mydata] [first data]]

				'values func [] [] ;To be extended like above for each geometry
				'lenght	func [] []  ;To be extended like above for each geometry

			
		]
		attempt [getters/(geometry)/(info) data]
]

(Note, it is incomplete, only one access is correct, the other are stubs)


>> probe xtract [[a b] [1 2]] 'base 'headings
== [a b]

20:39It works
20:40(Note, I have JUST modified the code)
20:41The approach works and I have no difficulty whatsoever
20:44Now, think for a moment if getters block if forged containing local words and functions and the arguments too and the function is called FORGE-GETTERS. If I want to return the getters block as result, and move it around. Without the context it would be impossible !
20:46(modified the reply here too, now 21:45)
hiiamboris
20:47
probe xtract: func [data geometry info] compose/deep [
   getters: [base [headings (func [mydata] [first mydata])]
      ;...
   ]
   getters
]
20:47try it
21:59If you want local persistent *words*, create a context with these words.
f: func [args...] bind [x y z ...] context [x: y: z: 'values]
GiuseppeChillemi
22:33@hiiamboris Some affirmations:
In the last example there are 2 contexts, function one and an anonymous one, isn't it ?
The anonymous one exists until the last word is bound to it and the function word is unset
The anonymous context is always online.
hiiamboris
22:34It is so.
GiuseppeChillemi
22:38@hiiamboris @meijeru
Do you know what was the most difficult thing to learn about functions ?
hiiamboris
22:39Lemme guess... That blocks within them are persistent? ;)
GiuseppeChillemi
22:39They are a 2 pass 2 states affair.
hiiamboris
22:40How so?
GiuseppeChillemi
22:44A function is 3 elements in the first phase and then 1 element in the second one once created (2 states). Then, once created, if auto localising, all of its body block is scanned for set words (2 pass) and they are set to none.
hiiamboris
22:47You misunderstood it ☻ You only have a function once it is created. Before that you only have a call to a function constructor func with 2 block arguments.
Another function constructor, function simply collects the set-words, and passes them to func constructor
22:47It's simple. Don't complicate it ;)
GiuseppeChillemi
22:49At the beginning I have considered functions to be as I see them and also local words were set as in body sequence. So the whole learning process was difficult because of this.
22:50But length? [func [] []] is 3 and length? reduce [func [] []] is 1
hiiamboris
22:51Sure because [func [] []] is not a block with a function, it's a block with 3 Red values :)
Same as length? [1 + 2] is 3, but length? reduce [1 + 2] is 1
GiuseppeChillemi
22:55But a newbie isn't aware that the fuction is transformed from 3 elements to a function value. The rule you learn studying Red is that each element count as 1 for length?. Then suddenly you discover that functions and objects, after their creation, despite they visualy are rapresented with 3 elements, their are now one.
hiiamboris
22:57Is there an interpreted language where this doesn't hold true?
GiuseppeChillemi
22:58I don't know, I am not so expert but I think it is worth describing it a little more, even in the **specs document**.
23:02Think about a function inside a function:
You have to take in your mind that:
The main function created passing from 3 to 1
During the first run of the body function are still 3
Then after the first run they are one
During the second run they are no more created, they already exist (isn't it). So that set word is not a set word (the "there is no spoon" problem) as in other languages.

hiiamboris
23:05You misunderstood this as well. f: does [g: does [..]] will recreate g*every* time f is called.
23:06Your confusion comes from using reduce on a *persistent* (aka *literal*) block, that you change by the 1st call of reduce
GiuseppeChillemi
23:07Yes, thats the kind of confusion I had all the time.
23:09Se, everywhere I find a a: func [] [] is it recreated each time or there are differences between being it in a function or in the main code ?
hiiamboris
23:10Function body is evaluated each time you run it, right? It's only natural that this extends to function creation
23:11The "main code" is evaluated each time you run a program.
GiuseppeChillemi
23:12I was thinking of a function created inside a repeatloop in the main code
hiiamboris
23:13No difference from a function within a function of course.
GiuseppeChillemi
23:18Here is the proof you are right

>> repeat x 2  [spc: [[a b][a d]] body: [print a] f: func spc/(x) body probe :f]
func [a b][print a]
func [a d][print a]

GiuseppeChillemi
00:12is there a RED command which accepts words and values in separate blocks of the same length to create an object and set its values ?
greggirwin
02:37@GiuseppeChillemi just do that in a mezzanine. But you can use set on objects that already exist.
GiuseppeChillemi
06:56I have already made the function. Just asking in case I am missing something.
dockimbel
re-l124c41
14:38Hello everyone!
Wanted to ask for some advice on how to use variables in blocks.
I need to make a nested blocks that contains some calculated values like this:
[[1 2] [3 4]]
Made a function to do this:
f: function [x y][
    h: 5 w: 2
    compose/deep [
        [(x - (h / 2)) (y - (w / 2))]
        [(x + (h / 2 )) (y + (w / 2))]
    ]
]

But with compose and all this parenthesis it's a bit unreadable. Is there any other way to use variables to construct blocks with data "in place"?
Oldes
14:46@re-l124c41 do you really need blocks inside of the block? What about using pair! datatype?
14:46
f: function [x y][
    h: 5 w: 2
    reduce [
        as-pair (x - (h / 2)) (y - (w / 2))
        as-pair (x + (h / 2)) (y + (w / 2))
    ]
]
14:50Also... you should check, if you really need integer arithmetic, as 5 / 2 = 2 and not 2.5 as you maybe expect.
14:51You would have to use 5.0 / 2
14:52But I see that Red does not support float pairs yet. So if you need float results, you must use blocks unfortunately.
14:54To avoid compose/deep, you may use:
f: function [x y][
    h: 5 w: 2
    reduce [
        reduce [x - (h / 2)  y - (w / 2)]
        reduce [x + (h / 2)  y + (w / 2)]
    ]
]
re-l124c41
14:55I guess i'ts more of a general question on how to construct data objects in Red. I just happened to have this example at hands. Thanks for the tip about float and integer arithmetic! Will keep that in mind)
14:57I'm mostly writing groovy code so I'm used to short syntax for creating nested lists and maps.
15:00So to summarize: I need to either reduce each nested block or use compose/deep and parentheses?
Oldes
15:02In Rebol3 and once Red would support decimal pairs, one could use:
f: function [xy [pair!]][
    hw2: 5.0x2.0 / 2
    reduce [xy - hw2 xy + hw2]
]
15:04I guess that using reduces and or compose/deep is the easiest way how to construct nested structures. How it is in Groovy?
re-l124c41
15:15Wow this example with pairs from R3 really shows that I need to think differently from what I'm used to about solving problems when using Red)
In Groovy this will be almost same but we don't need to explicitly evaluate block (and it's not a block anyway it's ArrayList):
def f = {x, y -> 
    def h=5
    def w=2
    [[x - h / 2,  y - w / 2], [x + h / 2,  y + w / 2]]
}
f 1, 3
===> [[-1.5, 2], [3.5, 4]]
loziniak
15:19 Hi! How can I measure a text, that I want to use inside draw? size-text seems to require a *face* to get a font from it, but the font I use inside draw is different, changed by font draw command. What I need is a size-text, but with *font* argument instead *face*.
Oldes
15:25@loziniak just use temp face with font and text you want to measure.
loziniak
15:26Haha that's crazy :-)
Oldes
15:26Why? You can reuse it.
loziniak
15:27Perhaps I could come up with a PR making size-text accept font object. Do you think this could be useful?
Oldes
15:28
>> tf: make face! [font: make font! [size: 30] text: "foo"] size-text tf
== 75x59
>> tf/font/size: 10 size-text tf
== 25x20
15:29If it would accept just a font, you still would need to provide also the text.
15:30The idea behind probably is, that you usually measure existing face anyway.
loziniak
15:44Windows implementation of get-text-size in gui.reds depends heavily on *face* handle. It's out of my skillset to fix this. If it's possible at all.
15:45macOS & GTK versions could be easily upgraded.
hiiamboris
17:23You can use system/view/screens/1 face. Just assign a font to it.
loziniak

GiuseppeChillemi
08:56Having this block:

myfuncs: reduce [
  'base reduce ['headings func [mydata /uppercase] [first mydata]
  'base reduce ['values func [mydata] [first next mydata]
]


Without refimenements I call the function with:

myfuncs/base/headings ARG

But how should use the refinement /uppercase without setting a word ?

endo64
10:04I doubt you can, you may need make uppercase as argument instead of refinement.
GiuseppeChillemi
10:26Now I have realized I have encountered again the difference between selecting with paths and selecting with "select/pick". If they paths a function they run it (I don't know the correct term to use: reduce ?). Do paths work differently than select only for functions or are there other datatypes wich receive special treatment?
10:35@endo64 As simple as breathing: myfuncs/base/headings !
hiiamboris
10:40> Do paths work differently than select only for functions or are there other datatypes wich receive special treatment?

Try it with %files ;)
LFReD
10:46@endo64 Regarding Giuseppe's method above, what would be better, doing something like this with blocks or an object?
GiuseppeChillemi
11:16Blocks give you the flexibility to enlarge them if you need. Also the structure can contain extra data without the needing to use set words.
12:00@hiiamboris

>> write %try.txt ["hello"] a: [file %try.txt] a/file
== %try.txt
>>

I see no difference than expected behaviour.
hiiamboris
12:03
>> a: [file %file]
== [file %file]
>> a/file
== %file
>> a/file/subpath
== %file/subpath
GiuseppeChillemi
12:04Only here:

>> write %try.txt ["hello"] a: [file %try.txt] probe a/file/21212
%try.txt/21212


Instead of an error I get this output
hiiamboris
GiuseppeChillemi
12:44@hiiamboris For some instants, I supposed it was able to access the content based on offsets. %a/file/21212to read the content and %a/file/21212: to write it.
Oldes
14:52> But how should use the refinement /uppercase without setting a word ?

@GiuseppeChillemi is this what you need?
>> f: func[a /uppercase][r: first a if uppercase [r: system/words/uppercase r] r]   f/uppercase "hello"
== #"H"
endo64
15:19@Oldes No, @GiuseppeChillemi means when the function is inside a block and evaluated by path access.
Oldes
15:22Ah... right.. another ill coding design pattern.
15:23Maybe @dockimbel should reconsider if this is not the right time to implement something like R3 has:
>> o: context [] extend o 'f func[][now]
>> o/f
== 10-Dec-2019/16:23:05+1:00
15:26@GiuseppeChillemi It is possible to use map to hold your functions now in Red:
>> o: #() extend o reduce ['f func[][now]]
== #(
    f: func [][now]
)
>> o/f
== 10-Dec-2019/16:25:55+01:00
15:34Or to keep the @GiuseppeChillemi 's strange structure:
myfuncs: #(base: #())
extend myfuncs/base reduce [
    'headings func [data /uppercase][probe data probe uppercase]
    'values   func [data] [first next data]
]
myfuncs/base/headings/uppercase "a"
GiuseppeChillemi
17:19@Oldes, the data is structured to maintain a mutable library of functions that you can reduce (in number) or enlarge and also maintain additional unassociated data.
Also I know that I can use MAP!, I love this and also I know Red authors don't like it but I find this feature very welcome under library light.
17:23When I will end these experiments the next one will be aimed at creating shared specs and code blocks to reduce code written when many functions have an identical, or similar, interface and blocks of code.
17:25I have already discovered that some coding patterns give blocks reuse efficiency but also they are a nightmare when you have to understand functions code as a whole. But there are remedies too.
17:30There is a particular goal I want to reach: having a function with multiple interfaces and body and provide a variation of the base word. While it is actually impossible to have it as a normal function, due to arity being fixed, it could be reached with different techniques, either involving parse; a mix of refinements and args; a mix of arguments, refinements; and block used as container of arguments.
18:28There is an expression in my mind since the days I have started my adventure here... no, there are 2 expressions in my mind:
*"Code blocks composition"* and *"Dynamic Code Building"* (From libraries of building blocks).
Everything can be summarized using the definition: **Dynamic Coding**.
This technique could be made possible thanks to Red and Rebol data/code nature and I want to develop this style.
(Oh, I have just found they call it in another way: [Dynamic Programming](https://en.wikipedia.org/wiki/Dynamic_programming_language)

re-l124c41
09:54Hi everyone) It's me again with some newbie question.
I'm trying to understand how parse works and it seems when I'm using integer! in rule block it's somehow different from using string!:
>> parse-trace [1] [1 end]
 -->
   match: [1 end] 
   input: [1]   
   -->
     ==> not matched
   <--
 <--
return: false
== false

But the above code works if I change 1 to "1":
>> parse-trace ["1"] ["1" end]
 -->
   match: ["1" end] 
   input: ["1"]   
   ==> matched
   match: [end] 
   input: []   
   ==> matched
 <--
return: true
== true

Also if I just use two identical blocks I'm getting error:
>> parse-trace [1] [1]
 -->
   match: [1] 
   input: [1]   
*** Script Error: PARSE - invalid rule or usage of rule: 1
*** Where: parse
*** Stack: parse-trace

Why is this happening? What is the difference between integers and strings in rules?
hiiamboris
09:56You read this https://www.red-lang.org/2013/11/041-introducing-parse.html ?
09:58There's also this great resource: https://en.wikibooks.org/wiki/Rebol_Programming/Language_Features/Parse/Parse_expressions
re-l124c41
10:01I did but maybe missed something here. Will read again now) For reference I was using this site http://helpin.red/Parse.html
Oldes
11:02@LFReD taking your code from the main chat:
out: copy ""
    out: blk/john-email

It is again a nonsense code... the first line can be ignored as on the next line you set out to have another value.. which you may want to copy (that depends on real use scenario)
LFReD
11:40Yup, makes sense.
xqlab
13:35@re-l124c41 integers in parse dialect tell how many times something occurs. You have to prefix quote if you are looking for integers as part of the test sample.
13:36
>> parse-trace [1] [quote 1 end]
 -->
   match: [quote 1 end] 
   input: [1]   
   ==> matched
   match: [1 end] 
   input: []   
   ==> matched
 <--
return: true

GiuseppeChillemi
16:07I have faced a problem one year ago and I was not able to solve it. Despite having one year more experience and your lesson, I have still not able to create a solution. Here is the problem:

I want to create a generic path in a block that must be later selected and used inside a function. The path contains words that have a corresponding one in the context of the function. The words in the block are bound to the system context. Also they are between parens. How could I bind the words in the block to the function so that they are properly reduced?

myroot: [aword [b "WRONG: aword"] another-word [b "OK: another-word"]]
a: 'aword
p: [my-path myroot/(a)/b]
f: func [a] [probe reduce select p 'my-path]
f 'another-word

== "WRONG: aword"



16:08Paths could be longer and with different (word). I need a method to bind all to the current context or another solution to have the same working.
hiiamboris
16:10just bind the path ;)
GiuseppeChillemi
16:11So I can bind the whole path ?
hiiamboris
16:11oh it's not allowed yet
16:11then bind the block
16:12or use tricks, put the path into a block then bind it ;)
16:25or another trick: path: as path! bind as block! path :fun
GiuseppeChillemi
16:37then bind the block

How bind a block from the inside of the function as it has no 'SELF

f: func [a] [bind p 'a]


?


hiiamboris
16:38yes, like that, or if it has a name then to that name
GiuseppeChillemi
16:39>> or use tricks, put the path into a block then bind it ;)

If words in parens are not bound how should I do this ?
16:40
path: as path! bind as block! path :fun


Good trick but I am searching for a function compatible to Rebol too...
hiiamboris
16:43
>> a: 1 b: 1
>> s: [q w e r t]
>> reduce 's/(a + b)
== w
>> f: func [x a b] [reduce probe as path! bind as block! x 'x]
== func [x a b][reduce probe as path! bind as block! x 'x]
>> f 's/(a + b) 2 2
s/(a + b)
== r
16:45This works too:
>> f: func [x a b] [reduce first bind reduce [x] 'x]
== func [x a b][reduce first bind reduce [x] 'x]
>> f 's/(a + b) 2 2
== r

You're binding something else if it's not bound ;)
16:47>
> path: as path! bind as block! path :fun
>

>
> Good trick but I am searching for a function compatible to Rebol too...

In R2 you can use to, but it's a bit slower than as
16:56After https://github.com/red/red/pull/4144 is merged, you can also replace outer reduce with do
GiuseppeChillemi
17:05@hiiamboris The second solution does not work in Rebol
17:06
>> f 's/(a + b) 2 2
== s/(a + b)

hiiamboris
17:09use do or swap reduce & first
17:09Red makes more sense here
GiuseppeChillemi
17:11
>> f: func [x a b] [do reduce first bind reduce [x] 'x]
>> f 's/(a + b) 2 2
== r
17:18@hiiamboris so, using this form:

[s/(a + b)]

The whole block content, including words between parens, are bound. Is this affirmation right ?
hiiamboris
17:18Yes, that's how it works when your script is loaded
GiuseppeChillemi
17:23And why has RED no need to "DO" but "REDUCE" ? Which is the difference ?
hiiamboris
17:41try it in Red and R2 and see
GiuseppeChillemi
17:43I'll do !

rebred
23:03
a: "89504E470D0A1A0A0000000D49484452000000080000000808020000004B6D29 DC00000048494441547801638080330C472068E2F5FF108490802384C47F3080 882ECA61002290045C0859E2FF5B7B84722009149A6AF31F280A442016328248 74F54F62C014854AA089C225005795710344893AEB0000000049454E44AE4260 82"

the string
a
is a binary png image

how do I convert
a
to binary exactly char by char ?
hiiamboris
23:04with load
23:05or debase/base a 16
rebred
23:10@hiiamboris great !! thank you!!!
greggirwin
23:14But we can also ask where that string came from. It may not need to ever be a string.

rebred
01:33@hiiamboris with
debase/base a 16
seems that there is a limit of 65KB
01:33with
load
I wasn't able to convert it to binary
greggirwin
03:43@rebred there shouldn't be a 65KB limit. I just test enbase/debased a 1M, then a 10M string with no trouble.

greggirwin
07:30@bubenkoff, do ? "series!" in the console. Using a string as the arg to help will search by more than just names, so you can get a list of all funcs that mention series in their specs. From that list, play with various functions to see how they work. [head tail first second last next back find select append insert take remove pick poke] are a good start.
bubnenkoff
08:00Sometimes I can add question mark. For example:
>> head d
== [aa bb cc]
>> head? d
== true


It works as modificator? Which words have it?
greggirwin
08:12It's not a modifier, just part of the name.
08:13Try ? "?"
08:15Looks like it may have a bug. Some unexpected things show up in the results.
08:18Ah, locals in the spec are the cause.
pekr
09:51@bubnenkoff I would like to once again suggest a Rebol Core 2.3 documentation, section Series. Series is simply a series of values. For strings, it is a series of "chars". When you assign a series to some word, think about it more as a pointer, not that it will contain the value itself ....
09:55In the following example, you can see, that aoriginally pointed to different value. It pointed to a certain position in terms of the string. But the string itself got changed by insert, which inserts at the beginning (head) of the series, whereas appendappends at the end (tail) of the series ....

>> str: "This is my short sentence."
== "This is my short sentence."
>> a: find str "is"
== "is is my short sentence."
>> insert str "Magic! "
== "This is my short sentence."
>> a
== "gic! This is my short sentence."
>> print head a
Magic! This is my short sentence.
09:58Those concepts are sometimes a gotcha to even occassional reducer. Understanding the series concept is imo essential .... I am myself not a good coder, and have to use some prototyping in console, to be sure I have my code right ...
loziniak
10:02@bubnenkoff head and head? are just two different functions. In Red there is much freedom in naming. For example + and ? are also functions.
bubnenkoff
15:06Can be keyword used outside it's dialect? Could for example skip have another meaning in parse dialect, than simple skip one latter?
greggirwin
21:54@bubnenkoff, yes. Formally there are no keywords in Red, but a words meaning is entirely dependent on its context. That can mean two things in Red: Its binding or its use as a literal value in a dialect. In the case of skip in parse, it already has a meaning, so you would need to hack the parse code to change it.
21:57@bubnenkoff , given your example:
s1: "aabbccddee"
s2: next next s1

>> copy/part s2 s1
== "aa"
>> copy/part s1 s2
== "aa"

What result do you *expect*? And if you think about it, what other result could there be?
Oldes
22:00@bubnenkoff in the first case you copy data backwards.
pekr
22:00In the first case I would expect and empty string. It depends upon how this stuff is being implemented. I thought copy takes two indexes of a position and copies between them.
Oldes
22:02It is like using -2 as a part value.
pekr
22:03no, it is not
22:03
>> copy/part s2 2
== "bb"
>> copy/part s2 -2
== "aa"


greggirwin
22:04https://github.com/red/red/blob/master/runtime/datatypes/series.reds#L1139
pekr
22:04how comes submiting it s1as a second argument is interpreted as -2? What is a logical basis there?
22:05This is a file I looked into before. I am not sure we should care about how it is implemented, but rather what is reasonable to expect. And if R2 provides identical result, I am really missing a reasoning about that ....
greggirwin
22:05It always copies forward, just reversing the offsets if they go backwards.
22:06So it is as you thought @pekr.
pekr
22:06I expected such an answer (based upon my limited understanding of an R/S code). So it is a helper for user imo, but not a logical stuff imo.
22:07It is contraintuitive imo, as with integers, it works differently. Well, maybe not differently, just Carl decided, that with strings, he takes two indexes and if the result is negative, it goes backwards ....
22:08We can be glad, there is not a /reverse refinement for a copy, or it would be a complete mess
Oldes
22:09Reasoning is that being able to use nagative part value is more useful than having empty string as you expect. And it is logical.. just do math on indexes of the series used.
pekr
22:13It might be logical with the second case, not with the first one imo. There is imo no reason to not return an empty string. No wonder, back then in the past, there was a website called Rebol gotchas ...
Oldes
22:15Sorry.. I don't understans you.. I'm just on phone.. but maybe you should recheck your code and think why the results should be wrong... check which series do you use!
pekr
22:15There is absolutly no reasoning behind that. The calculation is based upon the offset. It is like stating that for function skip part is irrelevant, if you state plus or a minus value.
greggirwin
22:17> I thought copy takes two indexes of a position and copies between them.

It's exactly what you said there @pekr. The doc string could be improved though.
pekr
22:18Oldes - we were talking the following example, where you can swap copy/part values and you obtain identical result. The first case is the one I question. While I might understand the reasoning/usefulness, I don't necessarily agree with the design decision:

s1: "aabbccddee"
s2: next next s1

>> copy/part s2 s1
== "aa"
>> copy/part s1 s2
== "aa"
Oldes
22:18
>> s1: "aabbccddee"
== "aabbccddee"
>> s2: next next s1
== "bbccddee"
>> copy/part s2 2
== "bb"
>> copy/part s2 -2
== "aa"
>> copy/part s1 2
== "aa"
>> copy/part s1 -2
== ""
greggirwin
22:18"Copy to a relative position"?
pekr
22:19@Oldes - what I question is missing from your example :-) copy/part s2 s1
22:19Copy to a relative position might be a bit of a help, yes ....
Oldes
22:20@pekr do you prefer this:
copy/part tail s1 -2

or that:
copy/part skip tail s1 -2 2

when you want 2 last chars from given series?
hiiamboris
22:20@pekr /part is symmetric and series part is treated equally as integer part, in all R2 funcs:
(copy/part s1 s2) = (copy/part s2 s1)
(copy/part s1 s2: skip s1 n) = (copy/part s1 n)
(copy/part s2 s1: skip s2 0 - n) = (copy/part s2 0 - n)
Oldes
22:20
copy skip tail s1 -2
22:22
>> copy/part s2 ((index? s1) - (index? s2))
== "aa"
>> copy/part s2 s1
== "aa"
pekr
22:27@hiiamboris (copy/part s2 s1: skip s2 0 - n) = (copy/part s2 0 - n) <-- I can see the zero in there as a made-up argument, to support the case :-) Noone asked Redbol to go backwards. That's why Redbol has /reverse refinements imo. But it made me thinking, will have to think about it more ....
hiiamboris
22:32I have worked a lot on series. This symmetry makes a lot of sense in my opinion ;)
0 - n notation simply denotes a negative integer
pekr
22:35I might have good tip for a docstring then, taken from the R3 documentation - "The length of the result is determined by an integer size or by the ending position location." @greggirwin I would add the word endingto the help string ....
greggirwin
23:13"Ending" is ambiguous though @pekr. The length is determined by the difference between the two series offsets, symmetrically.
23:14But that's too long. What do others think of "Copy to a relative position" for the /part doc string?
pekr
23:16My idea was to add just a word "ending" to the R2 help string, so from "Limits to a given length or position." to "Limits to a given length or ending position.". Red's copy/part docstring is imo not sufficient ....
greggirwin
23:18The Rebol doc string seems fine then.
pekr
23:19Definitely better than the Red's one ....
greggirwin
23:28On brief reconsideration, the current doc string is fine. It makes it clear that the target of the refinement limit is the result, not the series itself.
pekr
23:33You don't mean it, right? So one has to think about it for an hour first, to come back to the conclusion, the recent doc string is sufficient? Maybe we just have different opinion for what the "it makes it clear" represents. Well, good luck to explain the offset stuff just to anyone in the future ....
23:35I thought, that Rebol was always about keeping things simple, not academic. No further explanation of offsets nor series symmetry should be imo needed in such a case ...
23:36I give up.
greggirwin
23:46I thought about it for less than 10 minutes. The Rebol doc string is different, but not definitively clearer. If you can prove that it is, show me how. What is academic about "Limit the length of the result." Nobody gets further explanation unless they read this chat or get confused.
23:47> I give up.

I'll hold you to that. ;^)

bubnenkoff
08:22Maybe it's better to add an example in docstring?
Oldes
08:50Better to have example function which would provide multiple examples on given topic... but who would volunteer to do it? Anyway.. this copy/part is such a basic thing in Rebol, that I wonder if @pekr don't have some _newbie illness_.
pekr
09:30Oldes, you imo did not understand, what the case was all about.
hiiamboris
09:32Don't forget that it's not about copy, it's about all /part functions. And all their docstrings.
pekr
09:36@Oldes I do remember few goodies from R3. There was a why? function for e.g., which after obtained error got you to the docs corresponding section of the error message. I can imagine explainor docs, which was available for R3 too. Here's the list of the R3 stuff as an welcome message in the R3 console:

Special functions:

  Chat - open DevBase developer forum/BBS
  Docs - open DocBase document wiki (web)
  Bugs - open CureCode bug database (web)
  Demo - run demo launcher (from rebol.com)
  Help - show built-in help information
  Upgrade - check for newer releases
  Changes - what's new about this version (web)
Oldes
09:43@pekr I think I understand what the case was all about, as I was initially helping @bubnenkoff to understand what he does... and I already noticed that he swapped s and e in [his code](https://gitter.im/red/parse?at=5df7a09c7d382b523f89c01b) but I let it be initially as I have also own work (quite a lot actually these days).
09:45And I really consider negative /part values to be useful in many cases.
loziniak
13:31Hi! How to make red square appear BEFORE wait?
Red [Needs: 'View]
a: make face! [
	type: 'base color: red size: 20x20

	showw: function [
		parent [object!]
		offs [pair!]
	] [
		self/offset: offs
		self/parent: parent
		append parent/pane self
	]

	hide: does [
		remove find self/parent/pane self
		self/parent: none
	]
]

view [
	panel [
		button "show a" [
			a/showw face/parent 0x0	; square appears after wait, not before
			wait 3.0
			;a/hide					; if you uncomment it, red square disappears as soon as it is shown
		]
	]
]
hiiamboris
13:42it does on W7
13:42try do-events/no-wait otherwise
loziniak
13:43Indeed, in Wine it shows too. So this time a GTK bug :-D
hiiamboris
loziniak
13:45Insert do-events/no-wait just before wait 3.0?
hiiamboris
13:45yeah, try it
loziniak
13:46It didn't help.
hiiamboris
13:46definitely a bug then ;)
dander
17:36@bubnenkoff for examples - http://www.red-by-example.org/#copy (but it seems to need a few more examples for this case probably). What about "Limit the copy to an offset"?
greggirwin
21:31> "Limit the copy to an offset"?

Relative or absolute offset if numeric? ;^)
21:32:point_up: [December 18, 2019 1:22 AM](https://gitter.im/red/help?at=5df9e1a9260751301ccad3d6) @bubnenkoff doc strings are meant to be short, more like reminders and hints, not full docs. A single example would be the common case, and wouldn't help WRT negative indices or offsets.
GiuseppeChillemi
21:43SELF is not available in function context. Will there be any change in the future ? Also, why this choice ?
hiiamboris
21:46self - no. We need it to refer to the context where func is defined. Other way - may be
GiuseppeChillemi
21:50@hiiamboris
>> We need it to refer to the context where func is defined

So it is why you use SELF internally ?
22:10@hiiamboris going back to binding a block, is there a way to not bind some words even if they are in the current context? I kean: could bind exclude some words?
22:10*mean
hiiamboris
22:12I had some mezz for that, sec
greggirwin
22:14@GiuseppeChillemi what do you need it for?
hiiamboris
22:15I don't recall where I've put it :/
22:15Anyway, try ?? collect
22:18Found it
Red [title: "rebind"]

unless value? 'rebind [
rebind: function [
	"selectively rebinds only `what` in `subj` to `tgt`"
	subj [block! function!] what [any-word! block!] tgt [any-word! any-object! function!]
	/deep "rebind also in subblocks/paths/functions (not in objects)" /local w f
] [
	if function? :subj [subj: body-of :subj]
	what-rule: either any-word? what [ [if (w == what)] ][ [if (find/same what w)] ]
	word-rule: [ change [set w any-word! what-rule] (bind w :tgt) ]
	deep-rule: [
		word-rule
	|	ahead [block! | any-path!] into rule
	|	set f function! (parse body-of :f rule)
	]
	shlw-rule: [ word-rule ]
	parse subj rule: pick [
		[ any [ deep-rule | skip ] ]
		[ any [ shlw-rule | skip ] ]
	] deep
]

]
dander
22:22@greggirwin what meaning would absolute have? head value? It doesn't make the string much longer to say "limit the copy to a relative offset"
GiuseppeChillemi
22:39@greggirwin I want to pass a block of code to another function which shares the same arguments. Those arguments are in the passed block, so I would maintain the value they have in the caller context.
22:41*shares the same arguments names.
22:53Also I have a question on body block part of a function. Is it copied at function creation? If I use the same body block on 2 functions, could there be any kind of interferences? And if there are local words in the spec blocks which are in both specs? Could any modification in the block provided as body argument modify the working of the functions the block has been used as body?
dander
22:58@GiuseppeChillemi
body: [append l: [] length? l]
f1: does body
f2: does body
greggirwin
23:07@dander :point_up: [December 18, 2019 3:22 PM](https://gitter.im/red/help?at=5dfaa69044e1fb33f6ed3861) yes, I suggested that earlier in the chat. Happy for more people to weigh in on that idea.
GiuseppeChillemi
23:09@dander I have tried them and the block seems to be copied, deep copied. Is it correct ?
greggirwin
23:13@GiuseppeChillemi yes, bodies are deep copied when the function is made.
23:14@GiuseppeChillemi I can't picture exactly what you're doing with passing and rebinding in funcs, but it sounds tricky. :^\
dander
23:18@greggirwin I might have missed another mention, but I saw you mention "limiting the length". I just thought the term 'offset' seemed to apply to both integer! and series! a little better than length. I guess it assumes the user understands a series to also refer to a position in a series -- that is you could refer to the offset either by the length from the start, or the actual position you want to go to
greggirwin
23:20:point_up: [December 17, 2019 3:18 PM](https://gitter.im/red/help?at=5df9542e2cc1b31e3437c874)
23:21Oh, how I long for a few features in Gitter.
GiuseppeChillemi
23:27@greggirwin I am working on building functions stacking blocks of code from a library of code templates and passing around blocks of code from a function to another via function interface (either as an argument or return value). I am trying to create a model to work with. So the needing to know:
- what happens when a block of code used in multiple functions spec blocks
- what happens when it contains local words used in different functions
- how to localize code blocks passed via functions argument (already answered)
- What happens to the words defined as arguments, or local, once a block is forged inside a function and that block is returned.
23:29Here I have explained what I am working on.
:point_up: [December 10, 2019 6:19 PM](https://gitter.im/red/help?at=5defd385c3d6795b9f5a9ad2)
23:31Call it "Dynamic Coding" or "Dynamic Programming".
greggirwin
23:32@GiuseppeChillemi first, note that func *specs* are not copied. Paste this into a console:
spec: [a b]
body: [a + b]
fn-1: func spec body
fn-2: func append spec 'c append body [+ c]

spec-of :fn-1
body-of :fn-1

fn-2 1 2 3
fn-1 1 2 3
fn-1 1  2

So it's pretty easy to get yourself into very tricky debugging situations when you start meddling in the affairs of dragons.
23:37If you post a minimal example, we can probably show you how to make it work, technically. Personally, I'm hesitant to help you do this, because I fear it will drive you mad. ;^)
23:39Once you have a minimal example, though, you should try to figure it out on your own. Really. This is important, because if you don't *fully* understand *all* the *intricate* details of what's going on, as opposed to just getting it to work right now, you could be in a world of hurt later when something breaks and no easy answers come in from the community.
23:41Of course, I'm thrilled to be proven wrong and see how your solution makes things easier and more maintainable, because that's what Red is all about.
GiuseppeChillemi
23:48Gregg, actually I am like someone having a vision and playing with its toys (how I call my tools becouse I work with them for passion...). I already know what means going mad when entering a forest whose governing rules are not known and you need to understand from scratch which they are but you create wrong one. So, your help is invaluable because this information prevents me from going mad. Thank you !
23:50(It is directed to you for your spontaneous code snippet and everyone who is helping).

koba-yu
03:52Hi, I am writing some codes and reading [document of Red's reactivity](https://doc.red-lang.org/en/reactivity.html).
But not sure one point.
Can I make reactive relation between view's face and a non-face object?

; this code sets reaction(t2/text syncronizes t1/text)

v: view/no-wait [
	t1: text "1" return
	t2: text "" react [t2/text: t1/text]
	button [print t1/text: to-string 1 + to-integer t1/text]
]


; this seems not to set reaction(t2/text is not updated when t1/text updated)

t1: object [text: "1"]
v: view/no-wait [
	; t1: text "1" do [t1/visible?: no] return
	t2: text "" react [t2/text: t1/text]
	button [t1/text: to-string 1 + to-integer t1/text]
]


I tried some other codes using react and react/link function but not get reactive relation so far.
greggirwin
03:59
t1: make reactor! [text: "1"]
v: view/no-wait [
    ; t1: text "1" do [t1/visible?: no] return
    t2: text "" react [t2/text: t1/text]
    button [t1/text: to-string 1 + to-integer t1/text]
]
04:00That is, use make reactor! instead of object.
koba-yu
04:02@greggirwin Thank you for your kind help!
greggirwin
04:03You're welcome. :^)
04:05Some time back I did [this](https://gist.github.com/greggirwin/38883ca5109175a60896d2f406ee49f6) to explore ideas with reactivity.
lucindamichele
04:10"The trick is having the base
; data/bmr-19* refs in each react block. This is needed because the
; reference to the nested value (e.g. data/bmr-1918/female) does *not*
; work by itself. That is, we're telling Red to monitor a field *within*
; a reactive formula source and which doesn't work (currently).
; I'm sure we'll see more capabilities built on top of the base reactive
; system in the future. For example, the ability to define styles that
; contain reaction blocks, and a way to reference dynamic sources. In
; the meantime, if you have a lot of faces, you can also generate your
; View layout specs dynamically, which is often a good solution."

Interesting. Has this been developed since?
04:13seems a little along the lines of Gary's AI related questions on the red/red list
greggirwin
04:16Not AFAIK.
lucindamichele
04:21Hmmmm. #Goals!
GiuseppeChillemi
10:11@greggirwin

You can but you can't....

>> z: [a b]
== [a b]
>> f: func z [probe c]
== func [a b][probe c]
>> append z 'c
== [a b c]
>> f 1 2 3
*** Script Error: c has no value
*** Where: probe
*** Stack: f probe  

>> get 'f
== func [a b c][probe c]

10:16C is not bound to the function context
Oldes
10:39@GiuseppeChillemi apparently this is not a way how it works and it is good, because being able to mess with function specification this way would be way to hell.
10:40You should understand, that function takes spec block and creates internally a function for you using the block. You can modify the spec block after, but the function is already created and so it is not affected.
10:42I think that the original spec block should not be used when you request the function specification. That is a bug imho.
GiuseppeChillemi
11:03@Oldes , this time I am not advocating, I am trying to understand how it works.
11:08I think function takes the spec block and creates the context and the interface for the function and when invoked the body is executed. A special work for auto localizing functions is performed to scan for set words, bind them to the function context and set them to none.
Oldes
11:08As I said.. it's a bug in [func native](https://github.com/red/red/blob/6b6fdf753643dbead6fe67364cd3ffb39b2de80f/runtime/natives.reds#L417). The function native correctly [copy the spec block](https://github.com/red/red/blob/6b6fdf753643dbead6fe67364cd3ffb39b2de80f/runtime/natives.reds#L434).
GiuseppeChillemi
11:09Then the spec body has no more influence on the function and I suppose modifications to the body too. (Have to try)
11:10@Oldes
> As I said.. it's a bug in [func native](https://github.com/red/red/blob/6b6fdf753643dbead6fe67364cd3ffb39b2de80f/runtime/natives.reds#L417). The function native correctly [copy the spec block](https://github.com/red/red/blob/6b6fdf753643dbead6fe67364cd3ffb39b2de80f/runtime/natives.reds#L434).

Someone else other than me will reply.
Oldes
11:12:point_up: [December 19, 2019 12:12 PM](https://gitter.im/red/bugs?at=5dfb5b1a44e1fb33f6f1c5d8)
11:14@GiuseppeChillemi If you want to understand, you should read sources... it is not like with Rebol2 where sources were not available and one had to figure it out by experiments only.
pekr
11:22In R2, function spec and body were just modifiable blocks (you could access them by first, second, third). But it has changed even in R3 IIRC, from a security reasons mostly ...
GiuseppeChillemi
11:24@Oldes I agree, Red/System and Red Sources are ahead in my learning path, just after VID and Parse.
Oldes
11:29@pekr in R2 the behaviour was same... you can modify the spec block, but it has no real effect, as it is just a _copy_:
>> append first :f1 'c
== [a b c]
>> ?? f1
f1: func [a b][]
11:30What was changed was, that there is no strange first :func but spec-of :func instead.
11:33One should probably notice, that the content of the spec block is actually a _function **definition** dialect_ and not expect, that when you change it after function is created, that the function behaviour will change too.
pekr
11:35In R2, you could modify the body of the function during its own execution, so actually injecting into its own code.
Oldes
11:36That is possible, but @GiuseppeChillemi was modifying the spec block.
pekr
11:36I thought that even a spec block was modifiable in R2, but never tried it. So you might be right ....
Oldes
11:38And when I check it, than it looks you are not right.. this is in my R2 console:
>> f: does b: []
>> append b [print now]
== [print now]
>> f
>> source f
f: func [][]
11:40Hm... this works in R2:
>> append second :f [print now]
== [print now]
>> f
19-Dec-2019/12:39:53+1:00
11:42So you are right that that was changed (fixed) in R3, for the security reasons.
GiuseppeChillemi
11:44@Oldes It seems you reference the body block used by function in the latter code and the source block used to create the function in the first one.
Oldes
11:49Apparently R2 copy the body block on function creation and not when accessing it using second accessor, so I believe, that this _monkey patching_ availability in R2 was not intended. (but I think that welcome as there were no sources available)
GiuseppeChillemi
14:05I think that in R2 "second" points to the actual "active" block and not on its source.
Rebol2Red
22:24I sometimes get this error when reading a webpage
*** Access Error: cannot connect: https://xxxxxx.com
*** Where: read
*** Stack: read-and-parse-page

With a call to curl i do not get this error.
Is it because we do'nt have ports yet so the timeout throws this error?
Is there some way to avoid this so my program does not stop at this error?
btw i have tried
if not error? try [read https://xxxxxxx.com] [....]

but this halts the program at the timeout error too.
hiiamboris
22:29On what OS?
Rebol2Red
23:14Windows 10

bubnenkoff
07:38Where I can read about Red architecture? Does Red similar to Forth?
"Forth contains two stacks, one for storing return addresses (what was I doinglast/where do I go back to?), and one for storing data. The first stack is called the returnstack, and the second is called the data or parameter stack. ". Is it true for Red?
hiiamboris
09:10@Rebol2Red Depends on the sites I guess then. But the key is that all possible errors are reported as "timeout" right now.
09:11@bubnenkoff to REBOL
Rebol2Red
15:11@hiiamboris So there is no way to avoid stopping my program by this error?
Maybe there is a way to set the timout of read?
hiiamboris
15:32Why does it stop your program though? "try" should catch that
Rebol2Red
15:59I really don't know, all i know it just did. My program reads about 61 pages and at **some** i get the error and the program stops. Now they are all fine after reading 5 times the 61 pages. I have to admit i had relatively slow internet connection and windows was acting slow while testing.
Maybe it's on the server side (resetting the server) or my modem has to be reset or windows memory is full or ...
hiiamboris
16:08Okay ;) Let us know if you nail it down to what looks like a Red bug.
greggirwin
18:27@bubnenkoff there is no document for the architecture at this time. After v1, Red will get an internal refresh and things may change. For now, you need to read the source and ask specific questions.

Rebol2Red
02:03@hiiamboris I have tested the program many times (not resetting my modem, nothing at all) at irregular intervals and it is working flawless now but only after my son stopped playing on his ps4 and my wife stopped "working" on her phone on the same network. I noticed the program is acting faster but that is not surprising. I'll will test again when the conditions are the same. If it starts happening again i will let you know.
02:19Can someone tell me what timeout is set in Red when reading a webpage?
greggirwin
02:32Red doesn't control that at this time. The simple-IO engine lets the OS or Curl lib define it.
Rebol2Red
02:39Aha, but when i use a call in my program to curl.exe (juli-19-2019) to read the pages it is always working flawless. Maybe Red is using an old Curl lib?
hiiamboris
08:53As I said, every possible error is reported as "timeout". So you don't know if it's a timeout really.
GiuseppeChillemi
23:32Please, could someone point to the function specs dialect in the Red source?
greggirwin
23:50There are 2 sources. The definitive one is https://github.com/red/red/blob/master/runtime/datatypes/function.reds#L743, but you can also look at https://github.com/red/red/blob/master/environment/console/help.red#L257.

GiuseppeChillemi
00:07@greggirwin thanks. I need it as I want to validate a block of additional function arguments to its specs using standard rules
08:34Just a note: having paths returning none won't let you distinguish if this value has been returned from a function or caused by a wrong path.

>> f: reduce ['a does [none]]
== [a func [][none]]
>> f/a
== none
>> f/b
== none
>>


08:35Which check could be done on paths to know if they are not valid?
08:37Nevermind:

>> type? :f/a
== function!
>> type? :f/b
== none!


I have found a way !
11:40Changing at high level the word assigned to an existing Red instruction, could alter the working of other instructions of the language or we can take that word safely ? I mean: if I reassign the word "find", will other instructions like "parse" which. I suppose, relies on find in some parts of itself, continue to work ?
hiiamboris
11:53If none: 0 breaks it, so should find: something else
GiuseppeChillemi
12:03@hiiamboris So, find: :mycustom-function will break the working of Red. I hoped Red built in functions were safe from this
hiiamboris
12:44Just do that in your own context, not in system/words, and you're good.
endo64
19:46@GiuseppeChillemi Currently there is no protect function in Red, when we have it we can protect redefinition of system words. There also was protect-system function in R2.

bubnenkoff
08:29Could anybody explain why Rebol/Red apps so small in comparison of C-based apps?
greggirwin
08:29Per your previous bug report. Seems you had a unicode c lookalike in there.
08:30Do you mean the amount of code it takes to build an app, or the final binary size?
bubnenkoff
08:36@greggirwin yes, you are right. I have found it and remove question
08:36About both, but mainly about binary size
greggirwin
08:40Red is a high level language, so a lot of functionality is built into it, that you would have to write yourself in a C app. That means you write less code. For binary size, it's hard to compare. If you write in R/S, it should be comparable to C. If you use the runtime externally, it can be shared by many apps, so only their unique code needs to be in their EXE. If you build a standalone EXE, it will be larger than a C app, because the whole runtime is included. Now, an even trickier aspect is if you use encap mode, which includes the Red source directly in the EXE, and interprets it at runtime. It's often the case, especially when compressed, that source can be smaller than all the code generated for the equivalent functionality when compiled. But compiled is almost guaranteed to be faster at runtime.

Red gives you options to choose from, to fit many needs.
bubnenkoff
10:02Is it possible to use trim with multiple args? What is the best practice if I want to remove several values?
trim/with "<div>" ["<" ">"]

pekr
10:18maybe somethign like this?

>> data: "<div>"
== "<div>"
>> remove-each item data [any [item = #"<" item = #">"]]
>> data
== "div"

10:20Or maybe some parse related code, either removing from original string, or collecting into a new one just what you want ....
hiiamboris
11:03
>> trim/with "<div>" "<>"
== "div"
>> as string! load "<div>"
== "div"

bubnenkoff
11:55whow!
11:56What is the type system of Red? Can you say that static or dynamic type system?
hiiamboris
12:02dynamic, although the compiler can infer types in some basic scenarios
bubnenkoff
12:03and dynamic and weak ?
hiiamboris
12:12hard for me to tell, depends on what meaning do you put into 'weak typing'
12:13there does not seem to be a consensus on the web about this term ;)
toomasv
12:16> What is the type system of Red?

https://github.com/toomasv/red-type-hierarchy/blob/master/Red%20type%20hierarchy2.pdf
dockimbel
17:03@bubnenkoff
> What is the type system of Red? Can you say that static or dynamic type system?

Dynamic and strongly typed (with the exception of the as coercion on types of the same class).

bubnenkoff
12:14
>> test: [lots items]
== [lots items]
>> test/lots: 123
== 123
>> test
== [lots 123]

Why so strange result? I expect to set first nested word to 123
hiiamboris
13:41it's by design
bubnenkoff
13:43it's replace next after specified value?
hiiamboris
GiuseppeChillemi
15:12 @bubnenkoff Do you know how to change the first element to 123 ?

bubnenkoff
07:50@GiuseppeChillemi
>> x: [aa bb cc]
== [aa bb cc]
>> 
>> x/1: 123
== 123
>> x
== [123 bb cc]
greggirwin
07:53@bubnenkoff playing in the REPL will teach you a lot, as well as reading docs on series. Rebol docs are more detailed at this point, but finding and tinkering with various series funcs is easy.
>> test: [a b c d lots items]
== [a b c d lots items]
>> test/lots
== items
>> find test 'lots
== [lots items]
>> select test 'lots
== items
07:55So you can see that path access, using a non-integer key, works like select, while integer keys work like...I didn't include it in the example.
07:56You said the behavior seemed strange, but see how the syntax compares to accessing values in objects or maps.
GiuseppeChillemi
08:53@greggirwin I found his observation very interesting. I asked to myself "why was he expecting the first word had to change?". I suppose the concept of variable, its content, the word position and : came into the mental game: "set me to 123", "replace me to 123". I love to see new users approaching Red, they show how our mind works encountering new topics.
08:55@bubnenkoff perfect, you now know the difference between an integer selector and word selectors.
08:56Follow Gregg suggestion: Rebol chapter on series is a treasure of knowledge.
11:21I was experimenting with contexts. I have tried to bind a word to a context in the console and get its value.

a: 0 

ctx1: context [
   a: 22
   b: 87
   c: "Hello"
 ]

bind 'a ctx1

probe a
== 0


I was expecting 22 !

hiiamboris
11:45what you're expecting is impossible
11:47you want somehow system/words to become a mix of different contexts
toomasv
11:53@GiuseppeChillemi You have to keep your "contextualized" words out of system/words:
bind a: [a] ctx1
== [a]
>> get a/1
== 22
hiiamboris
11:57Or
>> a: bind 'a ctx1
== a
>> get a
== 22
toomasv
11:58Even better!
GiuseppeChillemi
12:00Well, that's another misunderstanding. In my mental model I have thought that words exists outside system context and they could be bound either to it or to another context.
12:03@hiiamboris
> Or
>
> >> a: bind 'a ctx1
> == a
> >> get a
> == 22
>


I had already tried this but found no explanation why a in a: has not been set to the "proper" context.
12:04But clearly it works differently
hiiamboris
12:06Think more about this part:
bind 'a ctx1

probe a
12:06How do you expect the result of 1st expr to travel into 2nd expr?
GiuseppeChillemi
12:08Because I supposed there were a separate words list other than the system context. So you bind the words in that list to any context you want.
12:10I still miss mechanism how the program code/data block is loaded and structured in memory and words are set, searched and retrieved for their respective values.
hiiamboris
12:12Do you understand the concept of "context is a table of words and their respective values"?
12:13I vaguely recall you even painted it ;)
GiuseppeChillemi
12:14Words are bound to the context and take the value they have in it. **Context has word and value couple.**
hiiamboris
12:16Forget 'bound'. Just a table with 2 columns, nothing else.
12:17That's contexts.
GiuseppeChillemi
12:17Yes: **Context has word and value couple**
hiiamboris
12:17'Bound' comes from the word cell. When you write a you create a word cell, and that cell contains the binding (just a reference to a context).
GiuseppeChillemi
12:18Bingo ! What creates the word cell ?
hiiamboris
12:18load does.
12:18or make word! .. used by it
GiuseppeChillemi
12:19I supposed there were a list of word cells each storing a different word.
12:20And... where is this list stored ? I supposed a separate list other than system/words context.
12:20These missing parts of my knowledge are the sources of my trouble.
hiiamboris
12:20There is no list of word cells. ;)
GiuseppeChillemi
12:21I supposed this ! :-)
hiiamboris
12:22A cell is passed into expressions as argument, it may be assigned by you to something. Otherwise it's just lost.
12:23Your bind 'a ctx1 returns a new word cell. But it's not passed to anything or stored explicitly. So you lose it.
GiuseppeChillemi
12:24Yes, I have seen it in the consolle: bind 'a ctx1 returns a and as it has not been stored anywhere, I supposed I have lost it.
12:25insert x: [] bind 'a ctx1 would have stored it.
12:26and probe x -> [a]
12:32So probe first x -> 22
12:33(Just to mix both examplanations)
12:35@hiiamboris Is it true if I affirm: when the script is loaded into memory, each Red element is converted into its corresponding cell element?
hiiamboris
12:40What's a 'Red element?' ;) Token in string?
GiuseppeChillemi
12:42We are touching topics I have encountered rarely in my life. Tokens where for me the translation of BASIC language commands into an internal numeric value which had an association command ID - function in a table.
12:47Red element is for me: an integer, a refinement, a word. Upon loading they are converted to a lower level structure. I remember Vladimir talking about CELL and PAYLOAD with a 128 bit structure. But how we pass from a textual script to cells and where tokens place is in this picture is obscure to me.
12:49Also I don't know how the execution is performed at lower levels but I would like to learn it a lot !
12:51I am just reading this: https://en.wikipedia.org/wiki/Lexical_analysis#Token
13:09Read !
So the first thing Red does is loading the source and converting it to tokens. The lexer stands in the middle of process.
hiiamboris
14:06You don't have 'an integer, a refinement, a word' in the first place. You have a stream of characters, that's all.
GiuseppeChillemi
14:22@hiiamboris Yes, I know I don't have them. At load time text is analyzed and then converted to... tokens ?
hiiamboris
14:29Yes. And each token, once recognized, gets immediately converted into a cell.
GiuseppeChillemi
14:34Which is the process which "recognizes" the tokens and convert them to cells ? The evaluation of the program (the program is running) or during tokenization phase ?
hiiamboris
14:34During load. system/lexer/transcode func.
14:35What's important is that there's no magical source of Red values that is converted to low-level something ;)
Only characters, tokens (which are an intermediate thing that is never held), and produced cells (which get put into a new 'block!' cell that can hold them all). Cells are the values.
GiuseppeChillemi
14:37So, cells are put in a 'block!' cell and then the evaluation starts from the first cell ?
hiiamboris
14:38Yes, that's how do works. You can make your own evaluator, that goes backwards ;)
GiuseppeChillemi
14:38But I have a "but" !
hiiamboris
14:39Shoot :)
GiuseppeChillemi
14:42I have this precious message from Vladimir: :point_up: [April 10, 2018 11:20 PM](https://gitter.im/red/help?at=5acd2aa75f188ccc154fc0b2)
It talks about a symbol table and words with a symbol ID which points to the word's context. *So I have thought the symbol/words table is external to everything and so words could be rebound from system/words to other contexts* .
14:44The problem is that I do not know what the symbols table purpose and nature is.
14:44So I started assuming things that are surely not real.
hiiamboris
14:46Symbol IDs are an optimization. You write words "hello simple world". Red thinks it's too bothersome to compare words as strings (e.g. is "hello" = "simple" or not). So Red assigns an integer to each unique words: your input is [1 2 3] for Red now (not integers but symbol IDs). And it's easy to compare (e.g. 1 = 2 ? nope..)
14:46Red remembers, that 1 is "hello", etc. To that end there is a symbol table.
14:46(suppose you have to print word)
14:47But no need to concern yourself with this ;)
14:49In Erlang, there's the same thing called 'atoms', to speed up communication between actors.
GiuseppeChillemi
14:51Once Vladimir wrote that to fully use Red you must deeply know how works the language, this against all the other writing "Red is so simple, you don't have to know this". Well, I agree With Vladimir. After more than an year since he has written this I *can affirm* that without knowing many internal Red workings it can be really used only as a "scripting language" and just few things more.
hiiamboris
14:54Of course, but do you have to know every detail? Remember every addition and multiplication? ;)
There's knowledge that lets you model things properly, and there's purely implementational details that you will only have to know for writing R/S code.
14:56Does it bother you for example, why Red gets out of memory when reading 700M file, and not 2000MB?
GiuseppeChillemi
14:56*you will only have to know for writing R/S code*

Give me one year and I will be there.
Also, those details build my mental model and many things become clearer time after time.
14:58@hiiamboris

It should depend on fragmentation of data once loaded in memory, so I suppose it depends on how data is converted and stored.
hiiamboris
14:58It's an interesting exercise ;) Crack it ☻
GiuseppeChillemi
15:01Let's conclude this topic: so you can't bind 'a ctx1 because you can't reference the main "block".
hiiamboris
15:01No. Because a context only has 2 columns. Symbols and values (cells). No binding info.
GiuseppeChillemi
15:04a has symbol ID and context.
15:04Context has Symbol ID and value.
15:05But you can't change the binding of a it into the main block without giving the block with the word as argument.
15:06(Changed)
hiiamboris
15:06Forget the 'main block'. 'a is bound to system/words context (initially everything is).
15:09> a has symbol ID and context.

> Context has Symbol ID and value.

So, as you can see, context doesn't have references to other contexts.
GiuseppeChillemi
15:10Let's change wording to avoid going in circles: bind 'a ctx1 returns
a as result bound to ctx1, doesn't it ?
hiiamboris
15:11Yes.
GiuseppeChillemi
15:13All the as in the main block have system/words as context set at load time, haven't they ?
hiiamboris
15:14Yes.
GiuseppeChillemi
15:14But there is now a way to change their binding to ctx1 in any way.
hiiamboris
15:15By evaluating bind
GiuseppeChillemi
hiiamboris
15:15bind is the only thing that changes binding to other context. At run-time.
GiuseppeChillemi
15:17I think that evaluating bind means something more this time but I am not sure.
hiiamboris
15:17Just a function ('native' technically) call.
GiuseppeChillemi
15:18Distance and chats is limiting...
15:19But I think I have understood 98% of the topic !
hiiamboris
GiuseppeChillemi
15:19Thanks for the patience
15:22A couple more question remains about the workings of Red at this level but nothing more. We are at the end of this stage !
15:24🎆🎆🎆
hiiamboris
15:24Sure ;)
15:25Stage 2 has more powerful monsters though, so be sure to take your time ;)
GiuseppeChillemi
19:26One of the remaining monsters: why functions are split from their original spec and body block once created? How data is structured internally? (same question goes for objects but I think the answer is the same)
hiiamboris
19:42> why functions are split from their original spec and body block once created?

But they are not. Only spec of function [..] is copied.
19:43> How data is structured internally?

That you will discover when you dive into R/S one year from now ;)
GiuseppeChillemi
22:03@hiiamboris It seems that body is copied at function creation and specs are not:

My question :point_up: [December 18, 2019 11:53 PM](https://gitter.im/red/help?at=5dfaade744e1fb33f6ed6b6e)
And Dander answer example

Gregg answers: spec not copied: :point_up: [December 19, 2019 12:32 AM](https://gitter.im/red/help?at=5dfab72149314a1d45a06ebb)

Body is copied :point_up: [December 19, 2019 12:13 AM](https://gitter.im/red/help?at=5dfab297e0131f50c9696c3a)

Holdes pointing to a possible bug in specs creation :point_up: [December 19, 2019 12:08 PM](https://gitter.im/red/help?at=5dfb5a3d44e1fb33f6f1c033) (read a few comments earlier)
hiiamboris
GiuseppeChillemi
22:11You are accessing the block "reflected" by body-of

hiiamboris
22:11Nvm, I see what you mean
GiuseppeChillemi
22:12But I liked you example. Please write it to me privately, I'll keep it in my library as reference
hiiamboris
22:12Sorry, deleted it ;)
22:13Well, I'm not sure what the copy is for. I'll think about it
22:16Maybe it's for inner functions?
>> f: does [g: does [probe append [] 1] g]
== func [][g: does [probe append [] 1] g]
>> f
[1]
== [1]
>> f
[1]
== [1]
22:17It's a question for Rebol veterans. As it's the same in R2.
GiuseppeChillemi
22:21It is the point where I am stuck in my mental model: I don't know how functions bodies and object bodies structured and kept separated from source block.
Also, if you perform a

>> length? f: [func [a] [probe a]] 
== 3
>> length? f: reduce [func [a] [probe a]] 
== 1
>>


The block is transformed and body and specs sources are no more there.
hiiamboris
22:23Object and context is the same thing right now. And you well know that a context is a 2-column table ;)
22:24Fn bodies are like other blocks, just arrays of cells.
GiuseppeChillemi
22:25When reduced the array is changed from 3 elements to 1 and then the source body is copied somewhere you can access only via Body-of reflector
22:29I know how it works but I do no know the inner mechanisms and storage structures and transformations involved. This is what I miss.
hiiamboris
22:33Well, it's in the open https://github.com/red/red/blob/544a6e12b265765d343bd71a483cd79de383dbc6/runtime/datatypes/structures.reds#L242
GiuseppeChillemi
22:54Questions will come later. Now a simple one: where is "node!" type defined?
hiiamboris
22:59https://github.com/red/red/blob/master/runtime/definitions.reds#L53
GiuseppeChillemi
23:12Thanks, looking at the inner parts of Red is like opening your eyes to a whole universe.

GiuseppeChillemi
08:27@hiiamboris
> Symbol IDs are an optimization. You write words "hello simple world". Red thinks it's too bothersome to compare words as strings (e.g. is "hello" = "simple" or not). So Red assigns an integer to each unique words: your input is [1 2 3] for Red now (not integers but symbol IDs). And it's easy to compare (e.g. 1 = 2 ? nope..)

So I suppose there are equalities rules so that different words share the same symbol ID. Hello , HELLO, hello, hellO, "hello", they all have the same simbol ID.
08:29If this is true, could you point me to the part of Red source where these equalities check are located so I can learn from it?
greggirwin
09:09@GiuseppeChillemi try %datatypes/symbol.reds. But please try searching on your own, because that's often what we have to do too. A couple people do have the bulk of the system in their heads, but they are very busy.
GiuseppeChillemi
13:26@greggirwin yes I now. Also I don't like asking but I am at the very beginning of this new travel and few hints about the whole structure and logic is welcome. Then I can continue by myself.
hiiamboris
13:34You can guess the structure by file/directory names ;)
koba-yu
15:20Hi, can we use build libRed command now? I got the error below.

PS C:\Users\x\OneDrive\ドキュメント\red> .\red.exe build libRed

-=== Red Compiler 0.6.4 ===-

Compiling C:\Users\x\OneDrive\ドキュメント\red\libRed\libRed.red ...
...compilation time : 1836 ms

Target: MSDOS

Compiling to native code...
*** Compilation Error: argument type mismatch on calling: red/actions/remove*
*** expected: [integer!], found: [struct! [
        header [integer!]
        data1 [integer!]
        data2 [integer!]
        data3 [integer!]
    ]]
*** in file: %/C/Users/x/OneDrive/ドキュメント/red/libRed/libRed.red
*** in function: exec/redRemove
*** at line: 2610
*** near: []


I am now on Windows 10 and Red 0.6.4 for Windows built 13-Dec-2019/15:37:32+09:00 commit #134a2b0
GiuseppeChillemi
16:22@hiiamboris you know that is not exactly what I need but it's a start 😉
hiiamboris
16:28@koba-yu hi :) Will you make an issue for this on [the tracker](https://github.com/red/red/issues/new?template=bug_report.md)? I can confirm it does not build for me too
Likely cause of regression: https://github.com/red/red/commit/ee12c461e8499d9e9b51dfc6c16a6fc8204c7fd5#diff-6bef59794da7c0a4cc711c1267da435e
greggirwin
20:13@dockimbel is aware of a build issue, which may be this one.
koba-yu
23:57@hiiamboris @greggirwin Thank you for your reply.
Though @dockimbel may already knows, I have made an [issue#4209](https://github.com/red/red/issues/4209) just in case. When I noticed it resolved, I will close it.

greggirwin
00:30:+1:
GiuseppeChillemi
14:37I am working on a small conversion framework. I convert from table format to array of objects; from words to placeholdes/values and vice versa. I need to make a choice: should this conversion COPY the original data like string fields or use the same structure ? Which solution would you suggest ?
14:41Also, I have another one: could ":" be redefined as you do with operators? I mean without passing from pre-lexer
hiiamboris
14:41> Also, I have another one: could ":" be redefined as you do with operators? I mean without passing from pre-lexer

no
GiuseppeChillemi
16:08It's just the last missing piece that keeps my code to be an extension of the datatype system. I will need to use set and get.
hiiamboris
16:34get- and set-words don't work for you?
meijeru
16:38I suppose Giuseppe is developing a "programming style" or (equivalently) a dialect. It would be nice to see what that is...
GiuseppeChillemi
17:07@hiiamboris Set and Get should be replaced to be used with new datatypes. Also : notation could be used as new datatypes are just blocks whose first element is a header. Maybe I have found a coding style (using @meijeru words) that allows me to reuse the standard words and interface, so I have not to parse a block of code. Without being able to "overload" (hope it is the correct term) the working of set and get OPERATIONS made using :, this approach will have limits.
17:13Another limit is caused by not being able to define a word is of datatype! type, but I am creating a new version of TYPE? which will go beyond this one (I hope).
17:17I hope will be able to let you see something in a couple of weeks. I am working fast as the style adopted is very simple and straightforward. It could even be extended.
hiiamboris
17:20good luck ☻
GiuseppeChillemi
17:26I don't need luck, I need skill. This is coming thanks to your help on topics not covered in available documentation and continuos experiments on the console. Ideas are just my own...

Rebol2Red
15:19Can someone explain what's the use of the icons of people on the left side of the screen under ALL CONVERSATIONS so i can decide if i want this too. Is this a link to a room or a way to chat?
How can you add your own icon?
15:33Is it possible to use view and parse in Red System?
Will a program be faster using R/S? (For example a program which use parse)
hiiamboris
15:58Red (that includes View and Parse) is built in, and compiles to, R/S. Just define your own routines with R/S code.
Rebol2Red
16:01I see, Thanks
16:04:point_up: [December 29, 2019 4:19 PM](https://gitter.im/red/help?at=5e08c400fd580457e78ff6e4)
What about this?
hiiamboris
16:04You mean the list of private conversations with other people?
Rebol2Red
16:05Yep, how does that works?
hiiamboris
16:06Everyone you ever PMed shows up there I think. It's possible to close those chats if you wish so.
Rebol2Red
16:07How to close those conversations?
hiiamboris
16:08See the "room settings" icon in the top right corner? When you switch to any of those conversations, it will show a "hide this room" option.
Rebol2Red
16:09It works. I appreciate your help, Thanx
GiuseppeChillemi
22:49When I build bocks of configuration data I use a key followed byt its value like:

config: [offset 1 body-keyword body]


As you can see, being body-keyword of the same WORD! type
of the value following it, this limits the number of usable values. When the keyword is just one there is no problem at all, but when keywords are multiple and there is the need of merging multiple blocks or storing values coming from the end-user, there is always the risk of value having a prohibited word.

For me, the best solution is to enclose the value word into a block:

config: [offset 1 body-keyword [body]]


And use config/body-keyword/1 path notation.

Which is your way to solve this problem?
Rebol2Red
23:01About compiling a program which use for ex. this line #include %/C/RED/user.red
Is the following the same in Red as in Freebasic?
The path to an include file may be an absolute or relative path.

For relative paths, or where no path is given at all, 
the include file is search for in the following order:
- Relative from the directory of the source file
- Relative from the current working directory
- The folder where the executable is located
GiuseppeChillemi
23:23Another question: could an atypical path be created ? One wich starts with a number ? I need it in a block like [1/c/4] and then use my routines to decode it.
hiiamboris
23:44@Rebol2Red it makes sense only to search from the script's location
23:45@GiuseppeChillemi
>> to path! [1 2 3]
== 1/2/3

GiuseppeChillemi
08:36@hiiamboris It is incredible how you think to convoluted solution when the right one is so simple.
ralfwenske
10:07I have encountered a rather strange error inside split-path
When I run this:
Red []
path: %data/coingecko/
name: "btc-map"
f: rejoin [path name ".obj"]
?? f
print split-path f

the console shows correctly:
f: %data/coingecko/btc-map.obj
data/coingecko/ btc-map.obj

However inside a rather complex application I have this code (that has worked before):
f: rejoin [path name ".obj"]
?? f                                          ;inserted to debug
print split-path f              ;inserted to debug
        unless exists? (first split-path f) [            ;original crash
            create-dir (first split-path f)
        ]

it crashes at the print split-path f with:
f: %data/coingecko/btc-map.obj
*** Script Error: at does not allow logic! for its series argument
*** Where: at
*** Stack: show-price split-path empty? dir

A) Is it possible at all that my environment has an impact on split-path?

B) the source of split-path (parse) is a bit beyond my ability to debug.
Is there an easy way to narrow down what might be happening here?
hiiamboris
11:06I wonder if you redefined head in system/words?
ralfwenske
12:20@hiiamboris Bingo! Thank you so much.
If I remember correctly, to do such a thing will be made a bit harder in some future release?
hiiamboris
12:24I suppose so too.
GiuseppeChillemi
14:11@hiiamboris So won't be possible to redefine words in system/words ?
hiiamboris
14:21Don't ask me :) But my educated guess is that it will be possible, just not by mistake.
GiuseppeChillemi
19:46Something like /force or you will have to lower security, I guess.
greggirwin
20:48Red will likely have protect, as Rebol did.