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
Vladimir Vasilyev
@9214
Technically, each value is a cell. All Red scripts are build from cells, so as organisms :wink:
yvendruscolo
@yvendruscolo
Nice!
Palaing
@Palaing
@9214 I knew there had to be some poet(s) around here!!!
nedzadarek
@nedzadarek
@9214 I tend to avoid domain-specific language (words) when I don't need it. As the naming is hard I like to look at the way people name things. spine, vertebra and code as an organism - interesting.
Vladimir Vasilyev
@9214
@nedzadarek I seek for 3-8 letter words that catch the abstraction succinctly, using thesaurus as a last resort. Red is all about dialects, so using slang and domain-specific terms ain't bad at all, it's the exact opposite. Good metaphors makes you think at the whole new level.
nedzadarek
@nedzadarek

@9214

so using slang and domain-specific terms ain't bad at all, it's the exact opposite. Good metaphors makes you think at the whole new level.

Yes, it makes your code more readable... if you get it right. If you are non-native speaker then you may make mistakes. That's why I'm little afraid. Well, maybe I'll use "your style" sometimes. I may fail but with failure we learn more. Thank you for your opinion about naming.

Vladimir Vasilyev
@9214
@nedzadarek you're welcome. Walk on the wild side :wink:
nedzadarek
@nedzadarek
I have gui with many sliders. I wanted set and get value of the a slider so I've put text (just to try getting values), like this: view [s: slider 50% on-change [f/data: s/data] f: text]. It worked so I've changed from text to field (view [s: slider 50% on-change [f/data: s/data] f: field]). It works but it's much slower than text alternative.
Do I need to do something differently?
ps. Red for Windows version 0.6.3 built 26-Mar-2018/1:14:22+02:00 on win 8.1 x64
nedzadarek
@nedzadarek
You can see the lag when you change the line 34 of preview.red (text to field).
Gregg Irwin
@greggirwin
This is a very nice app @nedzadarek. Field will have more overhead, though text flickers a bit here. To me that says there are a lot of updates going on. Profiling text vs field updates will be easy. Looking at event cycles will be a bit more work, but there may be something in all sliders triggering color-model-changed.
nedzadarek
@nedzadarek

@greggirwin thank you

Profiling text vs field updates will be easy.

I am not sure if I understand. text and field updates should be (almost*) the same. There is no another field and I change text for field (and vice versa) in the style.

  • there is one more text that I update Line 330

Looking at event cycles will be a bit more work, but there may be something in all sliders triggering color-model-changed.

Every change of a slider should trigger color-model-changedonce. I guess I should put some prints there to see the actual number of triggers.

To me that says there are a lot of updates going on.

At least 3/4 group of sliders & text, base and 1x text is updated each time I move a slider. I want to see result instantly - I do not think I can make less updates to achieve this.

Gregg Irwin
@greggirwin

The difference in styles is that the field may have more internal overhead, as the OS manages more because it's editable. My guess. Profile (my gist or others) and updating facets on one should tell us quickly.

The number of updates was more a thought, sorry for writing quickly. The reactive system does a good job, but if you trigger events from within events, there may be cases where extra events trigger before it stabilizes. My thought was just that there may be more events than we think.

Seeing the results instantly is great. Just a matter of technical details.
Vladimir Vasilyev
@9214
@nedzadarek if your fields have on-change handler, and if fields and sliders react to each other, then the following scenario occurs: you enter something in a field, it changes value of a slider, which in turn triggers an update in field, which either triggers slider again or remains silent because the actual data hasn't changed. Justs my after-midnight, uneducated guess.
Maciej Łoziński
@loziniak

Hello! I'm trying to compile a Red code with callback function.

Red []

a: function [
    num [integer!]
] [
    print "num: "
    print num
]

b: function [
    cb [function!]
    num [integer!]
] [
;--    cb: function spec-of :cb body-of :cb
    cb num
]

b :a 15

This does work only in interpreted mode. I've read https://github.com/red/red/wiki/%5BDOC%5D-Guru-Meditations#compiled-vs-interpreted-macros , but uncommenting a commented line in my code also does not help.

Vladimir Vasilyev
@9214
@loziniak remove this line completely, as it's not needed, and compile with -e flag.
Maciej Łoziński
@loziniak
thanks! what does this flag do? I don't see it in red --help output.
is there any documentation on it?
Vladimir Vasilyev
@9214

I don't see it in red --help output.

Update to nightly build. Usage is described in the readme file.

Gregg Irwin
@greggirwin
It compiles in encap mode, which doesn't really compile, but stores the source in the exe for runtime interpretation. It lets you work around any compiler limitations.
Maciej Łoziński
@loziniak
And will it allow me to mix R/S code with Red, using routines and #system?
Vladimir Vasilyev
@9214
  • Routines can be used as long as they are globally defined.
  • #system (if it has no local effect) and #system-global directives are supported.
  • #include is supported.
  • Your Red code is converted to Redbin format and compressed.
Maciej Łoziński
@loziniak
Thank you :-)
DVL333
@DVL333
A question about reactivity.
There is command react. Can you give me examples of using it with refinements /later and /unlink? (not with VID objects) I tried, but hadn't proper result:
obj1: make reactor! [a: 1 b: 2]
obj2: object react/later [sum: obj1/a + obj1/b]
;-- sum is evaluated during creation, but mustn't
react/unlink [sum: obj1/a + obj1/b] obj2
;-- reactivity continues to work, but mustn't
Vladimir Vasilyev
@9214

