Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:19
    @PeterWAWood banned @TimeSeriesLord
  • Aug 13 2016 03:23
    @PeterWAWood banned @Vexercizer
Maxim V
@maximvl
>>parse "abcd" [collect [keep any not #"a"]]
== [#"a"]
this result seems super counter intuitive
Boleslav Březovský
@rebolek
For example
>> parse "abcd" [collect some [not #"a" keep skip | skip]]
== [#"b" #"c" #"d"]
Maxim V
@maximvl
@rebolek yeah, I overlook that some rules don't advance the input and one needs to do it explicetely
thanks
Gregg Irwin
@greggirwin
Nice @9214.
Boleslav Březovský
@rebolek
@9214 Nice, but what about Red[Title: "]]]"]? ;)
Vladimir Vasilyev
@9214
@rebolek :scream:
@rebolek any tips?
skip if series! ?
Boleslav Březovský
@rebolek
@9214 you are parsing string, there is no series!
Ignore stuff between " and {}, but that's easier said than done :)
Vladimir Vasilyev
@9214
@rebolek ;)
This is a preface! Roses are red, the pill is RED too!

    rEd
    [_]
   [___]
  [_____]

Red [
    "]]]"
    {]]]}
    {"{"}}
    {^{}
]

source-of: func [
    "get source of the script without preface and header"
    script [file!]
    /header "get only header instead"
    /local
        blanks [bitset!]
        head   [block!]
        source [string!]
        i      [integer!]
][  
    ; skip preface and Red keyword
    parse/case read script [
        (blanks: charset reduce [cr lf space tab] head: copy [] i: 0)
        thru ["Red" any blanks ahead "["]
        s: to end
    ]
    ; now parse the source directly
    parse load s [set head block! source: to end]

    return either header [head][source]
]

probe source-of system/options/script
probe source-of/header system/options/script
Boleslav Březovský
@rebolek
Yeah, load FTW!!! :clap:
Vladimir Vasilyev
@9214
though, am I right that only Red keyword followed by [ with optional blanks in between counts as a start of the header?
red []

Red blah [...]

Red [File: %bad-script.red]

42
*** Error: not a Red program!
Gregg Irwin
@greggirwin
Almost. Red/System as well, plus optional BOM. From %lexer.r:
    header: [
        pos: thru "Red" (rs?: no) opt ["/System" (rs?: yes stack/push 'Red/System)]
        any-ws block-rule (stack/push value)
        | (throw-error/with "Invalid Red program") end skip
    ]

    program: [
        pos: opt UTF-8-BOM
        header
        any-value
        opt wrong-end
    ]
FLuX LoOP
@x8x

For those who need epoch with subsecond precision conversion:

to-date: func [dt][either float? dt [1-Jan-1970 + to time! dt][to date! dt]]
to-float: func [dt][either date? dt [to float! difference dt 1-Jan-1970][to float! dt]]

Test:

  date: now/precise
;   4-Aug-2017/2:16:10.183843+02:00
  epoch-with-subseconds: to-float date
;   1501805770.183843
  to-date epoch-with-subseconds
;   4-Aug-2017/0:16:10.183843
Muhammad N ElNokrashy
@narfanar
Is there a suggested .gitignore for Red projects?
PeterWAWood
@PeterWAWood
We discussed adding a sample to the website (or wiki) but it hasn't been done yet. This is an extract of the most common files to ignore from mine:
.gitignore
quick-test/quick-test.log
quick-test/runnable/
system/tests/source/units/auto-tests/
tests/source/units/auto-tests/
crush.dll
Vladimir Vasilyev
@9214
@Enamex lib* to ignore files spawned by libRedRT compilation
Muhammad N ElNokrashy
@narfanar
@PeterWAWood Are system and tests directories made by quick-test somehow? (Actually, what is quick-test... :P)
PeterWAWood
@PeterWAWood
@Enamex Quick-test is a very basic test framework that we initially wrote for testing Red/System (before Red). It is used to run the regression tests. If you run the tests, quick-test will create and populate:
quick-test/quick-test.log
quick-test/runnable/
system/tests/source/units/auto-tests/
tests/source/units/auto-tests/
Quick-test is [documented] but the documents need to be updated ... as does quick-test itself ... though not quick-test.red or quick-test.reds.
GiuseppeChillemi
@GiuseppeChillemi
I need the HTTP , FTP, EMAIL and HTTPS protocols. Are they in red or should I use something else?
PeterWAWood
@PeterWAWood

@GiuseppeChillemi
Red is still in the alpha phase of its development. The current release is Version 0.6.3. The first fully complete Red will be Version 1.0.. Features are continually being added to Red as it progresses to Version 1.0..

There is a Trello Roadmap which indicates at which stage various features will be delivered. (It is probably best to read The Red Project Approach to understand the context of the Trello Roadmap).

Red 0.6.3 includes temporary I/O features including support of HTTP and HTTPS (GET, POST, PUSH, HEAD and DELETE).

The port! datatype which will enable full I/O support is planned for Version 0.7.0. The Trello card for 0.7.0 under Milestones lists the protocol support planned to be provided in Version 0.7.0.

The Trello card for I/O under Road to 1.0 lists the protocol support that is planned to be added before Version 1.0 is released.

FTP is not currently included in either list. It is possible that someone from the community wiil contribute a FTP implementation once the `port!' datatype is available.

GiuseppeChillemi
@GiuseppeChillemi
@PeterWAWood I have read that someone in the past has used some kind of external library to do this kind of networking work. I supposed to receive answers about using that library to achive full communication capabilities but I need the libraryname and examples
PeterWAWood
@PeterWAWood
I woud guess that the library is LibCurl.
Petr Krenzelok
@pekr
I think that LibCurl can be used also from a command line, so one can use Red's callfacility eventually, but not 100% sure ....
PeterWAWood
@PeterWAWood
@pekr Yes you can run the curl executable on the command line.
Boleslav Březovský
@rebolek
I was using curl but now Red supports everything I needed from it.
Muhammad N ElNokrashy
@narfanar
Can one specify a static type of a 'local variable' outside a function?
Gregg Irwin
@greggirwin
@Enamex, can you give an example of what you want to do? You can create a context, with a function inside it, and use a word in that context.
ctx: context [
    var: 1
    set 'exported-func func [][print var]
]
You can also create pseudo-closures, or do things in trickier ways.
closure: func [
    vars [block!] "Values to close over, in spec block format"
    spec [block!] "Function spec for closure func"
    body [block!] "Body of closure func; vars will be available"
][
    func spec compose [(bind body context vars)]
]
closed-fn: closure [var: 1] [n] [var: var + n]
>> closed-fn 1
== 2
>> closed-fn 1
== 3
>> closed-fn 1
== 4
Muhammad N ElNokrashy
@narfanar
@greggirwin OK, that's not what I was asking about but it's awesome O.O
Gregg Irwin
@greggirwin
Can you give an example of what you're after?
I think @JacobGood1 did the original closure that's modeled on. Credit to him.
Vladimir Vasilyev
@9214
@greggirwin I think compose can be omitted
closure: func [vars spec body][func spec bind body context vars]
sounds like poetry :wine_glass:
Gregg Irwin
@greggirwin
Indeed. May be a relic from an earlier limitation in Red. Good catch.
No. It's needed. Otherwise the body block isn't eval'd when creating the closed func.
Ah, nevermind, you're right. Just remove the outer block there. Duh.
Vladimir Vasilyev
@9214
bind returns block with words binded to anonymous context one way or another
Gregg Irwin
@greggirwin
It will return a word if given a word arg, but we wrap it, so we always know we're going to get a block in this case.
Muhammad N ElNokrashy
@narfanar
@greggirwin Sorry, had to leave for a bit. Rather, something like:... Actually, does Red even have the notion of statically checking types? From playing around it feels mostly dynamically checked
Gregg Irwin
@greggirwin
Values are strongly typed. Variables are not.