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
Boleslav Březovský
@rebolek
Every word declared in function header exists in function context.
Vladimir Vasilyev
@9214
@nedzadarek what you said in "Red will just create 3 variables ..." I interpreted as "Red will populate global context with 3 new words set to some value".
nedzadarek
@nedzadarek
@9214 Well... you are right. I just assumed "local variables" by saying "variables". My bad. Sorry for confusion!
Vladimir Vasilyev
@9214
@rebolek do I sound like a pedant to you?
Anyway, once more with pedantry - words, not variables!
Boleslav Březovský
@rebolek
@9214 yes, but is that wrong?
9214 @9214 shrugs
nedzadarek
@nedzadarek
Are the word... no... the term "variables" wrong? I mean word doesn't have to refer to some value (reduce first [w]; *** Script Error: w has no value).
Vladimir Vasilyev
@9214
@nedzadarek variables are direct 1-to-1 mapping between some identifier and some value, words are indirect, they always refer to some context, not to the value.
nedzadarek
@nedzadarek
But they refer to value in some context. For example bind bl: [print a] c: context [a: 42], word a in the block bl refers to the the identifier a in the context c.
Boleslav Březovský
@rebolek
Vladimir Vasilyev
@9214
@rebolek we're doomed.
nedzadarek
@nedzadarek
:sparkles:
Nenad Rakocevic
@dockimbel
Yes, Carl used the name "variable" to make it easier to understand for newcomers. Though, I think that is misleading, as most newcomers will think words are like the "variables" they know about in other languages. That's why I'm rather in favor of telling people from the start that word <> "variable", in order to draw their attention to the specific way values are referenced by symbols in Redbol.
Vladimir Vasilyev
@9214
@nedzadarek "But they refer to value in some context" - it's a re-phrasal of what I said. Word refers to a context, and word's binding always resolves to one symbol.
Whenever someone says "variable" they automatically imply lexical or dynamic scopes that comes with them from other languages, and confusion starts.
Scopes imply some "meaning hierarchy" for variables, and that's not the case in Redbol - there's no hierarchy, there're only namespaces (contexts), completely separated one from another.
nedzadarek
@nedzadarek
@9214 it's not re-phrasal. You can store variables however you want (array, map, tree) but you still get 1 to 1 mapping.
Vladimir Vasilyev
@9214
@nedzadarek I don't understand what you're saying.
@nedzadarek it's not 1-to-1, as it can change at any point in run-time.
Not a value of the variable, but a context of the word.
You can either change a context or a value in a given context.
nedzadarek
@nedzadarek
hmmm
nedzadarek
@nedzadarek
You can change the context but does it means it's not 1-to-1? I mean foo can only mean 2 things:
a) some value
b) no value
Word can only refer to one context, hence, 1-to-1 mapping.
Vladimir Vasilyev
@9214
Tell me what you mean by "1-to-1 mapping".
Jose Luis
@planetsizecpu
HAHA, oh guys you make me remind my headstrong times (still today) :)
Vladimir Vasilyev
@9214

Word can only refer to one context

Word can refer to any context at any point in run-time.

nedzadarek
@nedzadarek
@9214 v: 1 => v refers only to 1 value, 1.

Word can refer to any context at any point in run-time.

Yes, but only 1 at time, right?

Vladimir Vasilyev
@9214
For Pete's sake...
@nedzadarek do you understand how words/context mechanic works?
nedzadarek
@nedzadarek
Yes, more or less:
b: 42
b-context: context? 'b
b-context/b
Vladimir Vasilyev
@9214
@nedzadarek do you understand how variables work, as in other mainstream languages?
nedzadarek
@nedzadarek
Yes
Vladimir Vasilyev
@9214
I tend to interpret your "Yes, more or less" as "No".
@nedzadarek do you think that words/context mechanic is different from variables mechanic, or do you think that they are the same?
nedzadarek
@nedzadarek
Similar I guess... but I cannot say with 100% certainty because I don't understand a lot languages that deep.
Vladimir Vasilyev
@9214
So you don't know/understand the difference, but you keep arguing that words are variables, as in other PLs?
nedzadarek
@nedzadarek
There are a lot of languages that uses "variable". Every language differs. Variable = value that can change over time.
Vladimir Vasilyev
@9214
@nedzadarek but variable itself is not a value, right?
Words is a value that can indirectly refer to other values. Variable is just a pairing between identifier and memory location.
Word can refer to (be bound to) different contexts, but context is not a value (in "variable" sense) itself, and not a memory location where this value resides.
nedzadarek
@nedzadarek
Similar stuff you can do in Ruby (you don't do this very often but... you can). @secret is still a variable (taken from: http://ruby-doc.org/core-2.4.0/Binding.html ):
class Demo
  def initialize(n)
    @secret = n
  end
  def get_binding
    return binding()
  end
end

k1 = Demo.new(99)
b1 = k1.get_binding
k2 = Demo.new(-3)
b2 = k2.get_binding

eval("@secret", b1)   #=> 99
eval("@secret", b2)   #=> -3
eval("@secret")       #=> nil
Vladimir Vasilyev
@9214
unnamed0.png
@nedzadarek what you seem to call a "variable" is a binding + relation between symbol ID and value inside context.
Which doesn't make much sense, because context can contain only one such pairing between symbol ID and value, i.e. it's implied.
Vladimir Vasilyev
@9214
Word is a separate value (any-word!), and context is provided by separate values (object! or function!). Binding is a relation between two separate entities, which you can manipulate at run-time (words and functions/objects). Variable, on the other hand, is a way to reference a value, but not a relation between the two values.
Vladimir Vasilyev
@9214
It's a bit different under the hood (there're nodes, symbol table and symbol IDs, value slots, etc), but the idea is the same.
Vladimir Vasilyev
@9214

@nedzadarek since "variable is a way to reference a value", "variable" (in your interpretation) can be either:

  • a way to reference a value that provides a context (but that's not a "variable", it's a "binding");
  • a way to reference a value in a context (which is done indirectly by word's binding and implied);
  • how symbol ID is related to a value slot (which is just a key/value association, loosely speaking).

Word is not a variable in any of these cases, it never refers to the value directly, it's always refers to a context provided by some value (either by object on the heap or by function on the call stack).