Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 20 2019 22:59
    @dockimbel banned @SmackMacDougal
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:19
    @PeterWAWood banned @TimeSeriesLord
  • Aug 13 2016 03:23
    @PeterWAWood banned @Vexercizer
Oldes Huhuman
@Oldes
Ah.. sorry.. that was our cat!
Gregg Irwin
@greggirwin
:^) You should name it crashdump.
Dave Andersen
@dander
that seems like a very appropriate name for a cat 😸
Oldes Huhuman
@Oldes
I quite don't undtestand how she did it.. just by sitting on a keyboard.
Dave Andersen
@dander
It's always amazing to me what a computer can do with a baby or cat sitting in front/on it
Gregg Irwin
@greggirwin
It's how most cat pictures get on the internet. Selfies.
I feel someone ready to call me out for cat chat.
Dmitry Bubnenkov
@bubnenkoff
What extension should use Red apps? I know that base is .red, but I is there any cases when .r is using?
Dmitry Bubnenkov
@bubnenkoff
Hm, strange. Why word get only one .r file:
>> list-of-rules: foreach f files [if equal? suffix? f ".r" [f]]
== %r3.r
>> 
>> foreach f files [if equal? suffix? f ".r" [print f]]
r1.r
r2.r
r3.r
Toomas Vooglaid
@toomasv
You are not collecting these files. In each loop it returns current file, the last stays.
Dmitry Bubnenkov
@bubnenkoff
>> files
== [%app.red %backup.txt %r1.r %r2.r %r3.r]
>> 
>> 
>> foreach f files [if equal? suffix? f ".r" [append list-of-rules f]]
== [%r1.r %r2.r %"" %r1.r %r2.r %r3.r]
Do I now collect them? Why so strange result with duplicates?
Petr Krenzelok
@pekr
Your console session is broken. Try to clear/reset your list-of-rules first ...
>> files: [%app.red %backup.txt %r1.r %r2.r %r3.r]
== [%app.red %backup.txt %r1.r %r2.r %r3.r]
>> list-of-rules: []
== []
>> foreach f files [if equal? suffix? f ".r" [append list-of-rules f]]
== [%r1.r %r2.r %r3.r]
Dmitry Bubnenkov
@bubnenkoff
thanks! Can be this code rewritten to make foreach return values instead of appending them? Or what best practice for writing such functions?
Toomas Vooglaid
@toomasv
Use collect/keep.
Gregg Irwin
@greggirwin
:point_up: January 23, 2020 11:31 PM @bubnenkoff %.r is the extension used for Rebol files.
Dmitry Bubnenkov
@bubnenkoff

Use collect/keep.

I know how to use it inside red parse, but have not ideas how work with it in classic red. Something like?

l: foreach f files [if equal? suffix? f ".r" [collect keep f]]

And it's seems that keep can't use outside red parse:

>> ? keep
No matching values were found in the global context.
GiuseppeChillemi
@GiuseppeChillemi
@bubnenkoff Yes, it can't. It is a word of parse dialect and not e standalone function.
Dmitry Bubnenkov
@bubnenkoff
So the function can't be rewritten to return result to word? Or it's absolutely normal that it looks so?
Toomas Vooglaid
@toomasv
Wrong. Please use help on collect.
Dmitry Bubnenkov
@bubnenkoff
Bingo!
l: collect [foreach f files [if equal? suffix? f ".r" [keep f]]]
== [%r1.r %r2.r %r3.r]
But why keep works outside parse?
Boleslav Březovský
@rebolek
This has nothing to do with parse at all
Dmitry Bubnenkov
@bubnenkoff
I am a little bit confuse how to know how every words work in different dialect and if it can\cannot be used there
Toomas Vooglaid
@toomasv
Research and practice. And then practice.
Maciej Łoziński
@loziniak
Is there any possibility to use refinements on functions programatically?
Like if I wanted to use refinement or not depending on some condition, without repeating all other function arguments?
like f/:cond xyz
probably just construct the call dynamically, then do?
Boleslav Březovský
@rebolek
@loziniak Right, right now that's the only way. Once we get apply it gets better.
Gregg Irwin
@greggirwin
:point_up: January 24, 2020 1:48 AM @bubnenkoff each dialect defines its own rules. Sometimes the same names will be used, e.g. copy, collect, and keep so they align with standard Red functions, but they may behave differently. It may seem strange at first, but it becomes natural before too long for most people.
Respectech
@Respectech
@bubnenkoff Carl, the creator of Rebol, wanted to create a system that allowed people to create dialects for domain-specific tasks. This would be like if you went to a conference and in one room, there were a number of astronomers. In another room, there were doctors. And in another room, there were lawyers. Another room had stock analysts. They might all be speaking the same language, but they would be using dialects to more efficiently communicate with others in the same specialty.
We could live without parse. But we wouldn't be as effective without it, and our code would be more complicated.
Also, in the military, they may use the word asset. The military's meaning of asset would be different than the financial analyst's meaning of asset.
GiuseppeChillemi
@GiuseppeChillemi
@bubnenkoff Have you read Rebol/Core manual up to parse?
Nash
@anonymouXnash
>_apt update
``` apt

hiiamboris
@hiiamboris
@GiuseppeChillemi re: starter example
Can't write you one, but here's some ideas:
  • call a function with the code (which is data) in question
  • have 2 states - do-evaluation or parse-evaluation - there
  • in do-mode, use do/next and check the mode again (switch if needed)
  • in parse-mode, define a rule exit that sets the position and breaks out of parse, then after a break (in do-mode again), continue from that position
The biggest headache will be to support (if you need it) this in inner nested blocks and when leaving those
GiuseppeChillemi
@GiuseppeChillemi
@hiiamboris could be done at pre lexer level?
hiiamboris
@hiiamboris
No
Neither in pre-load nor (reliably) after lexing. You need to evaluate your code, to be aware of definition changes since the initial boot-up. E.g. you think + is an operator, but at some point it may change into a value or a function and you need to be up to date with this change. The only way to be up to date is to evaluate ;)
If your switch is static enough that you pretty much know the outcome in advance, then just resort to macros (#if, #either, #switch, #case).
GiuseppeChillemi
@GiuseppeChillemi
Well, I do not have enough knowledge to understand the pre lexer and after lexer and macros level but the do/next and switching to parse is at my reach.
hiiamboris
@hiiamboris
:+1:
GiuseppeChillemi
@GiuseppeChillemi
Also, seeking docs and examples on pre lexer, could you point me to something?
hiiamboris
@hiiamboris

Well, I do not have enough knowledge to understand the pre lexer and after lexer and macros level but the do/next and switching to parse is at my reach.

pre-lexer is just a big string, system/lexer/pre-load thing abuses that
after lexing it's a block of Red values, there goes preprocessor and expands macros
then goes do on the result

Also, seeking docs and examples on pre lexer, could you point me to something?

search wiki for pre-load, there must be something