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
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.
GiuseppeChillemi
@GiuseppeChillemi
STR: "ah" must be read: STR is taking data from the CODEFLOW position shich is next to it (lets say it is pointer 1 to "ah")
another STR: "" must be read as TAKE DATA FROM CODEFLOW position next to it (lets say it is a pointer 2 to "")
When the code loops the first STR takes data from code position 1
So it is like having a different pointer not the same one which is reset or repositioned to point to another value
GiuseppeChillemi
@GiuseppeChillemi
In
STR: "ah"
STR: ""
We have
STR: is "CODEFLOW POSITION INDEX 1"
"ah" is "CODEFLOW POSITION INDEX 2"
STR: "CODEFLOW POSITION INDEX 3"
"" is "CODEFLOW POSITION INDEX 4"
Vladimir Vasilyev
@9214
what is "codeflow" anyway?
GiuseppeChillemi
@GiuseppeChillemi
It is FLOW of CODE: any word which makes up your code
Vladimir Vasilyev
@9214
and why not just "block"?
GiuseppeChillemi
@GiuseppeChillemi

When you:

STR: "" ;""  is data structure position 2
insert STR "ah"
STR: "" ;"" is data structure position 7
insert STR "bb"

you are stating: SET STR to what you find at position 2 of your data structure ("")
Then: insert on what is rapresented in position 5 (word "ah") on position 2
Then: set STR to what is rapresented in position 7 (second "") and use THIS POSITION in further reference to get/set the contend of STR
then insert on POSITION 7 "bb"
If this code loops, the first STR will take again the value "ah" insted of "BB" as it will use the content of position 2. The second one will use te conent of position 7.

So the first insert STR "ah" will have as result "ahah" at the second loop
Alexander Higgins
@cahiggins
that makes sense now
GiuseppeChillemi
@GiuseppeChillemi
@cahiggins After more than 10 years of REBOL it now makes sense to me too. It is important to help other users to "disconnect" to their old knowledge and connect to the new one.
I can say I am out of the matrix now !
Vladimir Vasilyev
@9214
here's another food for thought - think about how it all mixes together with bind and contexts
GiuseppeChillemi
@GiuseppeChillemi
@9214 Bind, contexts, reduce, form, mold, set, pick, blocks, system/words, parse, dialects.... I have to start over with new eyes.
there is no spoon !
I am a borg ! I am part of the group. We all say "there is no spoon". You will be assimilated to the 'NO SPOON" logic. Resistence is futile.
Vladimir Vasilyev
@9214
for that matter, the next step is to accept that there's no I
Boleslav Březovský
@rebolek
Carl has described Rebol script as series of values which is best description IMO.
Vladimir Vasilyev
@9214
@rebolek well, yeah, since script can be in various forms (block!, string!, binary!)
Boleslav Březovský
@rebolek
Yes, but it loads as block! anyway.
PeterWAWood
@PeterWAWood

Carl also refers to Rebol scripts as expressions. He says "REBOL Expressions are based on this concept: you combine values and words into blocks".

The chapter Expressions in the Rebol User Guide is pretty much essential reading.

Boleslav Březovský
@rebolek
I agree. Basically the whole book is essential reading.
geekyi
@geekyi
image.png

@dockimbel :point_up: September 29, 2017 12:13 PM

@geekyi How to do you end up with those counts?

I used a program that reads strings in memory

geekyi
@geekyi
Interestingly, I can also write to memory (notice the Blu):
image.png
geekyi @geekyi rubs hands (using this to debug the internals would be fun)
geekyi
@geekyi
This is also easier for anyone to get started with, than most other programs I tried(this particular functionality was just hidden very deep)
Nenad Rakocevic
@dockimbel
@geekyi Such extra copies could be created by the OS or the C library, as you are reading through the whole process's memory.
geekyi
@geekyi
Yes, some of them seem to be 2-byte encodings
Nenad Rakocevic
@dockimbel
That's UTF-16 strings, used by Windows API.
Gregg Irwin
@greggirwin
:point_up: September 30, 2017 1:19 AM @9214, save this somewhere. I like this explanation.
Vladimir Vasilyev
@9214
@greggirwin :muscle:, though, I need to meditate on how to blend this all together with bindology and other features nicely
Gregg Irwin
@greggirwin
Yes, but it's a nice "visual" metaphor.
GiuseppeChillemi
@GiuseppeChillemi
@greggirwin Yes, it add a missing block: code is itself memory where you store, retrieve and interpret.
Greg T
@gltewalt
Will there be a mechanism in the future to prevent code injection or 'not so nice' foreign code?
Boleslav Březovský
@rebolek
There already are such ways, construct, etc.
Gregg Irwin
@greggirwin
Dialects are also a major pattern for preventing code injection. You will likely never be able to safely do untrusted code.
Nenad Rakocevic
@dockimbel
@gltewalt do cannot be secured, but it should be possible to sandbox untrusted code, by blocking some language features.
GiuseppeChillemi
@GiuseppeChillemi
Now that I have understood "there is no spoon" I want to move to the next step: how is the code interpreted ? From loading the script to the very first steps
Gregg Irwin
@greggirwin

@GiuseppeChillemi, lexical scanning is the first step. Parsing and tokenizing the input to find Red values in the text, and determining if the input is valid. That is, it contains all valid Red values.

At that point you have a block of values. Think about how you, as a human, interpret that. You know some values are direct values, like numbers. But what happens when you find a word? You need to determine what to do. What kind of word is it? What is the behavior of each kind of word?

David Viner
@RiVeND
@greggirwin Thanks for that, Gregg :thumbsup: . I always find I have better comprehension of a system if I can picture what's going on under the hood. Maybe, when the documentation efforts get off the ground, those with more in-depth knowledge of Red could produce some simple flowcharts of what the more complex parts do (such as parse). I know they would definitely help me get a better grip on the language.
Gregg Irwin
@greggirwin

Glad if it helped a bit @RiVeND. Parse is deep, and hard to describe in prose/text, because the behavior and data mixture will be verbose. An interactive tool will be much better, so you can see what rule is being evaluated, the current location in the input, and maybe hints about keyword behavior. e.g. if ahead is evaluated, a "does not advance" indicator could light up.

There was an old parsing tool, VisualParse++, from Sandstone technology, that did something like that. It was a shift-reduce parsing tool, and was pretty cool.

GiuseppeChillemi
@GiuseppeChillemi
How datatypes are associated to each element of the block ?
Dave Andersen
@dander
@GiuseppeChillemi the elements of a block are all values, and every value has a type. All values in Red are 'boxed', and the box contains both the type and data structure which represents the value