Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 20 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
Maxim V
@maximvl
I also can fix it
red>> a: get bind 'a ctx
== 2
red>> a
== 2
:D
Vladimir Vasilyev
@9214
you mean data, not code ;)
Nenad Rakocevic
@dockimbel
It's beyond fixable, I'm afraid. ;-) Ah, you were talking about the code...
Maxim V
@maximvl
the fact that a and a are two completely different words, just happend to be named with the same symbol makes total sense now
Nenad Rakocevic
@dockimbel
That is the correct picture. Words are instances of symbols.
Vladimir Vasilyev
@9214
In fact it puzzled me why bind works like I expect with blocks but not with bare-bone words, now I see that (I think)
Nenad Rakocevic
@dockimbel
bind does the same job, it's just that words with same symbol are not inter-connected (other than sharing the same symbol ID). A new word (sent to input in the case above) is by default bound to global context, no matter what you did to a previous word with the same spelling. Now you start to realize how far the "variables" concept from other languages can be. ;-)
Maxim V
@maximvl
@9214 with block it just binds every corresponsding word inside
without block you bind only one "instance" of the word
Nenad Rakocevic
@dockimbel
I think it is ok to use the term "variable" in Redbol as a shortcut, for convience, but you need to be aware of the binding mechanism and contexts, otherwise, you are building a wrong picture of how words behave.
Vladimir Vasilyev
@9214
@maximvl Yup, I knew that before, but didn't know about instance on the stack
Maxim V
@maximvl
or should I say symbol?)
I have to admit this is much deeper concept than I saw it in the beginning
Vladimir Vasilyev
@9214
Aaaaah! I thought bind 'a context means "find a in a current context..." but that's BS since there's no current context
Nenad Rakocevic
@dockimbel
It is, and we really need some good visual ways to explain it, because it it really not complex, just very different.
@9214 Precisely, yes. Drop the scopes from the part of your mind you are filling with Redbol. ;-)
Maxim V
@maximvl
find a in current context - makes little sense, you can only find value of a in context, right?
Nenad Rakocevic
@dockimbel
Yep.
Vladimir Vasilyev
@9214
For no apparent reason Tuvan throat singing comes from my speakers
Nenad Rakocevic
@dockimbel
hehe ;-)
Maxim V
@maximvl
@dockimbel but word's values themselves are stored somewhere, right?
like 'x
Nenad Rakocevic
@dockimbel
Yes, in any value container (block!, paren!, map!, hash!, context!, ...). Values in Redbol cannot exist outside a value container, even what you write in the console, the input is loaded as a block.
Vladimir Vasilyev
@9214
As a matter of fact this discussion beginned from this gist https://gist.github.com/9214/1dd30a88383a3e46edf45e33e9def3a7
But I've forgot what I actually wanted to accomplish with that :D
Vladimir Vasilyev
@9214
Ah, at the end of it I've started to write
; now, let us make our spoon to be just a "spoon"
set 'spoon bind 'spoon third contexts ; <-- at this part I've started doubting myself and started a discussion
print spoon

print reduce shelf-with-spoons
comment {
    however, last entry changed too!
    how can we avoid that? <-- use poke on a series..?
}
so, before that part last spoon in a block should be rebounded somehow, to keep an old string value?
Vladimir Vasilyev
@9214
a fork and a knife, but still no spoon! :fork_and_knife:
bind back tail shelf-with-spoons make object! [spoon: "take the RED pill"]
print reduce shelf-with-spoons
print spoon
Vladimir Vasilyev
@9214
okay, I've updated gist, come and see! :alien:
Nenad Rakocevic
@dockimbel
"s(puny)", good one. :+1: :laughing:
Vladimir Vasilyev
@9214
@dockimbel I think I can do it even trickier on 78 line, bind back tail shelf-with-spoons context [spoon: "take the RED pill"]
by using spoon: "take the RED pill" which was entered in a script later... somehow
i.e. introspect script block itself
should I use system/console/history for that? ;)
ah, no, my bad, it's not about console either
Vladimir Vasilyev
@9214
Red [] ; 1
       ; 2
a: 1   ; 3
a: 2   ; 4
       ; 5
1336 + <`a` at line 3 inside LOADed block> ; --> 1337
is that possible?
Nenad Rakocevic
@dockimbel
Yes, if you save that script to 1337.red file, then:
h4x0r: load %1337.red
h4x0r/9: h4x0r/4
do h4x0r
Vladimir Vasilyev
@9214
script can load itself! :O
the power of the gods at my fingertips :sparkles: :point_left:
Nenad Rakocevic
@dockimbel
With great power... ;-)
Vladimir Vasilyev
@9214
and how could I make this trick more general, i.e. h4x0r: load <somehow construct file name from the header or some metanifo?>
Boleslav Březovský
@rebolek
load/header
c> script: load/header %json.red
== [Red [
    Title: "JSON parser"
    File: %json.red
    Author: ...
c> script/2
== [
    Title: "JSON parser"
    File: %json.red
    Author: "Nena...
c> script/2/file
== %json.red
Nenad Rakocevic
@dockimbel
Populating the header: Red [File: %1337.red], though, Red does not yet store the header info in system object (Rebol does).
Vladimir Vasilyev
@9214
Hm, but that means that I should know exact name of a file before I'll load its file entry from a header :confused:, what's the point?
Boleslav Březovský
@rebolek
@9214 How do you want to load a file which name you do not know?
Vladimir Vasilyev
@9214
so there's no other way for a script to know a name of a file in which it resides but to specify that filename inside of a script itself?
Boleslav Březovský
@rebolek
What if you load more files? How should each function "know" from which file it was? What if the function is dynamically constructed?