Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 01 2018 17:34
    @greggirwin banned @BIjeuca_twitter
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:20
    @PeterWAWood banned @TimeSeriesLord
PeterWAWood
@PeterWAWood
This is how to bind words to the same value:
>> a: b: c: "qwerty"
== "qwerty"
>> append a "abc"
== "qwertyabc"
>> b
== "qwertyabc"
sptorin
@sptorin_twitter

@PeterWAWood this make three string in memory?

a: "qwerty"
b: "qwerty"
c: "qwerty"

If we look at your first example, this right - now three string in memory with content "qwerty"

Now make:

a: "qwerty"
a: "qwerty"
a: "qwerty"

Againg three string in memory?

PeterWAWood
@PeterWAWood

On reflection, it probably doesn't but I'm not certain.

If it does then values that are not bound to a word! or included in a collection (e.g. block!) will be garbage collected, once the garbage collector has been implemented.

sptorin
@sptorin_twitter
loop 100 [a: "qwerty"] - 100 times bound a to same value? Because value in block!?
PeterWAWood
@PeterWAWood
I think that a is bound to the value "qwerty" in the first line, in the second and third lines, Red does not rebind to a new value.
PeterWAWood
@PeterWAWood
>> stats
== 3317760
>> loop 100000 [a: "qwerty"]
== "qwerty"
>> stats
== 3317760
>> loop 100000 [a: copy "qwerty"]
== "qwerty"
>> stats
== 6238208
As I understand, set-word!s evaluate differently if the word needs to be added to the context from when the word has already been added to the context.
geekyi
@geekyi

Typing out a word(without pressing enter) creates 4 instances. Of those, 2 instances are 2-byte word encodings, one is history of whole console.
Pressing enter gives me an obvious error about the word having no value, and 8 more instances are created (which includes the error message).
Note that it's all done in the console on Win10.

So, depending on how things are done, it may take up different memory in ways one wouldn't have thought!
Also, being alpha software, there's still space for much improvement here.

GiuseppeChillemi
@GiuseppeChillemi
@9214 @greggirwin read your last messages and head explodes twice... Let a: "1234567890" and after a: "". This mean what somewhere in memory exist string "1234567890" and word a bound to it. After this we create new string "" and bound a to it. Now no one pointer look on "1234567890" - and this string must be garbage collected?
The answer has still not solved some points like this. Hope @dockimbel will help clarify.
Gregg Irwin
@greggirwin
I answered that as best I could @GiuseppeChillemi. If nothing refers to a value, it may be garbage collected. As long as something refers to it, it can't. :point_up: September 27, 2017 11:50 AM may be corrected by @dockimbel, but these are also details that could change, and may not be worth time answering right now.
When implementation details like this become important is when they affect users directly.
Nenad Rakocevic
@dockimbel
@geekyi How to do you end up with those counts?

@GiuseppeChillemi

The answer has still not solved some points like this. Hope @dockimbel will help clarify.

I'm not sure what is missing from above explanations, but to answer your question, a series which is no longer referenced anywhere will be garbage -collected. If you put that string in a function body block, it is referenced.

Nenad Rakocevic
@dockimbel

@9214

how can you, oh mighty Redbol gurus, live on such mental heights without your head exploding?

With Redbol, it's most of time simpler than you think. I'm trying to write down some general explanations of the core concept, for the Red documentation and eventually a blog article.