reactivity continues to work, but mustn't

And why should it break all of a sudden, if I may ask?

Vladimir Vasilyev
@9214

sum is evaluated during creation, but mustn't

sum is evaluated during creation of an object from a block to which you applied react/later. This creation isn't necessary, unless you explicitly wanted to show us something.

>> foo: make reactor! [a: 1 b: 2]
== make object! [
    a: 1
    b: 2
]
>> unset? :x
== true
>> react/later [x: foo/a + something-else]
== [x: foo/a + something-else]
>> unset? :x
== true
>> react [x: foo/a + something-else]
*** Script Error: something-else has no value
*** Where: +
*** Stack: react
Vladimir Vasilyev
@9214

reactivity continues to work, but mustn't

Firstly, obj2 in your example isn't even a reactive source. Secondly, [sum: obj1/a + obj1/b] block you've provided does not contain any reactive relations.

>> foo: make reactor! [a: 1 b: 2]
== make object! [
    a: 1
    b: 2
]
>> bar: object [c: 0]
== make object! [
    c: 0
]
>> block: [bar/c: foo/a + foo/b]
== [bar/c: foo/a + foo/b]
>> react block
== [bar/c: foo/a + foo/b]
>> bar/c
== 3
>> foo/a: 100
== 100
>> bar/c
== 102
>> react/unlink block foo ; note that I unlink the same block in which reaction was linked in the first place!
== [bar/c: foo/a + foo/b]
>> foo/a: 200
== 200
>> bar/c
== 102
nedzadarek
@nedzadarek
@9214 what if you have 2 sources (reactors) and you want to remove only one? Removing reaction(s) with both sources works. It doesn't work with one source:
source-a: make reactor! [a: 1]
source-b: make reactor! [b: 10]

obj: object [c: 0]
block: [obj/c: source-a/a * source-b/b]
react block
obj/c
; == 10

source-a/a: 2
obj/c
; == 20

; react/unlink block [source-a source-b] ; works fine
react/unlink block source-a ; freezes the console
Vladimir Vasilyev
@9214
@nedzadarek good catch, I can reproduce freezing.
@nedzadarek can you file an issue and cross-post your finding in /bugsroom?
nedzadarek
@nedzadarek
@9214 ok, I'll post it.
DVL333
@DVL333
@9214 Thanks a lot!
Of course, i have read the document the link on which you have provided. But there aren't any examples of using react function, only for if. Moreother, I literally have followed a description from that document. :)
BTW, it seems that code react [sum: obj1/a + obj1/b] in my sample constructs a reactive relation, because changing obj1 fields changes sum field for obj2, so I thought I was on right way.
nedzadarek
@nedzadarek
@DVL333 there is www.red-by-example.org/ but sadly it doesn't have examples for react. I think the author should post @9214 in his/her site.
Vladimir Vasilyev
@9214
@toomasv :point_up: you had some really neat reactive solution for one of AoC puzzles, something about conveyors and robots?
DVL333
@DVL333
@nedzadarek
If it were there, I wouldn't ask such questions. ;)
Vladimir Vasilyev
@9214
@DVL333 it constructs a relation, yes, but I doubt that you can delete it without nuking everything with clear-reactions. object creates a copy of a spec block on creation, so original block with a linked reaction cannot be accessed anymore, not even with body-of obj2, as it returns a copy too.
Unless...
>> obj1: make reactor! [a: 1 b: 2]
== make object! [
    a: 1
    b: 2
]
>> obj2: object block: react/later [sum: obj1/a + obj1/b]
== make object! [
    sum: 3
]
>> obj1/a: 100
== 100
>> obj2
== make object! [
    sum: 102
]
>> react/unlink block obj1
== [sum: obj1/a + obj1/b]
>> obj1/a: 1'000
== 1000
>> obj2
== make object! [
    sum: 102
]
Toomas Vooglaid
@toomasv
@9214 Sorry, on the move until tomorrow evening.
Vladimir Vasilyev
@9214
@toomasv np.
Ungaretti
@Ungaretti

This has to be a bug:

Red[]
guess: ask "Enter your expression: "
print guess

Console:

Enter your expression: one
Enter your expression: one
>>

The ask text gets added to the variable (word). This does not happen in Rebol.

Vladimir Vasilyev
@9214
@Ungaretti Red version?
Ungaretti
@Ungaretti
Thanks @9214 .
Gregg Irwin
@greggirwin
We have a page where notes on reactivity can be added: https://github.com/red/red/wiki/%5BDOC%5D-Reactivity
Maciej Łoziński
@loziniak
And https://github.com/red/docs/blob/master/en/reactivity.adoc can also be modified by anyone using a pull request.
BTW would be nice to merge these two pages :-)
Vladimir Vasilyev
@9214
I'd suggest to keep official documentation's quality high and do not do PRs on a whim. If you wish to contribute in a procreative manner, it would be better to share your plan in /docs room first.
Maciej Łoziński
@loziniak
PR can always be rejected / corrected