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
Ungaretti
@Ungaretti
@9214 Thanks once more!
Wait, it says there object: :context, so they are the same?
Vladimir Vasilyev
@9214
>> same? :object :context
== true
Ungaretti
@Ungaretti
Aha!
And doesn't make object! creates and object in the same way as object? So context would be a wrapper around object
Vladimir Vasilyev
@9214
@Ungaretti well, yes, they are all aliases.
Ungaretti
@Ungaretti
:thumbsup:
BeardPower
@BeardPower
Not so much of a wrapper, but they are different.
Red/System:

Namespaces are not objects!

Even if they look like objects, namespaces only exist at compilation time, so they cannot be manipulated at run-time.

context is a namespace.
Vladimir Vasilyev
@9214
@BeardPower cool. Now you have to explain what a namespace is :wink:
BeardPower
@BeardPower
@9214 A namespace provides local contexts able to encapsulate source code.
In computing, a namespace is a set of symbols that are used to organize objects of various kinds, so that these objects may be referred to by name.
Namespaces are commonly structured as hierarchies to allow reuse of names in different contexts.
Vladimir Vasilyev
@9214

Namespaces are commonly structured as hierarchies

Except that there's no hierarchy between contexts whatsoever.

BeardPower
@BeardPower
:older_man: :bulb:
nedzadarek
@nedzadarek
@BeardPower but using the interpreter I can manipulate contexts. It is good to know such differences between compilation and interpretation.
Vladimir Vasilyev
@9214
@nedzadarek you can't manipulate contexts, only functions and objects.
Context is an internal runtime datatype, not accessible to a user.
nedzadarek
@nedzadarek
@9214 So... what am I doing here:
>> a: 1234
== 1234
>> a
== 1234
>> c: context? 'a
== make object! [
    datatype!: datatype!
    unset!: unset!
    none!: none!
    logic!: logic!
    block!: block!

>> c/a: 0
== 0
>> a
== 0
Vladimir Vasilyev
@9214
Setting word, fetching object.
nedzadarek
@nedzadarek
but c is the context of the a, right?
Vladimir Vasilyev
@9214
c is an object! that provides a context to which a is bound.
nedzadarek
@nedzadarek
So by manipulating c, I am manipulating the context of a, right?
Vladimir Vasilyev
@9214
@BeardPower are you sure that R/S namespaces are contexts, by the way?
@nedzadarek no, all you can do is to change values.
@BeardPower R/S seems to rely on static scopes, so it's not entirely correct to compare them with contexts.
nedzadarek
@nedzadarek
@9214 ok, so I can change values to whatever I want. It seems that there is the extend function that should work on object! (does not work or I am doing something wrong; works on map!). I think it is some kind of manipulation (even it is limited).
Vladimir Vasilyev
@9214
It's limited to the degree that I wouldn't call it manipulation. You can only store / fetch values via indirect reference to object! value, and it's even more limited with function!s, there you can read and modify values only from within function itself during its execution.
It would be "manipulation" if context would be an external datatype with available actions, which it is not.
nedzadarek
@nedzadarek

and it's even more limited with function!s, there you can read and modify values only from within function itself during its execution.

Isn't it because contexts of functions are gone after return?

Vladimir Vasilyev
@9214
@nedzadarek they are pushed / popped on the evaluation stack before / after function call.
Function's values block is dynamically mapped onto the stack, each time function is called, while object's values block is allocated on heap memory, and remain there once and for all (as long as object! is referenced, otherwise GC will take care of it).
BeardPower
@BeardPower
@nedzadarek No, as you change symbols of a context not the context itself.
Vladimir Vasilyev
@9214
@BeardPower not symbols, values.
BeardPower
@BeardPower
@9214 A context in R/S is what a namespace is in C/C++
Vladimir Vasilyev
@9214
@BeardPower yes, but the question was about red-context! datatype.
BeardPower
@BeardPower
@9214 Symbols can also be seen as values.
Vladimir Vasilyev
@9214
And R/S namespace / context is not a red-context!, obviously.
BeardPower
@BeardPower
That's why I mentioned R/S.
Vladimir Vasilyev
@9214
@BeardPower true, but if we're talking about symbol / value pairing in context, then you currently can only change elements in value block.
extend would allow to add new symbol / value pairs.
BeardPower
@BeardPower
A namespace holds symbols. So depending on the context they could be called values as well.
Vladimir Vasilyev
@9214

That's why I mentioned R/S.

And throwed confusion into the mix :wink:

BeardPower
@BeardPower
:smile:
I will look into the implementation.
Windows is currently driving me nuts