Vladimir Vasilyev
@9214
@dockimbel that will be great, because I feel that I lack strong mental model of what is really happening then I program in Redbol and it kinda limits my power. I would say that freedom is truly paralyzing ;)
btw, currently only series! could be modified in-place, am I right that with ref! datatype such self-modification will be doable with everything?
Rudolf Meijer
@meijeru
I thought that ref! was a re-designed issue!... :worried:
Boleslav Březovský
@rebolek
IIRC ref! is for @name
(I’m not sure why, but I can't type @ in Firefox, I have to copy it)
PeterWAWood
@PeterWAWood
@9214 I'm not certain that "currently only series! could be modified in-place" is correct. Though I may not understand what you are saying. object! and map! values can be modified in place. I believe that pair! and tuple! values can be modified in place.
Vladimir Vasilyev
@9214
@PeterWAWood
>> x: [1 2 3]
== [1 2 3]
>> reverse x
== [3 2 1]
>> x
== [3 2 1]
>> x: 1x2
== 1x2
>> reverse x
== 2x1
>> x
== 1x2
>> x: 1.2.3.4
== 1.2.3.4
>> reverse x
== 4.3.2.1
>> x
== 1.2.3.4
Rudolf Meijer
@meijeru
But,
>> x: 1.2.3
== 1.2.3
>> x/1: 4
== 4
>> x
== 4.2.3
This modification in place applies to pair!, tuple!, time! and date! values.
Vladimir Vasilyev
@9214

not sure what I meant either :D

>> f: func [x][y: 0 y: y + x]
== func [x][y: 0 y: y + x]
>> f 5
== 5
>> body-of :f
== [y: 0 y: y + x]
>> f: func [x][y: [0] y/1: y/1 + x]
== func [x][y: [0] y/1: y/1 + x]
>> f 5
== 5
>> body-of :f
== [y: [5] y/1: y/1 + x]

what if I want y in the first example to be modified as in the second example, only without explicit block wrapping?

I thought that ref! is something like a pointer to series position
reference
Boleslav Březovský
@rebolek
No, probably the name is confusing and should be changed.
Vladimir Vasilyev
@9214
so, ref! is sort of a @9214 mention?
couldn't find any info about this datatype in R3 docs
Boleslav Březovský
@rebolek
@9214 it is not in R3
Vladimir Vasilyev
@9214
another thing that I learned today is that tuple! is not limited in it's length (I thought that it should contain exactly 4 elements)
PeterWAWood
@PeterWAWood

another thing that I learned today is that tuple! is not limited in it's length (I thought that it should contain exactly 4 elements)

tuple! is limited in length.

>> 1.2.3.4.5.6.7.8.9.10.11.12
== 1.2.3.4.5.6.7.8.9.10.11.12
>> 1.2.3.4.5.6.7.8.9.10.11.12.13
*** Syntax Error: invalid tuple! at "1.2.3.4.5.6.7.8.9.10.11.12.13"
*** Where: do
*** Stack: load
Vladimir Vasilyev
@9214
@PeterWAWood thanks, my bad, I stopped at 10th :D
and minimum length is 3, otherwise it's a float!
Toomas Vooglaid
@toomasv
It doesn't accept devil's dozen :imp:
PeterWAWood
@PeterWAWood
A baker's dozen in England 🥐
Petr Krenzelok
@pekr
ref!leads ppl to think it is a pointer oriented datatype. I can simply imagine it being named name! or label!
btw - as for a pointer stuff, isn't there a handle!datatype for that?
Gregg Irwin
@greggirwin

The ref! name was discussed quite heavily at one point, on atlme too, but is not finalized. We also have tuple! with a different meaning than in other languages. What we need to do is ask: "What is the main purpose of this datatype? What does it represent?" People new to Red have a lot of concepts to learn, and old habits and ideas to un-learn.

I'm short on time, but will try to write up thoughts in the future. But ref! values aren't just for human handles in chat (e.g. @pekr). They could be used to refer to locations in code, as in a cross-reference, a specific message in a chat, a point in time, etc. That is, it refers to something. And since Red has no concept of a pointer, though R/S does, there shouldn't be much confusion after initial exposure.

GiuseppeChillemi
@GiuseppeChillemi
@dockimbel
I have worked on the "there is no spoon" problem and while it seems I have understood the "code is data"/"data is code" paradigm, I have ended up in a problem:
Please look at this code:
GiuseppeChillemi
@GiuseppeChillemi
print-it: func [/local str] [
    str: ""
    insert str "ha"
    print ["First STR" str]
    str: ""
    print ["Secnd STR" str]
    Clear STR
    print ["Clear STR" str]
]
New users head "explodes" while thinking that "STR" as the second "str" let us think the first one is being reset and referenc to the value of the rist one lost.
GiuseppeChillemi
@GiuseppeChillemi
What confuses more, and I am talking of personal experience, is the fact this kind of code works flawlessy in the main code body as if you do not repeat it in a loop, each time you start the script REDBOL programs seems behave like other programming languages
Only inside a loop, when the first STR and its next VALUE is referenced for the second time you will discover it is "ah" and then "ahah" and then "ahahah" at the third round.
GiuseppeChillemi
@GiuseppeChillemi
In other programming languages STR: "ah" and STR: "" change the value of the variable with a CLEAR and SET TO a value which is independend from the position of the code. While in REDBOL languages the position is a STORAGE of VALUE too.And we should workwith a very different logic
Vladimir Vasilyev
@9214
@GiuseppeChillemi
Every Redbol script is contiguous block of data. Think of it as one dimensional space. Now, this one dimensional space have some sort of spatial markers which point to specific location in this space. This is what set-word! is - it's just this type of marker. set-word! points to location in source code, while variables usually point to location in memory. But there's no variables in Redbol. In a vague sense, script's body is it's own memory. Entire script is just one big chunk of self-modifiable state, which can be trivially serialized, saved and restored.