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
:)
GiuseppeChillemi
@GiuseppeChillemi
Yes, when I see a block I think automatically I can get its elements via integers
Boleslav Březovský
@rebolek
And you of course can. However, object is not a block.
GiuseppeChillemi
@GiuseppeChillemi
I always think that there is an uniform access method in RED or REBOL so I apply the knoledge of blocks in object as when I probe them they actually seem an block with a "make object!" just before.
It's common to abstract a rule and apply it on similar things.
But REDBOL has many so many changes that this method can't be always applied.
Boleslav Březovský
@rebolek
There's no literal form of object which may be confusing for some people. But have a look at map!, it has its literal form - #( ... ), so you can't confuse it with block, can you? And objects are more like maps in this regards.
GiuseppeChillemi
@GiuseppeChillemi
However I think that having uniform access methods make easier to handle the language.
I don't know what you mean for "literal form" but I can imagine
Boleslav Březovský
@rebolek
There is uniform access method in form of path: x/y/z, but that does not mean that you can use integers everywhere, only where appropriate.
Max
@moliad
objects have little to do with blocks. objects are not series.
Boleslav Březovský
@rebolek
Literal form is datatype specific syntax.
Map has one, object doesn't.
GiuseppeChillemi
@GiuseppeChillemi
Yes @moliad but first/second/third or obj/1 ../2 /3 is a method you could apply to object content. In fact in rebol you could use it on the third element of an object. (i.e.: probe first third obj)
Vladimir Vasilyev
@9214
@GiuseppeChillemi because third obj in Rebol is equivalent to body-of obj in Red.
GiuseppeChillemi
@GiuseppeChillemi

So, having

z: make object! [b: 0 c: 1 d: 2]

a first z returning b could be a valid access method.

@9214 Yes, now I have understood
In RED a more explicit and verbose method is used
Max
@moliad
@GiuseppeChillemi in fact /1 /2 /3 doesn't work in Rebol :smirk:
>> a: context [a: 8]
>> a/1
** Script Error: Invalid path value: 1
** Near: a/1
GiuseppeChillemi
@GiuseppeChillemi
Just had to learn the proper way to get object contend

@moliad

Yes, we have another way

>> z: make object! [b: 0 c: 1 d: 2]
>> probe pick third z 1
b:
== b:
Boleslav Březovský
@rebolek
words-of, values-of, body-of and of course object/key
Max
@moliad
@GiuseppeChillemi I know, but just clarifying
Vladimir Vasilyev
@9214
@rebolek and select.
Boleslav Březovský
@rebolek
@9214 right. And in and other esoteric stuff ;)
GiuseppeChillemi
@GiuseppeChillemi
@moliad I know you know but was me which didn't know.
:)
Boleslav Březovský
@rebolek
>> a: context [b: 2 c: 5]
== make object! [
    b: 2
    c: 5
]
>> get in a 'b
== 2
>> do bind [b] a
== 2
>> a/b
== 2
>> select a 'b
== 2
>> do reduce [first words-of a]
== 2
GiuseppeChillemi
@GiuseppeChillemi

So, lets return on my first struggle

y: [b c d]
probe context? y/1

I supposed context? y/1 returned an empty context but instead it is the global one.

Boleslav Březovský
@rebolek
it can't return empty context, word cannot be member of empty context
Max
@moliad
@GiuseppeChillemi yes, cause you created the [b c d] block on the console, so the created words where global at that moment
GiuseppeChillemi
@GiuseppeChillemi
So, which is there rule here: words on a block have the global context when not created inside a function/object ?
Max
@moliad
short answer yes
long answer, it depends.
GiuseppeChillemi
@GiuseppeChillemi
Noooo, I can't live with "depends" !
Max
@moliad
it will use the "current" context. which is the global one by default (at root of app, on the console, etc.)
GiuseppeChillemi
@GiuseppeChillemi

When I have written:

words on a block have the global context when not created inside a function/object

I meant that when created inside them they get their context which is the current one.

Max
@moliad
it is possible that if you read code and load it within some other code, it will bind some of it there, and bind some of its words to the global context, if the words are new
GiuseppeChillemi
@GiuseppeChillemi
Not as easy as it seems....
Max
@moliad
dialects have a tendency to have a bind inside somewhere... ex: foreach, binds to a new hidden context, all the words in the 'words argument (the first)
the rest stay as they where.
function dialect binds all set-words to a new inner context.
GiuseppeChillemi
@GiuseppeChillemi

If I have a:

        foreach [value] block-with-specific-context
        [
...
        ]

How do I manintain the context of block-with-specific-context

Max
@moliad
what do you mean by "maintain"?
here 'value is local to the loop.
Boleslav Březovský
@rebolek
@moliad not in Red:
>> x
*** Script Error: x has no value
*** Where: catch
*** Stack:  

>> foreach x [1 2 3][]
>> x
== 3
Max
@moliad
all the rest of the content in 'block-with-specific-context stays bound to the same value
GiuseppeChillemi
@GiuseppeChillemi
but value get its value for a block and block words could a context you may want to have on value too
Max
@moliad

@rebolek

not in Red:

>> foreach x [1 2 3][]
>> x
== 3

what! is this by design or is it an unresolved side-effect?

Vladimir Vasilyev
@9214
@moliad unresolved design.