test:Red [] ? system/script
# ./red test *** Script Error: image! has no value *** Where: =
# red red/read/test *** Runtime Error 27: non-existent physical address *** at: A17340E4h
red-28apr17-bbd8e43.to-int: function [value [percent!]][to integer! 255 * value]
view [
below
r: slider
g: slider
b: slider
base react [
face/color: as-color to-int r/data to-int g/data to-int b/data
]
]View window I notice a 2 seconds delay when switching Terminal.app tabs,Application Not Responding, normally that is only for unresponsive apps.op!, but it looks like it works at first, and can generate a crash:>> plus: make op! [[x y][x + y]]
== make op! [[x y]]
>> ? plus
USAGE:
x plus y
DESCRIPTION:
PLUS is an op! value
ARGUMENTS:
x
y
>> 1 plus 1
*** Runtime Error 1: access violation
*** at: 02BD5F0Chop! is just the infix version of a prefix binary function, it has no constructor defined for a spec/body blocks input.>> load %. *** Script Error: transcode does not allow block! for its <anon> argument *** Where: transcode
read %. ???tab before ;commentf: func [ fun ;comment ][fun] f 1
f: func [
[ func function function! function?
[ func;comment
[ ][fun]
; func [
func
][fun]
f 1
*** Script Error: fun has no value
*** Where: fbracketed paste mode on Mac, it can be used to fix this issue. Will push a fix later. :smile: gui-console. Also, I guess we don't need anything like that on Unix?do the block containing a function passed as an argument.do block will run interpreted at execution time.Red [] object [ a: func [i][i] set 'b func [f][do [f 1]] set 'c does [b func [i][print a i]] ] c
?function?
a function called in the function passed as an argument to function b inside function c should be executed interpreted as it is evaluated inside the do block in the body of function b.a is not executed, it returns instead it's function value.Red [] object [ a: func [i][i] set 'b func [f][do [f 1]] set 'c does [b func [i][print do [a i]]] ] c
do [a i] instead of a i inside the function passed as argument to function b that is run inside the do block of function bdo, so that the interpreter takes over it (maybe we should make that a compilation option) and you won't be limited by the compiler. Dyn-stack branch should solve most (maybe all those cases), though, performances will suffer from it, for use cases like that (closer to interpreted performances than compiled ones). No ETA, they are too many other higher priority tasks for now.a returns it's function value and not be executed instead?do as you did in the second example.Red[] Compilation troubleshoot?do itsystem/view/evt-names in latest windows build:key-up on-key-up
ime on-ime
focus on-focustime on-time is therecontinue. The help says "Throws control back to top of loop" and from a few tests I suspect that this is indeed what it does: restart the loop body with the loop counter the same as it was. But that leads to endless loops. Shouldn't it rather throw control to the *end* of the loop, where the loop counter is tested and possibly increased?loop, while,until: no counter, *NA*repeat: counter increasesforall: *infinite loop (implying counter doesn't increase)*foreach: counter increases>> repeat i 5 [if odd? i [continue] print i] 2 4
continue is last value:>> things: [1 2 3 4 5 6] forall things [if 4 < first things [continue] print things] 1 2 3 4 5 6 2 3 4 5 6 3 4 5 6 4 5 6
head things?forall. I will make the issue later today.%interpreter.reds at lines 215 - 220. There is a definite typoswitch TYPE_OF(arg) [ TYPE_LOGIC [push logic/get arg] TYPE_INTEGER [push integer/get arg] TYPE_LOGIC [push float/get arg] default [push arg] ]
TYPE_LOGIC should be TYPE_FLOATp: layout [
button "Create" [
do view [
button "Lockup Red REPL"[
unview/only p
view p
unview
unview p
]
]
]
]
view pp: layout [
button "Create" [
do view [
button "Lockup Red REPL"[
unview/only p
view p
unview
unview/only p
]
]
]
]
view pdo view will try to evaluate the return value of view, which is very odd, as viewshould return a face or a value from the event loop. popup doesn't have borders, a different result from what @justjenny is getting (noflags doesn't work for her either)popup. With @justjenny bug with borders, if you see the last image, the popup version doesn't have blue border except at the top. Given, it's just a minor visual thing. And jenny says it happens with python and rebol too (which I've not checked)Showcase/last-commits.red example. Great! Only, when I run it as is, the window is minimal size, and cannot be enlarged. I had to add dimensions to the text-list (say 800x600) in order to have a useful picture. Missing or wrong default size for text-list?view/flags [] 'resizeview, then write the resizing event handler yourself.view [
text-list data parse
read https://api.github.com/repos/red/red/events
[collect [any [thru "message" 3 skip keep to ["\n" | {"}]]]]
]events and list words definition, so it looks more *pure*.view [
text-list data collect [
foreach commit github/list-commits 'red/red [
keep commit/commit/message
]
]
]Compiling to native code...
...compilation time : 53527 ms
...linking time : 641 ms
...output file size : 882176 bytes
...output file : C:\Projects\Red\programs\red-inspector\libRedRT.dll
...compilation time : 62 ms
Target: MSDOS
Compiling to native code...
*** Compilation Error: attempt to redefine existing function name: red/object/get-values
*** near: [332x1
#import ["libRedRT.dll" stdcall [
get-values: "red/object/get-values" [obj [red/red-object!] return: [red/cell!]]
get-values: "red/object/get-values" [obj [red-object!] return: [cell!]]
]]
]
> Terminated with exit code 1.convert-types allows there to be no type spec at all, but when such a routine is actually compiled, a compilation error occurs, presumably coming from the Red/System compiler. Wouldn't it be easy to allow no type spec and substitute any-type for that? OR, am I doing something wrong?false and true to be printed here:>> case [(probe equal? 1 2) [print "asd"] (probe equal? 1 1) [print "xyz"]] xyz
[red-value!] when the routine is called the first time (emit-routine). So if you never call the routine, its spec block will remain invalid. The following code compiles fine:r: routine [a][probe TYPE_OF(a)] r 123
convert-types, so that it will not error out if the routine is never called.argument: system/args-list + 1 home-dir: argument/item print-line ["Julia home dir: " home-dir]
c:\dev\GIT\Red>julia "c:\dev\Julia-0.5.2\bin\" Julia home dir: c:\dev\Julia-0.5.2\bin"
c:\dev\Julia-0.5.2\bin\ not c:\dev\Julia-0.5.2\bin"\" is treated as an escape sequence for double quote. I guess such rule should not be used on Windows. You can open a ticket for it.get-env doesn't seem to work correctly with a word! argument (but I'm not sure how it's supposed to work)>> env: 'temp == temp >> env2: "temp" == "temp" >> get-env temp *** Script Error: temp has no value *** Where: get-env *** Stack: >> get-env env == temp >> get-env env2 == "C:\Users\davidan\AppData\Local\Temp" >> get-env 'env2 *** Runtime Error 13: integer divide by zero *** at: 0041A295h
>> get-env 'temp *** Runtime Error 1: access violation *** at: 0041A2CBh
get-env temp where you are not passing a valid argument. Please open a ticket for it.--no-runtime, there was this https://github.com/red/red/issues/1772--no-runtime though. Maybe you are trying to compile Red files where the --no-runtime expects it to be R/S--no-runtime is used with Red source code?--no-runtime automatically applied to that step.--no-runtime--no-runtime to work for Red sources.>> o: make object! [ [ b: [aa 1 bb 2] [ on-change*: func [w o n] [ print "activated" ] [ o: make object! [oa: 1 ob: 2] [ c: 1 [ ] == make object! [... >> o/c: 1 activated == 1 >> o/b/bb: 4 == 4 >> o/o/ob: 4 == 4
on-change is triggered by changed values in the root object only. on-deep-change is what you want (though, IIRC, nested objects needs to be manually "owned" for now using modify).Red/System [] print "Hello world!"
--no-runtime results in *** Compilation Error: undefined symbol: print
Needs: 'View to header but the compilation breaks with error*** Compilation Error: invalid #call function name: face? *** in file: /Users/sony/Code/red/environment/console/console.red *** near: []
fakemac:red sony$ sudo red Password: PROGRAM ERROR: Invalid encapsulated data. fakemac:red sony$
sudo directly on a Rebol encapped executable, you need to wrap it in a shell script. Though, we have a generic solution for such issues that will be part of 0.6.4.sudo ./console worksalphabet: {AaBbCc}
replace alphabet #"a" 1
probe alphabet"1aBbCc"
replace is case-insensitivereplaceis function that uses find for matching. find supports /case refinement, so I think that replace should also support it.>> replace/case
*** Script Error: replace has no refinement called case
*** Where: replace
>> ? replace
USAGE:
REPLACE series pattern value
DESCRIPTION:
REPLACE is a function! value.
ARGUMENTS:
series [series!]
pattern
value
REFINEMENTS:
/all =>print-body: func [:foo] [probe second :foo] print-body print-body
[probe second :foo]
*** Script Error: second does not allow word! for its s argument *** Where: second
:foo in spec is equivalent to 'foo. Why is that?print-func: func [:foo] [probe get/any foo] print-func print-func
|> pipe operator. For now user is forced to use get-word! on calling side:|>: make op! func [x :f] [f x] ; :f could be 'f [1 2 3] |> :reverse |> :print
|>: make op! func [x :f] [f x] [1 2 3] |> reverse |> print
first, second and third correspond in Red respectively to words-of, body-of and spec-of.get-word! on calling side? Comparing with Rebol2:REBOL [] pipe: func [x :f] [f x] pipe [1 2 3] print
Red [] pipe: func [x 'f] [f x] pipe [1 2 3] :print
Red [
Config: [red-strict-check?: off]
]
#do [
unfold: function [
range [block!]
][
bit: make bitset! range
len: length? bit
str: make string! len
repeat i len [if find bit i [append str to char! i]]
return str
]
]
#macro alphabet: func [] [unfold [#"A" - #"Z"]]
probe alphabet"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
*** Red Compiler Internal Error: Script Error : Invalid argument: - *** Where: unfold *** Near: [bit: make bitset! range len: ]
/local words (i.e. has function):#macro whatever: func [/local some-word] []
*** Macro Error: invalid specification *** Where: [whatever: func [/local some-word]] *** Throw Error: no catch for throw: halt-request *** Where: throw *** Stack: expand-directives expand
#macro whatever: function [] [some-word:]
function in Red is equivalent to funct in Rebol 2. function in Rebol 2 takes 3 arguments the second being a list of local words.#macro whatever: func [/local some-word] [] seems like a bug to me.[ - ] bitset generation?function with just two args. For R2 it takes 3: FUNCTION spec vars bodyFunction is one function that is not Rebol compatible.function is redefined in the toolchain to match Red's definition, you can check it by compiling the following code:Red [] #do [probe :function]
*** Macro Error: invalid specificationerror looks like an issue with the preprocessor macro validation code.unfold as func just for sanity check but error still persist. Rebol2 actually supports charset generation, so now I'm confused :confused:charset wheel, and now error message is even more cryptic:Red []
#do [
charset: func [
range [block!]
/local
bs blk start bump
][
bs: make bitset! copy []
while [not tail? range] [
blk: head remove at take/part range 3 2
start: to integer! blk/1
bump: to integer! blk/2
while [start <= bump] [
bs/:start: on
start: start + 1
]
]
return bs
]
unfold: func [
range
/local
bit len str
][
bit: charset range
len: length? bit
str: make string! len
repeat i len [if find bit i [append str to char! i]]
return str
]
]
probe #do keep [unfold [#"A" - #"Z"]]*** Red Compiler Internal Error: Script Error : Invalid argument: '00000041 *** Where: charset *** Near: [start: to integer! blk/1 bump: ]
unfold for a while.Red []
#do [
unfold: func [
range [block!]
/local
index bump blk
][
to string! collect [
while [not tail? range] [
blk: head remove at take/part range 3 2
forall blk [poke blk 1 to integer! to char! blk/1]
set [index bump] blk
until [keep to char! index (index: index + 1) > bump]
]
]
]
]
view [text #do keep [unfold ["A" - "Z"]]]Red []
#do [
unfold: func [
range [block!]
/local
index bump blk
][
to string! collect [
while [not tail? range] [
blk: head remove at take/part range 3 2
forall blk [poke blk 1 to integer! blk/1]
set [index bump] blk
until [keep to char! index (index: index + 1) > bump]
]
]
]
]
view [text #do keep [unfold [#"A" - #"Z"]]]*** Preprocessor Error in #do *** Script Error : Invalid argument: '00000041 *** Where: [#do] *** Near: [forall blk [poke blk 1 to integer! blk/1] set [index bump] ]
string!s in range block and explicitly convert them to char! and then to integer!, while in the second case this conversion is avoided because I use chars! as usually. probe #do keep ["1 2 3"] ;== "1 2 3" probe #do keep [[1 2 3]] ;?? 1 ; crude workarounds probe load #do keep ["1 2 3"] ;== [1 2 3] probe #do keep [[[1 2 3]]] ;== [1 2 3]
/only refinement (i.e. #do keep/only) for such cases?|>: make op! func [x 'f] [f x] [1 2 3] |> :reverse |> :print
*** Compilation Error: invalid path value: intrinsics/func*
*** in file: <snip>
*** at line: 332
*** near: [
get-word/get ~reverse
intrinsics/func*
stack/unwind
get-word/get ~print
intrinsics/func*
stack/unwind
]&: :and |: :or ~: :complement
&: :and |: :or ~: :complement complement 100 and 200 or 300
&: :and |: :or ~: :complement ~ 100 & 200 | 300
*** Compilation Error: invalid path value: ops/&*
*** in file: <snip>
*** at line: 332
*** near: [
integer/push 200
ops/&*
stack/unwind
integer/push 300
ops/|*
stack/unwind
]bit-twiddling: context [
&: :and
|: :or
~: :complement
]
complement 100 and 200 or 300
do bind [~ 100 & 200 | 300] bit-twiddlingdate! type branch.unfold macro, |> weirdness, and bit-twiddling crash) are worthy and what exactly I should write in description :(Red [] context? 'context?
Compiling to native code...
*** Compilation Error: undefined symbol: red/natives/context?*
*** in file: <snip>
*** at line: 332
*** near: [
natives/context?* true
stack/unwind #user-code
]>> a: 1/1/0000 == 1-Jan-0000 >> b: 1/1/0001 == 1-Jan-1000 >> b/year == 1
context?error, did you compile in dev mode (using libRedRT) or in release mode? Worth a ticket for a deeper look anyway.#do [foo: does [1 % 1]] #macro make-some-foo: func [][foo] probe make-some-foo
...using libRedRT built on 6-Jul-2017/15:05:21+5:00 *** Red Compiler Internal Error: Script Error : % has no value *** Where: foo *** Near: [% 1]
% to mod works#do [foo: does [mod 1 1]] #macro make-some-foo: func [][foo] probe make-some-foo
% character alone is invalid syntax in Rebol, so you need to either use // or mod in that case.|> crash, it seems that binding block of code to some context fixes it (as with | & ~ shortcuts issue)|>: make op! func [x 'f][f x] do bind [[1 2 3] |> :reverse |> :print] system/words
system/words).>> block1: [12uifehwiguhig] *** Syntax Error: invalid integer! at "12uifehwiguhig]" *** Where: do *** Stack: load
time of a date to an integer!. Though doing so seems to adjust the time rather than set it. Shouldn't this raise an error as does Rebol?>> d: now == 7-Jul-2017/14:46:37+08:00 >> d/time: 1 == 1 >> d == 7-Jul-2017/6:46:01+08:00 >> d/time: -10 == -10 >> d == 6-Jul-2017/22:46:50+08:00
random on dates seems broken. to a negative time also appears to give incorrect results. Perhaps it should also raise an error?
text`/time. Rebol behaves the same (for same reasons)./time to an integer is fixed now.-24:00 will give you same time (0:00:00), but minus one day.date! (while it's all still fresh in my mind).date! documentation, this was the first thing I tried:>> d: 31/Dec/32767 == 7 >> d == 31-Dec-3276
set '& get 'and set '| get 'or
0.6.3 launch, right?entry: [a b c]
foreach :entry [1 2 3 4 5 6 7 8 9][
print [a * 2 b * 3 c * 4]
]2 6 12 8 15 24 14 24 36
...using libRedRT built on 6-Jul-2017/15:05:21+5:00 *** Red Compiler Internal Error: Script Error : add-symbol expected name argument of type: word *** Where: comp-foreach *** Near: [add-symbol word: pc/1 add-global word ]
while behavior, it always returns unset no matter what. probe while [true][break/return 42] ; unset vs. 42 i: 1 probe while [i < 5][i: i + 1] ; unset vs. 5
while loop in catch/throwprobe catch [while [true][throw 42]]
i: 1 probe catch [
while [i < 5][
i: i + 1
if i = 5 [throw i]
]
]>> d: 2016-11-23/23:57 == 23-Nov-2016/23:57:00 >> loop 6 [print d: d + 0:01] 23-Nov-2016/23:58:00 23-Nov-2016/23:59:00 24-Nov-2016 24-Nov-2016/0:01:00 24-Nov-2016/0:02:00 24-Nov-2016/0:03:00
>> d: 2013-11-23/0:00 == 23-Nov-2013/0:00 >> e: 2013-11-23 == 23-Nov-2013 >> d/date == 23-Nov-2013
date! docs suggest that any of the "ordinal" paths can be used with pick. However, trying to pick 12 (week) or 13 (isoweek) gives a script error:>> e: 2017-11-23/0:00 == 23-Nov-2017 >> pick e 12 *** Script Error: value out of range: 12 *** Where: pick *** Stack: >> pick e 13 *** Script Error: value out of range: 13 *** Where: pick *** Stack: >> e/12 == 47 >> e/13 == 47
>> f: 9999-12-24 == 24-Dec-9999 >> to integer! f == -1460864
/date accessor. :smile: represent calendar dates would be better?== 1-Jan-2017 >> d/month: -1 == -1 >> d == 1-Nov-2016 >> d/month: 1 == 1 >> d == 1-Jan-2016 >> d/month: 2 == 2 >> d == 1-Feb-2016 >> d: 31-jan-2017 == 31-Jan-2017 >> d/month: 2 == 2 >> d == 31-Feb-2017 >> d: 31-feb-2017 *** Script Error: cannot MAKE/TO date! from: [day month year] *** Where: do *** Stack: load
pick issue fixed.>> last-day-of-month: func [d][d/month: d/month + 1 d/day: 1 d - 1] == func [d][d/month: d/month + 1 d/day: 1 d - 1] >> last-day-of-month now == 31-Jul-2017/13:06:56+08:00
>> d: 1-jan-2017 == 1-Jan-2017 >> d/day: 32 == 32 >> d == 1-Feb-2017 >> d/day: -1 == -1 >> d == 30-Jan-2017
lisp >> d: 1-Feb-2017 == 1-Feb-2017 >> d/day: 1 == 1 >> d == 1-Feb-2017 >> d/day: 0 == 0 >> d == 31-Jan-2017
>> d: 2016-11-23/23:57 == 23-Nov-2016/23:57:00 >> loop 6 [print d: d + 0:01] 23-Nov-2016/23:58:00 23-Nov-2016/23:59:00 24-Nov-2016/0:00:00 24-Nov-2016/0:01:00 24-Nov-2016/0:02:00 24-Nov-2016/0:03:00 >> d/time: none == none >> d == 24-Nov-2016 >> loop 6 [print d: d + 0:01] 24-Nov-2016/0:01:00 24-Nov-2016/0:02:00 24-Nov-2016/0:03:00 24-Nov-2016/0:04:00 24-Nov-2016/0:05:00 24-Nov-2016/0:06:00
1-1-10000 *** Syntax Error: invalid date! at "10000" *** Where: do *** Stack: load 31-12-9999 + 1 ; 1-Jan-10000
-t Windows and press the button... the application quits:Red [Needs: 'View] view [ button "Press me" [print "pressed"] ]
view-test.red script does nothing when compiled with -t Windows and not -d.--test-- libWin32-1 FAILED**************
%lib-win32-test.reds fromlw1-len/int: 15
lw1-len/int: 16
get-computer-name, lwl-len/int had been set to 16).bass-test.red from Red/Code is not working and found strange behavior.... with this code:#define BASS_FETCH_OPT_NAMED_VALUE(type) [ pos: cmd + 1 if pos < tail [ value: either TYPE_OF(pos) = TYPE_WORD [_context/get as red-word! pos][pos] if TYPE_OF(value) = type [cmd: pos] ] ] #define BASS_FETCH_OPT_SETTINGS(blk ms) [ blk: null BASS_FETCH_OPT_NAMED_VALUE(TYPE_BLOCK) print-line [pos " " cmd " " blk] if pos = cmd [ blk: as red-block! value ] print-line ["blk: " blk] ]
028ED348 028ED338 00000000 blk: 029119A8
pos <> cmdBASS_FETCH_OPT_SETTINGS directly into the code. Simply pos = cmd is true even when the values are different.either returns a value in Red/System. So you will get some unpredictable results with:value: either TYPE_OF(pos) = TYPE_WORD [_context/get as red-word! pos][pos]
either can return a value (for setting a variable or returning from a funciton), but either should not be used nested in expressions otherwise.if/either is somehow corrupted... I had similar case... using:#define BASS_FETCH_OPT_NAMED_VALUE(type) [ pos: cmd + 1 print-line [(pos < tail) " " pos " < " tail] either pos < tail [ value: either TYPE_OF(pos) = TYPE_WORD [_context/get as red-word! pos][pos] print-line [(TYPE_OF(value) = type) " " TYPE_OF(value) " = " type] if TYPE_OF(value) = type [cmd: pos] ][ print-line "?" ] ]
true 0285D348 < 0285D368 ?
%system/compiler.r, at line 3885, just before compiler/run job src file, you can add a write %src.reds src and examine the output of the preprocessor.save %src.reds src (to have it readable :) but see nothing suspicious there.bass-test.red with version of Red from 04/03/2017, it is working I will try to find the last working commit. Later.value: either TYPE_OF(pos) = TYPE_WORD [_context/get as red-word! pos][pos]
either TYPE_OF(pos) = TYPE_WORD [value: _context/get as red-word! pos][value: pos]
bass.dll?request-dir/dir does not work properly if an argument is a string. A starting directory always is user`s home directory. My system is Windows 8.1request-file/file. Both internal funcs (OS-request-dir/OS-request-file) look like they may have been written for file support, and strings were added to the func spec later, without them being updated. They coerce file! values to OS-local format, but don't seem to prime pbuf if it's a string. -=== Red Compiler 0.6.3 ===- Compiling /mnt/Red/red/tests/source/runtime/unicode-test.red ... Compiling libRedRT... ...compilation time : 792 ms Compiling to native code... *** Compilation Error: invalid path value: image/encode *** in file: %environment/codecs/png.red *** in function: exec/ctx259~encode *** at line: 1 *** near: [as cell! image/encode img where IMAGE_PNG]
-=== Red Compiler 0.6.3 ===-
Compiling /mnt/Red/red/tests/source/runtime/tools-test.reds ...
Target: FreeBSD
Compiling to native code...
*** Compilation Error: #export directive requires a library compilation mode
*** in file: %start.reds
*** at line: 67
*** near: [
#export [environ __progname]
]-u, the compile completes fine, but then gives the same error you posted. Please open a ticket.view [
list: text-list data ["John" "Bob" "Alice"]
button "Add" [append list/data "Sue"]
button "Change" [lowercase list/data/(list/selected)]
]Red [] case []
Compiling to native code...
*** Compilation Error: datatype not allowed
*** in file: %<snip>
*** at line: 332
*** near: [none
either logic/true? none [stack/reset none/push-last]
stack/unwind #user-code
]my-ctx: context [
my-other-ctx: context [
f: func [c][
object [x: 100 * c y: 100 / c]
]
]
foo: func [c][my-other-ctx/f c]
]
probe my-ctx/foo 3
view []my-ctx/foo should always return object! and that's exactly what happening in interpreter:make object! [
x: 300
y: 33
]my-ctx/foo for some reason returns 3.with: func [
contexts [block!]
body [block!]
][
forall contexts [bind body reduce first contexts]
]
my-ctx*: context [
my-other-ctx: context [
f: func [c][
object [x: 100 * c y: 100 / c]
]
]
some-other-ctx: context [field: 'whatever] ;<-- if I'll comment out this line compiled app will silently crash
foo-body: with [some-other-ctx][my-other-ctx/f c]
foo: func [c] foo-body
]
probe my-ctx*/foo 3
view []object!, but once compiled probe returnsfunc [c][some-other-ctx]
my-ctx*/foo 3 call inside view block like this:view [do [probe my-ctx*/foo 3]]
object! in interpreter (as usual), and, uhm, object! in compiler, but not the one I expectedmake object! [
field: 'whatever
]x field of returned object! I'll get an error, since there's no x field! (because it's not *that* object) :(ctx: context [
ctx*: context [
ok?: func [x][yes]
]
foo: func [thing][
case [
not ctx*/ok? thing [return "UNNACEPTABLE!"]
]
]
]...using libRedRT built on 22-Jul-2017/7:13:40+5:00 *** Compilation Error: CASE is missing a value *** in file: <snip> *** near: []
ctx: context [
ctx*: context [
ok?: func [x][yes]
]
foo: func [thing][
if not ctx*/ok? thing [return "UNNACEPTABLE!"]
]
]...using libRedRT built on 22-Jul-2017/7:13:40+5:00 *** Compilation Error: expected a block for IF-BODY instead of word! value *** in file: <snip> *** near: [thing [return "UNNACEPTABLE!"]]
ok? moved out of inner context everything works fine.view [backdrop #itscrash]
*** Runtime Error 1: access violation *** at: 0042535Dh
view [
list: text-list data ["John" "Bob" "Alice"] select 1
button "Add" [append list/data "Sue"]
button "Change" [lowercase pick list/data list/selected]
]>> help system/version SYSTEM/VERSION is a tuple of value: 2.7.8.4.2 >> now == 25-Jul-2017/13:13:52+2:00 >>
--== Red 0.6.3 ==-- Type HELP for starting information. >> now == 25-Jul-2017/12:14:17+01:00 >>
foo: func [c][do [my-other-ctx/f c]] helps? In general, if there is a compiler error with function, that instead runs the function in an interpreterfunc exactly? I start to remember something among this lines in compiler vs. interpreted behavior...dodo [ straight after the Red header and ] at the end of your code, the whole program will be compiled to be interpreted. The compiler will still give you a single binary executable to run. When it runs the code will be interpreted by the Red runtime.wait issue confirmed, a recent regression, will be fixed in a few minutes.-c -r -t Windows app can't be launched - View window just never pops up.-c and -r are contradicting options, should be either one or the other. When compiled with -t Window, you give up on having a console, so any output attempt using print or probe will result in the app quitting. Or it could just be your AV preventing the executable from launching.-r is for compiling in release mode, so a self-contained exe.-r flag silently crashes (console window blinks for a second and disappears).exe on old Win XP machine and gotEntry point in procedure GetGestureInfo not found in DLL USER32.DLL
-c flag. Though I can try to compile without -t Windows... Edit: nope, still the same error.-c flag from VSCode produces working executable, compilation with other options (-o, -r, and -t Windows) doesn't work.exe compiled with -r -t Windows -o ... works *only if* all .red scripts are present in the same directory... is it because of do/expand workaround?WindowsXP compilation target.do the other .red script at runtime, if you include them it should work, though #include in Red is still limited for now.do/expand then #2910 pops up.do/expand [
#include %decoder.red
#include %injector.red
#include %gui.red
]do them instead?do/expand [#include ] does not work?do [do do ...] exe among all needed scriptsdo will load files at run-time, so the exe location matters.do/expand postpones their processing to run-time.do/expand?do/expand needed (or not?) because there's macrosdo. The compiler resolved macros already, do/expand will preprocess and evaluate the argument block at run-time, though, the compiler should have expanded the macros in the block before, unless there are hidden behind an include, and as #include is rather limited currently...1.0? Because, frankly, working with interpreted Red was *very* joyful experience, but then it comed to compilation... yikes, my arse still hurts :fire:do/expand, so far exe is trully self containted.#include capabilities, you are jumping right in the middle of uncharted behaviors. I don't think anybody tried such mix until now. Given how young is the preprocessor and the various compiler rough edges, you should be going there step by step, so we can identify bugs and limitations one by one and fix or workaround them.exe, otherwise whole project of mine is useless.include) let you bundle all your scripts into one for encapping. The downside, of course, is that then you need a main script to do the build. Not hard, but not as easy as just running interpreted. Here is where we can build tooling to help, but need to think about notations. With R2, I sometimes had multiple build scripts (bundle, encap, encap for distro on CD, build for IOS).do instances and handle them.red Red [] print unset ; doesn't work but prints error after eval next line (4 + 2) print 4 + 2
6 *** Script Error: unset does not allow unset! for its word argument *** Where: unset *** Stack:
>> print unset *** Script Error: unset is missing its word argument *** Where: unset *** Stack: >> print 4 + 2 6
unset expects argument so evaluation goes to the next thing which is print 4 + 2print [unset] was working fine>> probe print 1 1 unset >> unset unset *** Script Error: unset is missing its word argument *** Where: unset *** Stack:
s: reduce [:append 42] print type? s/1 ; incomplete line print [4]
probe, would catch sooner..42 is not a series?append, it evaluates to the function itself>> s: reduce [:append]
== [make action! [[
{Inserts value(s) at series tail; returns series head}
series [ser...
>> print type? s/1
*** Script Error: s/1 is missing its series argument
*** Where: type?
*** Stack:get-word! ;)blocks! of length 1. ? doesn't distinguish between.. no, you can't simply find the difference from console output. Found out there isn't a bug (probably)2910 ever again :(length? for blocks, if you have nested functionsdo block?make error! 100 silently crashes REPL. Bug/feature?text view layout/flags [] 'some-valid-flag
*** Script Error: cannot set none in path none *** Where: eval-set-path *** Stack: view layout eval-set-path
make error! 100 is also in comments to issue #2628layout, couldn't find anything related, currently filling a ticket.red repo?foo chokes up on bar arg maybe I should write SOME-TAG-IN-CAPS: FOO chokes up on BAR arg or vise versa? Same for content of the issue, I know that it should contain at least minimum code example, but anyway.TAG-IN-CAPS is usually left for WISH:, or maybe [VID] and/or [View].>> bs: make bitset! 1
== make bitset! #{00}
>> repeat c length? bs [print bs/:c]
false
false
false
false
false
false
false
false
>> b: [true false true]
== [true false true]
>> repeat x length? b [bs/:x: b/:x]
== true
>> repeat c length? bs [print bs/:c]
true
true
true
false
false
false
false
falsefalse.>> repeat x length? b [bs/:x: reduce b/:x] == true >> repeat c length? bs [print bs/:c] true false true false false false false false
make date! [1 2 3 4 5 6 4] ; 1-Feb-0003/4:05:06+04:00 make date! [1 2 3 4 5 6 5] *** Script Error: cannot MAKE/TO date! from: [1 2 3 4 5 6 5] *** Where: make *** Stack:
>> i: make image! 100x24
== make image! [100x24 #{
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFF
>> draw i [pen black fill-pen red box 1x1 99x23]
== make image! [100x24 #{
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFF
>> view [base i]123.0, it now returns 123:Red [] object [ to-float*: :system/words/to-float set 'to-float func [n][to-float* n] ] print to-float 123
-c and -r/proc/cpuinfo).#"^^..." instead of #"^...". Is this a consequence of the bootstrap toolchain using Rebol?>> #"^"
*** Syntax Error: invalid char! at {#"^^"}
*** Where: do
*** Stack: load
>> #"^8"
*** Syntax Error: invalid char! at {#"^^8"}
*** Where: do
*** Stack: load*** Syntax Error: Invalid issue! value
*** in file: /Users/peter/VMShare/Code/Red/test.red
*** line: 3
*** at: {"^^4"}
>>^4 within a *string* is accepted, i.e. in that case ^ quotes anything following it, which does not have a special meaning.res: either zero? res [-1][read-sz]
res: either zero? res [-1][1]
; allowed as a word?>> to-word ";" *** Syntax Error: invalid character in: ";" *** Where: to *** Stack: to-word >> to-word first ";" == ;
paren!? subshell: [ '( compound-list ') ]into can do thatahead paren! into ... to make sure you are not parsing content of a string, for examplecd>> to-red-file "C:\Program Files" == %/C/Program%20Files >> cd to-red-file "C:\Program Files" *** Access Error: cannot open: <snip> *** Where: do *** Stack: cd change-dir cause-error >> change-dir to-red-file "C:\Program Files" == %/C/Program%20Files/
>> set to-word first ";" 42 == 42 >> get to-word first ";" == 42 >> set to-word #";" 24 == 24 >> get to-word #";" == 24
>> set to-word #"{" 'left-brace
== left-brace
>> get to-word #"{"
== left-braceto word! works the same:>> set to word! #";" 42 == 42 >> get to word! #";" == 42
to function should also enforce it.>> set to-word first "1" 42 == 42 >> get to-word first "1" == 42 >>
to seems to accept any char:>> set to-word first "^/" 42 == 42 >> get to-word first "^/" == 42
to-word should be checking for a valid character before allowing the conversion. You can open a ticket for that.cd is not a shortcut for change-dir, it is meant to work as its system shell counterpart, so only works with literal values, and not with function calls (change-dir is there for that).shell dialect>> set to-word #" " 'space == space >> get get to-word get get to-word #" " == #" "
code: "v[t"
v: 'view
t: "text {One-letter-command mini-language!}"
set to-word #"[" 'to-block
reduce parse code [collect some [s: keep (get to-word first s) skip]]>> call/console {grep blah}grep waits for input in that case (when you don't pass in a file to process)~$ grep foo blah foo foo
>> call/console form reduce [{grep foo} newline 'blah newline 'foo #"^D"]text
probe collect [
foreach [l d] "a1b2" [
keep reduce [
subtract to integer! to char! l 1
to integer! form d
]
]
][96 1 97 2]. But logically identicalprobe collect [
foreach [l d] "a1b2" [
keep reduce [
-1 + to integer! to char! l
to integer! form d
]
]
][
96 1
97 2
]keep is probably adding them to make the block more readable. If you do not want them, you can remove them.-1?>> i: 11 == 11 >> if i > 10 [make error! "too big"] *** User Error: "too big" *** Where: ??? >> f: func [i][if i > 10 [make error! "too big"] print i] == func [i][if i > 10 [make error! "too big"] print i] >> f 11 11 >> f: func [i][if i > 10 [return make error! "too big"] print i] == func [i][if i > 10 [return make error! "too big"] print i] >> f 11 *** User Error: "too big" *** Where: ???
cause-error to make them hot. The console forms error info, so you see it that way:>> f: func [i][if i > 10 [e: make error! "too big"] print i] == func [i][if i > 10 [e: make error! "too big"] print i] >> f 11 11 >> e *** User Error: "too big" *** Where: ???
foreach v [] [] returns unset! on Red but none! on R2. Is it a bug / known issue or intentional?-1?form-ed by default when returned in the console. As this can be confusing, I guess we should change that to the mold-ed version (make error! [...]) rather.text
>> [<]
*** Syntax Error: invalid tag! at "<]"
*** Where: do
*** Stack: load
>> ?? <
<: make op! [[
{Returns TRUE if the first value is less than the second}
value1 [any-type!]
value2 [any-type!]
]]
>> [< ]
== [<]>> ? extend
USAGE:
EXTEND obj spec
DESCRIPTION:
Extend an object or map value with list of key and value pairs.
EXTEND is a native! value.
ARGUMENTS:
obj [object! map!]
spec [block! hash! map!]
REFINEMENTS:
/case => Use case-sensitive comparison./word!, thanks :)datatype!values using the construction syntax (#[...]), though, it's just partially implemented for now, and anyway looks uglier in code. ;-)refinement can have multiple arguments, is that by design?>> f: func [/a b c] [probe reduce [a b c]] == func [/a b c][probe reduce [a b c]] >> f/a 1 2 [true 1 2] == [true 1 2] >> f [false none none] == [false none none]
trace refinement in your code have only one argument - a function callback ;)>> f: func [/a b "this" c "that" /d] [probe reduce [a b c]]
== func [/a b "this" c "that" /d][probe reduce [a b c]]
>> ? f
USAGE:
F
DESCRIPTION:
F is a function! value.
REFINEMENTS:
/a =>
b "this".
c "that".
/d =>unset! falsey? It's sort of related to #2645, but I think there might be a stronger case for unset!. My concern is that I might be conflating it with none, and I don't totally understand the implications it would have with functions that return unset!. However this kind of thing seems confusing/surprising to me (I know that's not an argument in itself for doing it):>> unset 'w >> if (get/any 'w) [print w] *** Script Error: w has no value
unset!, with no clear right/wrong answer. It's a design choice. I don't think it's worth a wish ticket, but I doubt Doc wants to take time right now to document his thoughts in more detail. http://www.rebol.net/r3blogs/0318.html has some good thoughts in it, WRT the truthiness of unset! from Carl's perspective. There is a note about why it exists at all, which is important, and simple: https://github.com/red/red/wiki/Guru-Meditations#why-does-unset-exist. Maybe enabled.unset! as a true or false at all, it's kinda of a special value as @greggirwin pointed outwhile - in Red it's always unset!, but not in Rebol; so, in interpreter everything worked, but broke after compilation (since macros currently rely on R2)null, which needs to be differentiated between an invalid condition, and also a valid empty placeholder. I hadn't realized that redbol had a solution to that problem :smile: >> find reduce [function! op! action! native!] datatype! == [function! op! action! native!]
datatype! itself?>> find [function! op! action! native!] to-word datatype! == none >> find [function! op! action! native!] to-word function! == [function! op! action! native!]
function! as a word and function! as a datatype call it's calledcurry function which should allow one to bind arbitrary parameters of a functioncontext? or something, but this is too hackyreduce [my-object 1 2] <- is this a call to my-object/call with args 1 and 2 or do I want to reduce object and two integers?call method, how do I override it and get whole object?:my-object ?closure!.specialize func, right?specialize: function [fun [function!] defs [block!]][
spec: copy/deep spec-of :fun
body: copy/deep body-of :fun
foreach [arg value] defs [
arg: to word! form arg
pos: find spec arg
remove/part pos pick [2 1] block? pos/2
parse body rule: [some [change only arg value | into rule | skip]]
]
func spec body
]>> foo: func [x y][x + y] == func [x y][x + y] >> bar: specialize :foo [x: 5] == func [y][5 + y] >> bar 10 == 15 >> baz: specialize :bar [y: 5] == func [][5 + 5] >> baz == 10
curry function that gets another function with inner state, changes its state, and returns a new function, right?/state refinement it spits out its internal state, otherwise performs some function>> f/state
== make object! [
foo: true
bar: false
]
>> set in f/state 'foo 'poop
== poop
>> f/state
== make object! [
foo: 'poop
bar: false
]unset if ends with break. Those are all correct.use in his R2 work to create an anonymous context that returns a function. No way to get at the internal state, unless you add it as a refinement, like you do. That's clever./state type trick for aggregator funcs.curry things, but we can potentially uncurry them as well.probe something, because it's anonymousself in function's body :confused: >> read https://raw.githubusercontent.com/minimaxir/big-list-of-naughty-strings/master/blns.txt
*** Access Error: invalid UTF-8 encoding: #{EFBFBE0A}
*** Where: read
*** Stack:EFBF characters, including the UTF-8 [Byte order mark](https://www.wikiwand.com/en/Byte_order_mark#/Byte_order_marks_by_encoding) EFBBBFa: read/binary https://raw.githubusercontent.com/minimaxir/big-list-of-naughty-strings/master/blns.txt
b: find a #{EFBFBE}
a1: take/part a2: copy a index? b>> back back back back b ; UTF-8 Byte order mark
== #{
EFBBBF0A...
>> to-string a1 ; before
== {#^-Reserved Strings...
>> to-string at a2 3 ; after
== {^/^/#^-Unicode Symbolsview [
size 232x300
across
text "Font-Size 24" font-size 24
return
text "Font-Size 24" 230 font-size 24
] ask should check for such key shortcuts before processing themCtrl-3 is treated as "^[" (escape?), Ctrl-8 acts like backspace (dunno why I'm investigating this :D)Ctrl-<1 9 0> puts actual digits, though it works for all of them with numpadop!?>> a: #()
== #()
>> a/+: :+
== make op! [[
"Returns the sum of the two values"
value1 [number! char! pair! tuple! vector! time!]
value2 [number! char! pair! tuple! vector! time!]
return: [...
>> 1 a/+ 2
== 2to-block somehow evaluates it's argument:>> to-block "abc" == [abc] >> to-block "1" == [1] >> to-block "1/0" *** Syntax Error: invalid integer! at "1/0" *** Where: do *** Stack: to-block
collect returns nested blocksop! - I bashed my head over this and IMO it's easier just to store their function counterpartstext
>> a: #()
== #()
>> a/+: :add
== make action! [[
"Returns the sum of the two values"
value...
>> a/+ 1 2
== 3to cares about left arg as welladd thanks :D>> a/+: :+
== make op! [[
"Returns the sum of the two values"
value1 [n...
>> do reduce [1 a/+ 2]
*** Internal Error: reserved for future use (or not yet implemented)
*** Where: do
*** Stack:any matches also nothinghelp room btw? :Dany skip skipped to the end of the series and "]" failed the matchto-block somehow evaluates it's argument:load on a string value, before wrapping it in a block. In your case above, you specified a non-loadable string.do [...] wrapper for ensuring ++ is processed as a function call).>> foo/*** Script Error: w1 needs a value *** Where: set *** Stack: ask red-complete-input red-complete-path
>> first now/date *** Script Error: first does not allow date! for its s argument *** Where: first *** Stack: first >> second now/date *** Script Error: second does not allow date! for its s argument *** Where: second *** Stack: second
>> help first
USAGE:
FIRST s
DESCRIPTION:
Returns the first value in a series.
FIRST is a function! value.
ARGUMENTS:
s [series! tuple! pair! time!]first, second and etc should accept date! toored/bug room :D>> parse [1 2 3] [collect [keep collect any [keep number!]]] == [[1 2 3] [1 2 3]]
[[1 2 3]][1 2 3] in both caseskeep to affect the closest collect only, if possiblecollect/keep - it can't be used recursively because of this behaviourahead / into combo?>> parse [1 2 3][collect [keep ahead collect any [keep number!]]] == [[1 2 3]]
copy/deep the parse way :godmode: >> rule: [collect some [into rule | keep skip]] == [collect some [into rule | keep skip]] >> parse [a b [c d]] rule == [a b [c d]]
ahead basically says "first match this rule before doing anything else"[1 2 3] is collectedahead shouldn't adjust the inputifahead is needed there at allparse [1 2 3] [collect [keep collect any [keep number!]]]intoahead approachahead is like if, it matches some rule, but does not advance. If it matches, next rule is matched. If it does not, it backtracks.collect/keep twiceparse [1 2 3] [collect [keep ahead collect any [keep number!]]] it's: keep any numbers (innermost), collect them, then keep collected numbers (topmost), then collect themcollect appends to the result automatically and I don't need to do it second time?into?collect appends to the result automatically and I don't need to do it second time?keep is the cause of your troubles:>> parse [1 2 3] [collect [collect any [keep number!]]] == [[1 2 3]]
collect is enough there, unless you really want a nested block.collect automatically appends to its parent collect and the root one returns the block as result. This auto-appending feature works only on "naked" collect (not followed by any optional keyword, like set, into, after). So, you can control for every collect where the resulting block will go, either let it flow to his parent, or redirect it somewhere else.mal-map: [
collect set tmp-series [ "{" any [not "}" mal-expression] "}" ]
keep (to-map tmp-series)
]Red [] do %/home/max/projects/mal/red/mal-utils.red probe "worked" do probe to-file append system/options/path "mal-utils.red" probe "worked 2"
~/projects/mal/tests $ red ../red/step0_repl.red "worked" %/home/max/projects/mal/red/mal-utils.red *** Access Error: cannot open: %/home/max/projects/mal/red/mal-utils.red/ *** Where: do *** Stack: do-file change-dir cause-error
do works with the constant but fails with constructed one though it's exactly the same %/home/max/projects/mal/red/mal-utils.red/.>> spec-of :odd?
== [
{Returns true if the number has a remainder of 1 when divided by 2}
number [number! char! time!]
return: [number! char! time!]
]logic!even?. You can post a PR to fix it.hash! :)>> h == make hash! [] >> put h 1 2 == 2 >> h/1 == 1 >> h == make hash! [1 2]
>> h: make hash! [1 a 2 b] == make hash! [1 a 2 b] >> find h 1 == make hash! [1 a 2 b] >> find h 'a == make hash! [a 2 b] >> select h 1 == a >> about Red for Windows version 0.6.3 built 18-Sep-2017/15:48:26+05:00
red.exe you download from Red's web site is the toolchain, the console is precompiled on first run and put in a cache folder. To find the console binary: list-dir system/options/cache, then you can just make a copy of the latest console binary to your working folder, and use it to run your Red scripts interpreted.console binary is the compiled binary usually under %ProgramData%: C:\ProgramData\Red\console-2017-9-17-80805.exe red.exe and acts as the master, while the console is the slave. We should be able to reverse this relationship, and that will fix most of those cases, where the red binary is run by another app with redirected I/O.reactor! prototype with is "linkage" breaks entire reactive framework>> r1: make reactor! [x: 1]
== make object! [
x: 1
]
>> r2: make r1 [x: is [r1/x]]
*** Script Error: set-quiet does not allow set-word! for its word argument
*** Where: set-quiet
*** Stack:
>> ;-- boom
>> what: make reactor! [ever: 'really]
== make object! [
ever: 'really
]
>> nope: is [what/ever]
== really
>> what/ever: 'yeah
== yeah
>> nope
== reallyis is meant to work from inside a reactive object. The global context is not reactive. Use react for general reactions definition.make and : is [proto/] that wreaks hawoc I believe. Not sure what you meant about global context and react though: second example works perfectly fine if I'd skip the first part.text
>> what: make reactor! [ever: 'really]
== make object! [
ever: 'really
]
>> nope: is [what/ever]
== really
>> what/ever: 'yeah
== yeah
>> nope
== yeah>> r1: make reactor! [x: 1]
== make object! [
x: 1
]
>> r2: make r1 []
== make object! [
x: 1
]
>> react [r2/x: r1/x]
== [r2/x: r1/x]
>> r1/x: 100
== 100
>> r2/x
== 100>> parse/all "abc" [#"a" copy x any #"x" to end] x == none
>> parse "abc" [#"a" copy x any #"x" to end] x == ""
copy in Parse will copy the input if the sub-rule succeeds (any always succeeds) and even if the input does not advance (you get "" then). Same as in Rebol3. This makes copy more predictable.fib: function [n [float!]][
table: #(0.0 0.0 1.0 1.0)
either table/:n [
table/:n
][
extend table reduce [
n
add fib n - 1 fib n - 2
]
]
]
repeat i 100 [fib to float! i]
t: select body-of :fib 'table
probe select t 78.0
probe select t 79.08944394323791464.0 1.447233402467622e16
fib: function [i [integer!]][
table: [0.0 1.0]
either table/:i [
table/:i
][
append table reduce [add to float! fib i - 1 to float! fib i - 2]
]
]
repeat i 100 [fib i]
t: select body-of :fib 'table
probe pick t 78 + 1 ;; adjust for 0 being considered F0
probe pick t 79 + 11.44, floats are tricky :De16 at the end?map! vs. block! - I think I want to check if it could be modified inside a function's body (as with block!s without copy)pick [- +] negative? n like that, you should rewrite everything using if/else and... stop chuckling!scale](https://doc.red-lang.org/en/draw.html#_scale) accepts two number! arguments, but chokes up on percent!, though>> number! == make typeset! [integer! float! percent!]
integer! float! insteadpercent! into the number! typeset. Though in this case, having support for percents would be nice to have anyway.number! is used only for scale and matrix, I quickly checked matrix and it seems to support percent!Needs: View.mbp:red peter$ ./macView --== Red 0.6.3 ==-- Type HELP for starting information. >> Terminated: 15
View is called or is that a bug?view/no-wait [panel 300x300] responds differently to mouse actions between Windows and macOS. On both systems, it can be dragged around the screen. On Windows, it can be minimised and closed using the window buttons. On macOS, clicking on the minimise and close window buttons resulting in a spinning beach ball./no-wait difference as I only tried that today.Needs: View freezing ?>> [<tag>] == [<tag>] >> [< not tag >] == [< not tag >] >> type? first [<. not tag? >] == tag! >> <. not tag? > == <. not tag? > >> < what > *** Script Error: < operator is missing an argument *** Where: catch *** Stack: >> <| okay that's interesting |> == <| okay that's interesting |>
< followed by a whitespace will parse as a word. If you put anything else, it should parse as a tag (if you provide a closing >).lisp >> < what > *** Script Error: < operator is missing an argument *** Where: catch *** Stack: >> [< what >] == [< what >] >> length? [< what >] == 3 >> length? [<this is a tag >] == 1
< character.text also violate! violate!: does [violate!]
*** Runtime Error 1: access violation *** at: 00460102h
violate! was already defined before also is used (idk why I used it)wheel-event and down-event occur in same spot but values are different (Win10):>> view [base 100x100 on-wheel [probe compose [wheel: (event/offset)]] on-down [probe compose [down: (event/offset)]]] [wheel: 960x559] [down: 47x43]
on-wheel gives the offset w.r.t. upper left corner of entire screen (absolute coordinates) while on-down gives the offset w.r.t the window, as it should.>> make reactor! [probe words-of self] [on-change*] == make object! [ ] >> make object! [probe words-of self] [] == make object! []
reactor! isn't a separate datatype but a shortcut of some sort?>> foo: func [x [reactor!]][] *** Script Error: invalid type specifier: reactor! *** Where: func *** Stack:
on-change/on-deep-change callback funcs.mold/all to see them.words-of block, because it's, ehm, hiddenmold, because reflector funcs don't (currently) have refinements. If they're hidden via reflection, then there's no way to find them.>> parse z: [] [x: (insert x 'a) y: skip] == true >> parse z: [] [x: (insert x 'a) y: 'a end] == false >> x == [a] >> y == [a]
skip worksinsert continues match *after* the insertion>> parse z: [] [x: insert 'a] == true >> z == ['a]
insert keywordmold specific behavior in the docs.>> t: 1.2.3.4.5.6 == 1.2.3.4.5.6 >> make tuple! [1 2 3 4 5.8 6 7] == 1.2.3.4.5.6.7 >> t/5: 5.8 == 5.8 >> t == 1.2.3.4.255.6
>> do https://tinyurl.com/y9azl975 *** Access Error: cannot connect: https://tinyurl.com/y9azl975 reason: timeout *** Where: read *** Stack: do-file >> read http://google.com *** Access Error: cannot connect: http://google.com reason: timeout *** Where: read *** Stack:
fixme:winhttp:winhttp_request_QueryInterface interface {06f29373-5c5a-4b54-b025-6ef1bf8abf0e} not implemented
fixme:ole:CoCreateInstanceEx no instance created for interface {06f29373-5c5a-4b54-b025-6ef1bf8abf0e} of class {2087c2f4-2cef-4953-a8ab-66779b670495}, hres is 0x80004002
fixme:winhttp:winhttp_request_QueryInterface interface {06f29373-5c5a-4b54-b025-6ef1bf8abf0e} not implemented
fixme:ole:CoCreateInstanceEx no instance created for interface {06f29373-5c5a-4b54-b025-6ef1bf8abf0e} of class {2087c2f4-2cef-4953-a8ab-66779b670495}, hres is 0x80004002
fixme:winhttp:winhttp_request_QueryInterface interface {06f29373-5c5a-4b54-b025-6ef1bf8abf0e} not implemented
fixme:ole:CoCreateInstanceEx no instance created for interface {06f29373-5c5a-4b54-b025-6ef1bf8abf0e} of class {2087c2f4-2cef-4953-a8ab-66779b670495}, hres is 0x80004002do https://tinyurl.com/y9azl975op! doesn't allow to pass unevaluated operators?>> bar: make op! func ['left 'right][] == make op! [['left 'right]] >> foo bar baz *** Script Error: foo has no value *** Where: bar *** Stack:
*** Script Error: make-bge-base64 has no value *** Where: encoding *** Stack: context context
do/expand [...] block, it works (in fact it gives another error, but that's expected). Any ideas? I believe it worked roughly 2 weeks ago without a fuss.>> parse [set-word:] [quote set-word:] == true >> parse [set-word:] [quote set-word] == true >> parse [set-word:] [quote :set-word] == true >> parse [set-word:] [quote :set-word]
ahead set-word! quote set-word will do, but still*** Runtime Error err:seh:raise_exception Unhandled exception code c0000005 flags 0 addr 0x4161e6
ahead, and boom:*** Red Compiler Internal Error: Script Error : ahead has no value *** Where: expand *** Near: [parse code rule: [
ahead in his Parse dialect.ahead already, no clue regarding make-bge-base64 and bugged executable is dead, just checked on Win10inc: func [x][x + 1] and I want to build macro from that function or make it usable from macro, I should copypaste it either inside #do [...] or in #macro inc: ... directive, but it would be nice if I could just set some flag in *that* function (e.g. inc: func [[macro] x][x + 1] instead of copypasting everything by hand. I have no idea how Red could distinguish between between macro call and function call though :D Also, I whish I could separate my macros (and execution context) in dedicated file(s) and just #include it anythere I need them instead of copypasting their definitions (and #do [...] context).parse implementation.#](http://wiki.c2.com/?ThreeStarProgrammer) programmer :^)parse doesn't havecollect/keep keywords either? This could explain why compiled exe is dead, though, why it didn't spit compiler internal error as with ahead in this case?collect/keep support, yes. If you can make a short version that reproduces the crash, you can put it in a new ticket for investigation.text Red [] #macro answer: func [][42] a: answer
>> do %scratchpad.red *** Script Error: answer has no value *** Where: a *** Stack:
text
Red []
do/expand [
#macro answer: func [][42]
c: answer
]>> do %scratchpad.red == 42
do/expand wrapping>> do %scratchpad.red *** Script Error: answer has no value *** Where: a *** Stack: do-file >> do load %scratchpad.red == 42 >> do %scratchpad.red == 42
do on file! will call internally [this high-level function](https://github.com/red/red/blob/master/environment/functions.red#L835). As you can see on line 840, it calls expand-directives on the loaded file.text
>> do expand-directives load {#macro answer: func [][42] a: answer}
*** Script Error: answer has no value
*** Where: answer
*** Stack:expand-directives.expand](https://github.com/red/red/blob/master/utils/preprocessor.r#L271)register-macro](https://github.com/red/red/blob/master/utils/preprocessor.r#L353) goes nuts and doesn't register answer as a macro?>> preprocessor/macros
== ['answer
(change/part s do-macro 'answer s 0 1) :s
]do-macro is guilty?parse matching of any-words?about displays the build date of the cached console executable, rather than the date that red.exe was built. Is there a rationale for doing that? For example, from different runs of Red.exe located in my Downloads folder after clearing the cache:>> about Red for Windows version 0.6.3 built 29-Sep-2017/13:51:12-07:00 >> system/options/boot == "C:\ProgramData\Red\gui-console-2017-8-3-49893.exe" >> about Red for Windows version 0.6.3 built 4-Oct-2017/11:24:09-07:00 >> system/options/boot == "C:\ProgramData\Red\gui-console-2017-8-3-49893.exe"
>git log -n 1
commit 87e85d10a78c4aeb1e2bdc77de4c4c402a02f7c7
Author: Nenad Rakocevic <nr@red-lang.org>
Date: Wed Oct 4 21:20:58 2017 +0800
FIX: minor fix in the compilation output display.
>git describe
v0.6.3-235-g87e85d1
>git log -n 1 --pretty=format:%h
87e85d1>> call/output "git log -n 1 --pretty=format:^"[short: {%h} long: {%H} date: %aI]^"" :out commit: load out
== [short: "87e85d1" long: "87e85d10a78c4aeb1e2bdc77de4c4c402a02f7c7" date: 4-Oct-2017/21:20:58+08:00]git-commit?: function [
"Gets the latest (HEAD) commit hash from the current git repo"
][
path: system/options/path
; look for the root of the git repo
while [not exists? dirize path/.git][
path: clean-path path/..
if not exists? path [cause-error 'user 'message ["Could not find .git directory; this does not appear to be a Git repository"]]
]
; HEAD will either contain the hash of the latest commit (detached head) or a reference to the current branch file which contains it.
; i.e: "ref: refs/heads/master" which indicates the hash is in .git/refs/heads/master
head: read path/.git/HEAD
if find head "ref:" [
ref: load head
head: read path/.git/(ref/ref)
]
trim/lines head
]context processes a call to return in the spec block. It returns the argument value of the called return instead of the object.>> o: context [x: 5 return 2 + x] == 7 >> probe o 7 == 7
return:>> o: context [x: 5 return 2 + x]
>> context [x: 5 return 2 + x]
>> probe o
make object! [
x: 5
]make object! (all code after return 2 + x is not evaluated). R3 behaves the same as Red.context were a macro instead of a function, I supppose...max@max-virtualbox ~/projects/typed $ strace red
execve("/home/max/bin/red", ["red"], [/* 62 vars */]) = 0
strace: [ Process PID=588 runs in 32 bit mode. ]
brk(NULL) = 0x9a4e000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xf7781000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=141957, ...}) = 0
mmap2(NULL, 141957, PROT_READ, MAP_PRIVATE, 3, 0) = 0xf775e000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/i386-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\220E\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=341948, ...}) = 0
mmap2(NULL, 344144, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xf7709000
mmap2(0xf775c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x52000) = 0xf775c000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/i386-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0000\n\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=13828, ...}) = 0
mmap2(NULL, 16488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xf7704000
mmap2(0xf7707000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0xf7707000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/i386-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\320\207\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1786484, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xf77a8000
mmap2(NULL, 1792540, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xf754e000
mprotect(0xf76fd000, 4096, PROT_NONE) = 0
mmap2(0xf76fe000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1af000) = 0xf76fe000
mmap2(0xf7701000, 10780, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xf7701000
close(3) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xf754d000
set_thread_area({entry_number:-1, base_addr:0xf754d700, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 (entry_number:12)
mprotect(0xf76fe000, 8192, PROT_READ) = 0
mprotect(0xf7707000, 4096, PROT_READ) = 0
mprotect(0xf775c000, 4096, PROT_READ) = 0
mprotect(0xf77a9000, 4096, PROT_READ) = 0
munmap(0xf775e000, 141957) = 0
rt_sigaction(SIGCONT, {0x80a2cb0, [CONT], SA_RESTART}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGTSTP, {0x80a3150, [TSTP], SA_RESTART}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGINT, {0x80a4ad0, [INT], SA_RESTART}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGTERM, {0x80a4ad0, [TERM], SA_RESTART}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGHUP, {0x80a4ad0, [HUP], SA_RESTART}, {SIG_DFL, [], 0}, 8) = 0
brk(NULL) = 0x9a4e000
brk(0x9a71000) = 0x9a71000
mmap2(NULL, 528384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xf74cc000
mmap2(NULL, 528384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xf744b000
brk(0x9a94000) = 0x9a94000
brk(0x9ab5000) = 0x9ab5000
brk(0x9ad6000) = 0x9ad6000
gettimeofday({2787310729019563, -35154101159329788}, NULL) = 0
open("/etc/localtime", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\16\0\0\0\16\0\0\0\0"..., 4096) = 2943
_llseek(3, -28, [2915], SEEK_CUR) = 0
read(3, "\nCET-1CEST,M3.5.0,M10.5.0/3\n", 4096) = 28
close(3) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
brk(0x9af7000) = 0x9af7000
getcwd("/home/max/projects/typed", 50) = 25
brk(0x9b1a000) = 0x9b1a000
brk(0x9b17000) = 0x9b17000
brk(0x9b16000) = 0x9b16000
gettimeofday({2815661808140459, -35152997360919260}, NULL) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/home/max/projects/typed/none", 0xff831050) = -1 ENOENT (No such file or directory)
stat64("/usr/local/bin/netscape", 0xff831050) = -1 ENOENT (No such file or directory)
stat64("/usr/bin/netscape", 0xff831050) = -1 ENOENT (No such file or directory)
gettimeofday({2822280352743595, -35152997360919260}, NULL) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
gettimeofday({2825402793967787, -35152997360919260}, NULL) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
gettimeofday({2828649789243563, -35152997360919260}, NULL) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
gettimeofday({2832712828305579, -35152997360919260}, NULL) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
gettimeofday({2844412319219883, -35152997360919260}, NULL) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
gettimeofday({2848578437497003, -35152997360919260}, NULL) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
gettimeofday({2851151122907307, -35152997360919260}, NULL) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
gettimeofday({2853530534789291, -35152997360919260}, NULL) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
gettimeofday({2855343010988203, -35152997360919260}, NULL) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
gettimeofday({2858534171689131, -35152997360919260}, NULL) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2943, ...}) = 0
getpeername(0, 0xff831d74, 0xff831d70) = -1 ENOTSOCK (Socket operation on non-socket)
open("/home/max/license.key", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/max/projects/typed/license.key", O_RDONLY) = -1 ENOENT (No such file or directory)
mmap2(NULL, 790528, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xf738a000
open("/usr/bin/strace", O_RDONLY) = 3
lseek(3, 464260, SEEK_SET) = 464260
read(3, "H\211\373\350\24\357\376\377H\213s H\211\337\350\30\375\377\377H\215=u\306\0\0\350lr\377\377"..., 116) = 116
read(3, "\30\306\0\0\350\17r\377\377H\213s0H\215\25\226O\0\0H\215=\315\303\"\0\350(\346\377\377"..., 66) = 66
read(3, "d$\1dH\213\4%(\0\0\0H\211D$\0301\300\350\276q\377\377\17\266\34$L\215l$"..., 785638) = 402038
close(3) = 0
mmap2(NULL, 1032675328, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb9ab4000
write(1, "** Script Error: ", 17** Script Error: ) = 17
write(1, "Invalid compressed data - proble"..., 37Invalid compressed data - problem: -3) = 37
write(1, "\n", 1
) = 1
write(1, "** Near: ", 9** Near: ) = 9
write(1, "script: decapsulate \nif none? sc"..., 36script: decapsulate
if none? script) = 36
write(1, "\n", 1
) = 1
exit_group(0) = ?
+++ exited with 0 +++open("/home/max/license.key", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/max/projects/typed/license.key", O_RDONLY) = -1 ENOENT (No such file or directory)>> typed [x z: x] *** Runtime Error 1: access violation *** at: 0806D8DBh max@max-virtualbox ~/projects/typed $
probe expand-directives [
#macro [ahead set-word! quote lookup-table block!] func [[manual] s e][
s/2: reverse s/2
e
]
lookup-table: [<1> 2 3 <4> 5 6]
][
lookup-table: [<1> 2 3 <4> 5 6]
][6 5 <4> 3 2 <1>]text
probe expand-directives [
#macro [ahead set-word! quote lookup-table block!] func [[manual] s e][
s/2: reduce [reverse s/2]
e
]
lookup-table: [<1> 2 3 <4> 5 6]
][
lookup-table: [[[6 5 <4> 3 2 <1>]]]
]expand-directives causes block to be preprocessed second timeahead having no value :(expand-directives invokes the preprocessor.-c, because of R2 limitations, and -e aint do the trick-e is experimental and may be replaced by a different command-line syntax. Actually, the compiler's preprocessor will still be invoked on the source code, even in that encapped mode. Such behavior could be blocked, but it then defeats the purpose of macros in Red, which are a compile-time optimisation. Using macros in interpreted code is useless, as you can do the preprocessing in the code itself without any external framework. The only reason macros are resolved in the interpreter is for compatibility with compiled code. You really don't need them otherwise. That's why they never made it in Rebol after two decades of usage, it's just useless for an interpreted homoiconic language.-e is my saviortext ./test *** Script Error: path none is not valid for none! type *** Where: eval-path *** Stack:
list-dir purpose's is to print a list of files inside the console. Therefore, it relies on system/console/size for that, but the console is not there when you compile the script. What is the use-case for using list-dir in a compiled script?Help also uses the system console size. Maybe we could standardize on a default if that isn't there.list-dir came about when writing tests for environment/functions.redin which it is defined. If it is a console only function, wouldn't it be better in a file under in environment/console/?list-dir, namely ls dir and ll were already in console/engine.red./all. After making the block longer, it doesn't pass both params...>> comp: func [a b][probe reduce [a b] probe either a/2 = b/2 [a/1 < b/1] [a/2 > b/2]] == func [a b][probe reduce [a b] probe either a/2 = b/2 [a/1 < b/1] [a/2 > b/2]] >> sort/all/skip/compare [#"b" 1 #"a" 1 #"d" 1 #"e" 2 #"c" 2 #"f" 2 #"g" 2] 2 :comp [[#"a" 1] [#"b" 1]] true [[#"d" 1] [#"b" 1]] false [[#"e" 2] [#"d" 1]] true (snip) == [#"c" 2 #"e" 2 #"f" 2 #"g" 2 #"a" 1 #"b" 1 #"d" 1] >> sort/all/skip/compare [#"b" 1 #"a" 1 #"d" 1 #"e" 2 #"c" 2 #"f" 2 #"g" 2 #"h" 1] 2 :comp [#"c" #"b"] *** Script Error: path a/2 is not valid for char! type *** Where: = *** Stack: probe
Red [] #system [ #call [probe 1] ]
*** Runtime Error 1: access violation *** at: A1742F52h
#call does not do any boxing/unboxing of the argument values. In the above code, you are passing a red-value! pointer of value 1, causing the crash. You need to provide valid Red values (pointers to red-! structs).text in the first line it works, but with text there's no, well, text>> text: "test" == "test" >> view [panel [text with [text: text]]]
text in that example. That is, it works without defining text, because text is in the working context already.>> view [panel [text with [text: probe text]]] none
with block is binded to current face>> blk: [23 #"g" 56 11 #"8"] == [23 #"g" 56 11 #"8"] >> find blk #"8" == [56 11 #"8"]
find:>> to-integer #"8" == 56
[#"8"]>> find blk #"g" == [#"g" 56 11 #"8"] >> to-integer #"g" == 103 >> insert blk 103 == [23 #"g" 56 11 #"8"] >> find blk #"g" == [103 23 #"g" 56 11 #"8"]
find/case, but I think it is more bug than feature.any [bug? not intended? I'm-doing-something-wrong?]>> ? bind
USAGE:
BIND word context
DESCRIPTION:
BIND is a native! value.
ARGUMENTS:
word [block! any-word!]
context [any-word! any-object! function!]
REFINEMENTS:
/copy =>
RETURNS:
[block! any-word!]
>> do bind [x] has [x][x: 1]
*** Script Error: x is not in the specified context
*** Where: do
*** Stack:>> fn: has [x][x: 1] == func [/local x][x: 1] >> context? first bind [x] :fn == func [/local x][x: 1] >> same? :fn context? first bind [x] :fn == true
[x] is evaluated. But the error message is not very accurate (it was copied from Rebol3), so it probably needs to be changed to something like "context for x is not available".[x] is bounded, but its context is missing? That's interesting, and how one can evaluate [x] "in parallel" with function evaluation?>> foo: has [x][x: 'cool bar] == func [/local x][x: 'cool bar] >> bar: does [do bind [x] :foo] == func [][do bind [x] :foo] >> foo == cool
text >> foo: has [x /bar][if bar [return do bind [x] :foo] x: 'cool foo/bar] == func [/local x /bar][if bar [return do bind [x] :foo] x: 'cool foo/bar] >> foo == cool
>> foo: has [x /bar][if bar [return do block] x: 'cool foo/bar] == func [/local x /bar][if bar [return do block] x: 'cool foo/bar] >> block: [do bind [x] :foo] == [do bind [x] :foo] >> do block *** Script Error: x is not in the specified context *** Where: do *** Stack: >> foo == cool >> do block *** Script Error: x is not in the specified context *** Where: do *** Stack:
length? species that the argument must a series. However, length? currently accepts a map! and returns the number of entries as its length. length? does not accept an object!.length? to work on map!s?map!s and object!s is trivial with length? words-of, is it necessary for length? to work directly on map!s?words-of, though that is more much resource-consuming, but also you rarely need it, that might not really matter in practice. As map! is more object-like than series-like, it would make sense to support objects too then if we keep it for maps. So I'm undecided on that. words-of/values-of in conjunction with it, what do you use it for? Perhaps useful when you only need to know the length ("There are 19 items in X"), but you can't iterate or pick with it.text
partition: function [elems [block!] group [integer!]][
parse elems [
collect some [keep group skip | [collect keep to end]]
]
]
probe partition [1 2 3 4 5 6 7 8 9] 2*** Runtime Error 1: access violation *** at: 0805B384h
to keyword which seems to throw parse into an infinite loop.profile setups (see [here](https://gitter.im/red/help?at=5a0aad6aba39a53f1a9953a0)):profile/show/count collect [
repeat i samples [
keep/only compose [
partition (to word! rejoin ['elems i]) group]
]
] 100*** Math Error: math or number overflow *** Where: - *** Stack: profile collect
1000*** Runtime Error 1: access violation *** at: F76C5D60h
Red [ Needs: View ] ;system/view/auto-sync?: false a: make face! [type: 'base color: red offset: 120x120 size: 50x50] b: make face! [type: 'base size: 50x50] win: make face! [ type: 'window size: 400x400 pane: reduce [a] actors: object [ on-down: function [face event] [ append face/pane make b [color: random white offset: random 150x150] move find/same win/pane a tail win/pane show win ; <<< crashes if auto-sync is OFF! ] ] ] view win
on-down: function [face event] [ append face/pane make b [color: random white offset: random 150x150] show win ; this prevents the crash move find/same win/pane a tail win/pane show win ]
>> x: 1% while [x < 10%][x: x + 1%] >> x == 11%
do can automatically load string! value, I expected it to return "foo".>> foo: 'bar == bar >> do "foo" == bar
>> do "11 + 2" == 13 >> do next "11 + 2" == 3
set-word! syntax on everything that starts with <?>> <: 1 *** Syntax Error: invalid tag! at "<: 1" *** Where: do *** Stack: load
>> to-date to-integer 1-Jan-1970/0:00:01 == 1-Jan-1970/0:00:01 >> to-date to-integer 11-9-1561/4:35:13 == 1-Jan-1970/0:00:01
do strings, it's one of those things we want to be careful of. doing untrusted blocks.>> m: #(a: 1 b: [2])
== #(
a: 1
b: [2]
)
>> mm: copy m
== #(
a: 1
b: [2]
)
>> mmm: copy/deep m
== #(
a: 1
b: [2]
)
>> same? m/b mm/b
== false ; should be true
>> same? m/b mmm/b
== false
>> same? mm/b mmm/b
== true ; should be falsecopy to me:>> m: #(a: 1 b: [2])
== #(
a: 1
b: [2]
)
>> mm: copy m
== #(
a: 1
b: [2]
)
>> same? mm/b m/b
== true
>> mmm: copy/deep m
== #(
a: 1
b: [2]
)
>> same? mm/b m/b
== false
>> same? mm/b mmm/b
== truetest: make face! [ type: 'base myfunc: does [ 'nothing ] ] *** Script Error: old has no value *** Where: series? *** Stack: series?
make object! [ label: none parent: none root: does [ either self/root? [self][ first self/ancestors ] ] children: copy [] siblings: does [ exclude parent/children reduce [self] ] ; NB! needs to be copied as `descendants-list: copy node/descendants` ; otherwise crashes descendants: func [/into list][ list: any [list copy []] if not empty? children [ append list copy children foreach child children [ child/descendants/into list ] ] copy list ] ; NB! needs to be copied `ancestors-list: copy node/ancestors` ; otherwise crashes ancestors: has [list ancestor][ list: copy [] ancestor: parent while [ancestor][ insert list ancestor ancestor: ancestor/parent ] copy list ] root?: does [not to-logic parent] leaf?: does [empty? children] branch?: does [not leaf?] external?: does [leaf?] internal?: does [branch?] ; e.g. node/count/condition node/children 'internal? count: func [what /condition cond /local n][ either condition [ n: 0 forall what [if what/1/:cond [n: n + 1]] n ][ length? what ] ] degree: does [length? children] depth: does [length? ancestors] level: does [depth + 1] set 'node func [label parent /local me my][ me: my: make object! self my/label: copy label if parent [ my/parent: parent append parent/children me ] me ] ] n1: node "1" none n2: node "2" n1 n3: node "3" n2 n4: node "4" n2 n5: node "5" n3 n6: node "6" n4 n7: node "7" n4 n8: node "8" n7
>> length? n1/descendants == 7 >> length? n8/ancestors == 4 >> foreach d copy n1/descendants [probe d/label] "2" "3" "4" "5" "6" "7" "8" == "8" >> length? n7/ancestors == 3 >> foreach d copy n7/ancestors [probe d/label] "1" "2" "4" == "4"
copy here? Te result is copied already:descendants: func [/into list][ list: any [list copy []] if not empty? children [ append list copy children foreach child children [ child/descendants/into list ] ] copy list ] ancestors: has [list ancestor][ list: copy [] ancestor: parent while [ancestor][ insert list ancestor ancestor: ancestor/parent ] copy list ]
copy results in Error:>> foreach d n1/descendants [probe d/label] *** Script Error: invalid argument: make object! [label: "2" parent: make object! [label: "1" ...
copy (d: n1/descendants) crashes the console, while d: copy n1/descendants works well.foreach accessing the underlying the func rather than the result? >> n1/descendants/1 *** Script Error: descendants has no refinement called 1 *** Where: descendants *** Stack:
>> d: copy n1/descendants
== [make object! [
label: "2"
parent: make object! [
label: "1"
parent: none
root: fu...
>> d/1
== make object! [
label: "2"
parent: make object! [
label: "1"
parent: none
root: fun...foreach d probe n1/descendants [d/label] Shoot. Console just vanished while experimenting.des: n1/descendants dupes it.copyconsistently crashes the console. foreach sets a word each time, so they may have a related issue.me: my: make object! self doesn't fix it.a: copy [] same? copy a a ;== false ;But: same? copy n1/descendants n1/descendants ;== true same? copy n2/ancestors n2/ancestors ;== true ;But also: same? a copy a ;== false ;And: same? n1/descendants copy n1/descendants ;== false same? n2/ancestors copy n2/ancestors ;== false
n: object [l: none x: none asc: has [a l][l: copy [] a: x while [a][insert l a a: a/x] copy l]] n1: make n [l: "1" x: none] n2: make n [l: "2" x: n1] foreach y n2/asc [probe y/l] *** Script Error: invalid argument: make object! [l: "1" x: none asc: func [/local a l][l: copy [] a: x while [a] [insert l a a: a/x] copy l]] *** Where: foreach *** Stack: >> type? n2/asc == block! >> length? n2/asc == 1
>> foreach y copy n2/asc [probe y/l] "1" == "1" >> foreach y to-block n2/asc [probe y/l] "1" == "1"
n: object [l: none x: none] asc: func [n /local a l][l: copy [] a: n/x while [a][insert l a a: a/x] copy l] n1: make n [l: "1" x: none] n2: make n [l: "2" x: n1] >> foreach y asc n2 [probe y/l] "1" == "1"
>> m: object [asc: func [n /local a l][l: copy [] a: n/x while [a][insert l a a: a/x] copy l]]
== make object! [
asc: func [n /local a l][l: copy [] a: n/x while [a] [insert l a a: a/x] copy l]
]
>> foreach y m/asc n2 [probe y/l]
*** Script Error: invalid argument: make object! [l: "1" x: none]
*** Where: foreach
*** Stack:bang: n2/asc it kills the process. Please file a ticket.view make face! [ type: 'window color: red size: 100x100 f1: does [f2] f2: does [print "ok"] ] ; *** Script Error: f2 has no value
ok printed 3 times for below code:view make face! [ type: 'window color: red size: 100x100 f1: does [print "ok"] f1 ] ;ok ;ok ;ok
make face! [ type: 'base size: 100x100 f1: does [print "ok"] ] ;ok ;ok
*** Script Error: old has no value issue if system/view/debug? trueforever [[][reduce []]
*** Syntax Error: invalid value at "]" *** Where: do *** Stack: load
text >> parse ["1" "2"][some [copy match string!]] == true >> match == ["2"]
"2"set then.break doesn't reset series internal pointer to head when used in forall, is this behavior by design?>> s: "12345" forall s [all [s/1 = #"3" break]] s == "345"
>> s: "12345" forall s [all [s/1 = #"3" also s: head s break]] s == "12345"
>> to-float "1e-18" == 0.0 >> zero? to-float "1e-18" == false >> 5 * to-float "1e-18" == 0.0
1 + 2 = 3.0000000000000000000001dtoa() port in R/S.parse.reds and thought that case is some undocumented keyword (if so, what is it for?), butparse [][case]
*** Runtime Error 1: access violation *** at: F76D1FFCh
>> parse "aaA" [some #"a"] == true >> parse/case "aaA" [some #"a"] == false
/case refinement, but [this one](https://github.com/red/red/blob/master/runtime/parse.reds#L139) seems to be actual rule>> foo: func ['a [any-type!] 'b [any-type!]][probe :a probe :b] == func ['a [any-type!] 'b [any-type!]][probe :a probe :b] >> foo unset unset >> foo 1 1 unset >> foo 1 2 1 2 == 2
unset pops up, and it won't work if arguments aren't quoted and unset! is not listed in typeset (here its any-type!, so unset values are allowed)do [] block.f [random number of args] is much easier.append to a list56 n 57 p 58 f 59 a 60 z 61 y 62 US 2 survey 3 geodetic 4 Zena 3 Duna 4
forall while iterating over a series which is a part of context>> insert body-of :?? [print "!!!"]
== [
prin mold :value
prin ": "
print either value? :value [mold get/any :value] ["unset!"]
]
>> ?? a
a: unset!
>> ?? b
b: unset!
>> ?? ??
??: func [
"Prints a word and the value it refers to (molded)"
'value [word! path!]
][print "!!!"
prin mold :value
prin ": "
print either value? :value [mold get/any :value] ["unset!"]
]?? is updated but it ignores inserted commandstext
>> append body-of :rejoin [print "all rejoined, yay!"]
== [
if empty? block: reduce block [return block]
append either series? first block [copy first block] [...
>> rejoin [1 2 3]
== "1 2 3"probe res
probe next res
probe type? res
probe length? res
res: next res
probe res
probe type? res
forall res [[kg] none block! 1 none none! *** Script Error: forall does not allow none! for its 'word argument *** Where: forall *** Stack:
next somewhere?replace t: %a.b find/last t %. %.c ; %a.c
replace t: %a.b find/last t %. %.c ; %a.c.b
>> #"a" = 97 == true
text
>> ? ==
USAGE:
value1 == value2
DESCRIPTION:
Returns TRUE if two values are equal, and also the same datatype.
== is an op! value.
ARGUMENTS:
value1 [any-type!]
value2 [any-type!]select/case I see :)abcbca ?^, so I doubt it would be accepted.read/lines/escape %file #"\" ?>> 604800.0 / 86400.0 == 7.0 >> units/graph/week/base-unit-value / units/graph/day/base-unit-value == 1.0 >> units/graph/week/base-unit-value == 604800.0 >> units/graph/day/base-unit-value == 86400.0 >> units/graph/week/base-unit-value / units/graph/day/base-unit-value == 1.0
base-unit-value is a functionunit: object [
; value: 1
type: 'unit
conversions: none
base-unit: none
init: does [
conversions: make map! []
]
base-unit-value: does [
if base-unit [ select/case conversions base-unit ]
]
can-convert: func [_to] [ find conversions _to ]
convert: func [amount _to /local formula] [
formula: select/case conversions _to
if formula [
run-formula formula amount
]
]
]units: context [ graph: context [ week: make unit [base-unit: "s" conversions: ["s" 604800.0]] day: make unit [base-unit: "s" conversions: ["s" 86400.0]] ] ]
7.0 when dividingunit: object [
type: 'unit
conversions: none
base-unit: none
init: does [
conversions: make map! []
]
base-unit-value: does [
probe select/case conversions base-unit
if base-unit [ select/case conversions base-unit ]
]
]
>> units/graph/week/base-unit-value / units/graph/day/base-unit-value
604800.0
86400.0
== 1.0do reduce [units/graph/week/base-unit-value '/ units/graph/day/base-unit-value]>> week: make object! [
type: 'unit
conversions: #(
s: 604800.0
)
base-unit: 's
init: func [][
conversions: make map! []
]
base-unit-value: func [][
probe select/case conversions base-unit
if base-unit [select/case conversions base-unit]
]
]
>> day: make object! [
type: 'unit
conversions: #(
s: 86400.0
)
base-unit: 's
init: func [][
conversions: make map! []
]
base-unit-value: func [][
probe select/case conversions base-unit
if base-unit [select/case conversions base-unit]
]
]
>> week/base-unit-value / day/base-unit-value
604800.0
86400.0
== 1.0
>>7.0>> units/convert2 1 'week 'day 604800.0 *** Runtime Error 1: access violation *** at: 08074D8Fh
>> units/convert2 1 'week 'day == 7.0 >> units/convert2 1 'week 'hour == 168.0 >> units/convert2 1 'uranusyear 'hour == 736491.672036 >> units/convert2 1 'uranusyear 'day == 30687.1530015
units unix utility :))>> probe keys-of units/graph [kg kilogram s second m meter A ampere amp cd candela mol mole K kelvin radian sr steradian US bit cm LENGTH AREA VOLUME MASS CURRENT AMOUNT ANGLE SOLID_ANGLE MONEY tonne t metricton quintal cc are a liter L l galvat angstrom xunit_cu xunit_mo angstromstar fermi barn shed svedberg spat sec minute min hour hr day d da week wk sennight fortnight blink ce watch bell decimalhour decimalminute decimalsecond beat circle degree deg arcdeg arcmin arcminute arcsec arcsecond rightangle quadrant quintant sextant sign turn revolution rev gon grade centesimalminute centesimalsecond milangle pointangle centrad sphere squaredegree squareminute squaresecond squarearcmin squarearcsec sphericalrightangle octant TEMPERATURE TEMPERATURE_DIFFERENCE degcelsius degC degfahrenheit degF degreesrankine degrankine degreerankine degR tempR temprankine degreaumur degK tempK atomicmassunit u amu amu_chem amu_phys dalton standardtemp stdtemp Rinfinity R_H bohrradius planckmass m_P deuteronchargeradius protonchargeradius electronmass m_e protonmass m_p neutronmass m_n muonmass m_mu deuteronmass m_d alphaparticlemass m_alpha taumass m_tau tritonmass m_t helionmass m_h kayser balmer abampere abamp aA biot Bi intampere intamp LUMINOUS_INTENSITY candle hefnerunit hefnercandle violle TIME anomalisticyear siderealyear tropicalyear eclipseyear siderealday siderealhour siderealminute siderealsecond anomalisticmonth nodicalmonth draconicmonth draconiticmonth siderealmonth year yr month mo lustrum decade century millennium millennia solaryear calendaryear commonyear leapyear julianyear gregorianyear islamicyear islamicleapyear islamicmonth mercuryday venusday earthday marsday jupiterday saturnday uranusday neptuneday plutoday mercuryyear venusyear earthyear marsyear jupiteryear saturnyear uranusyear neptuneyear plutoyear earthradius_equatorial sunradius astronomicalunit au solarmass sunmass sundist moondist sundist_near sundist_far mercurymass venusmass earthmoonmass marsmass jupitermass saturnmass uranusmass neptunemass plutomass earthmass moonmass oldmercurymass oldvenusmass oldmarsmass oldjupitermass oldsaturnmass olduranusmass oldneptunemass oldplutomass atomicmass atomiclength thermalvolt inch in foot feet ft yard yd mile line rod perch furlong statutemile league chain link ch intacre acre section township homestead engineerschain engineerslink ramsdenschain ramsdenslink gurleychain gurleylink wingchain winglink internationalyard fathom nauticalmile cable intcable cablelength marineleague pound lb grain ounce oz dram dr ushundredweight shorthundredweight shortton shortquarterweight shortquarter troypound troyounce ozt pennyweight dwt fineounce silversmithpoint appound apounce apdram apscruple usgallon usquart uspint usgill usfluidounce usfloz liquidbarrel beerkeg ponykeg winekeg petroleumbarrel barrel bbl ushogshead usfirkin usbushel uspeck drygallon dryquart drypint drybarrel cranberrybarrel heapedbushel wheatbushel soybeanbushel cornbushel ryebushel barleybushel oatbushel ricebushel canada_oatbushel ponyvolume jigger shot fifth wineglass magnum metricquart jeroboam rehoboam methuselah salmanazar balthazar nebuchadnezzar shoeiron shoeounce shoesize_delta shoe_men0 shoe_women0 shoe_boys0 shoe_girls0 europeshoesize buck fin sawbuck usgrand greenback key lid usfootballfield canadafootballfield brnauticalmile brcable admiraltymile admiraltycable seamile shackle clove stone tod brhundredweight longhundredweight longton brton brgallon brbarrel brbushel brheapedbushel brquarter brchaldron bag bucket last pottle pin puncheon seam coomb boll firlot brfirkin cran brwinehogshead brhogshead brbeerhogshead brbeerbutt registerton shippington brshippington freightton displacementton waterton strike amber imperialgallon imperialbarrel imperialbushel imperialheapedbushel imperialquarter imperialchaldron imperialwinehogshead imperialhogshead imperialbeerhogshead imperialbeerbutt imperialfirkin hide virgate nook englishcarat mancus mast nailkeg basebox metre litre geometricpace pace USmilitarypace USdoubletimepace fingerbreadth fingerleng
>> units/convert 10 'ampere 's *** Throw Error: no catch for throw: cant-convert *** Where: throw *** Stack:
thermalhenry J K^2/W^2 # thermal inductance osi ounce force / inch^2 # used in aviation europeanUvalue watt / m^2 K
>> change "test" "" == "test" >> change/part "test" "" 1 == "est"
change gets length from value. In first case, that length is zero.>> head change "test" "" == "test" >> head change "test" "_" == "_est" >> head change "test" "__" == "__st" >> head change "test" "___" == "___t"
/part refinement, /part is equal to the length of the value so that:change "test" ""
change/part "test" "" 0
or position in the description:/part => Limits the amount to change to a given length or positionposition part accounts for this:>> change/part t: "test" "b" at t 2 t == "best" >> change/part t: "test" "b" at t 4 t == "bt"
issue! especially is such a great key.