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
@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).

Whichever terminology you personally use is completely up to you, but if you're willing to communicate with other Reducers in established (and productive) manner, while avoiding possible confusion of newcomers -- stick to our conventions and wordings.
Christopher Ross-Gill
@rgchris
@9214 Or just put caution tape on every script until a native version of USE appears.
Vladimir Vasilyev
@9214
@rgchris no one reads caution tapes nowadays.
Christopher Ross-Gill
@rgchris

@ne1uno

did rebol have a bigger problem leaking context?

Currently Rebol 2 and Red are little different in this regard.

use seems like a solution in search of a problem in red

An interesting way of looking at it. I've long found it a very tidy way of creating micro-contexts. With Rebol 3's tighter control on context, I've found it a useful way of tracking word useā€”even within modules.

hiiamboris
@hiiamboris
is it ok that replace treats it's pattern as a parse rule only when /deep refinement is provided?
it's doc-string seemingly totally omits this specific
Vladimir Vasilyev
@9214
@hiiamboris yes, look at the source.
hiiamboris
@hiiamboris
yes, that's what I did to get to the conclusion
hiiamboris
@hiiamboris
@hiiamboris You can always use (pick a 'y) < (pick b 'y).
>> p: 2x3
== 2x3
>> pick p 2
== 3
>> second p
== 3
>> pick p 'y
*** Script Error: value out of range: y
*** Where: pick
*** Stack:
maybe there was an intent to make this work, maybe not, but just sayin... it doesn't work
lepinekong
@lepinekong_twitter
I have a weird case for set: it works with one element but not with 2 : * Script Error: forall does not allow word! for its 'word argument
P: context [

    F: [
        P1: [
            name: "John"
        ]

        P2: [
            name: "Mary"
        ]    
    ]

]

set [list1 list2] compose [
    (words-of (Context (P/F)))
    (values-of (Context (P/F)))
]

; this works
set [list1] compose [
    (words-of (Context (P/F)))
]

; this doesn't work
forall list1 [
    probe list1/1
]

forall list2 [
    probe list2/1
]
Vladimir Vasilyev
@9214
@lepinekong_twitter both list* words are bound to other words (P1 and P2, respectively).
I guess that's what you want instead:
P: context [
    F: [
        P1: [name: "John"]
        P2: [name: "Mary"]    
    ]
]

set [list1 list2] reduce [
    words-of  context p/f
    values-of context p/f
]

forall list1 [probe list1/1]
forall list2 [probe list2/1]
lepinekong
@lepinekong_twitter
@9214 ah yes thanks, have always difficulty to understand bind stuff :worried:
Vladimir Vasilyev
@9214
@lepinekong_twitter there's zero "bind stuff" here.
Examine the result of compose application and you'll probably figure out that it's not what you expected.
You should have used compose/only instead, which composes nested blocks "as-is" (though compose is superfluous here, as reduce can do the same job just fine). Moreover, I don't get why you need multiple parenthesis nestings.
lepinekong
@lepinekong_twitter
@9214 thanks I never know when to use reduce or compose, will have to think about it
Vladimir Vasilyev
@9214
@lepinekong_twitter use reduce whenever you need a block of evaluated expressions, and compose when you have a "template" data with forms to fill in.
lepinekong
@lepinekong_twitter
@9214 It is now part of my ever growing list of all troubleshootings :smile: https://i.snag.gy/obuyZO.jpg
Vladimir Vasilyev
@9214
@lepinekong_twitter don't push yourself too hard :) is that a list of "flashcards"?