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
Rebol2Red
@Rebol2Red
Just tested it. Everything seems to work now. Many Thanks!
hiiamboris
@hiiamboris
:+1:
Rebol2Red
@Rebol2Red
Btw As far as i know is the tick before View not needed anymore
hiiamboris
@hiiamboris
Yeah, you're right
Rebol2Red
@Rebol2Red
Thanks for confirming this. Now i know for sure.
Nenad Rakocevic
@dockimbel
@vazub cos is the C-like version, concise and accepting radians, convenient for (complex) math expression. cosine is the human-friendly version, accepting degrees and not having a mangled name.
Nikita Korotkin
@TheHowdy_gitlab
@hiiamboris thx
VaZub
@vazub

@vazub cos is the C-like version, concise and accepting radians, convenient for (complex) math expression. cosine is the human-friendly version, accepting degrees and not having a mangled name.

Thanks for the reply, @dockimbel ! So this is merely a convenience function, for specific use cases? Interesting. However, cosine seems to accept radians as well, with /radians refinement and is of native! type, which, in my limited understanding should provide some performance benefits - is that correct? Unless I am missing something else here, I am unsure what additional cases would justify for me using cos instead of cosine, aside of somewhat lesser verbosity.

And by the way, speaking of some possible additional redundancy: %, //, mod, modulo, remainder also confuse me a little bit in terms of choice. Aside of being used in either infix or prefix scenarios, how should one proceed with deciding on what should be the most appropriate for their case? Help description states that modulo "handles errors like REMAINER", but no further details are given, so this seems to be quite abstract for me as a newcomer still.

and just a bit above there are points on what to use
Gregg Irwin
@greggirwin
@dockimbel do you and the deep core want to weigh in on :point_up:
GiuseppeChillemi
@GiuseppeChillemi
If an argument is defined as: :arg, which is the difference from 'arg' when passing an integer or other arguments which are not functions? Is it equivalent or it is different in some way ?
hiiamboris
@hiiamboris
try passing a paren to it
Semseddin Moldibi
@endo64
We may add below difference to the wiki:
f: func [:a] [probe a]
f myword
; R2  == ** Script Error: f is missing its a argument
; R3 & Red  == myword
Dmitry Bubnenkov
@bubnenkoff

is there any difference between:

>> a: "aaa"
== "aaa"
>> b: a
== "aaa"

and

>> a: "aaa"
== "aaa"
>> b: :a ; colon before a
== "aaa"
Boleslav Březovský
@rebolek
Not in your case, a evaluates, while :a does not, but string evaluates to itself, so it's same. But there are types where it makes difference.
GiuseppeChillemi
@GiuseppeChillemi
Functions, lit-words and.. ?
I remember a document written by Vladimir on this topic but I can't find it.
Boleslav Březovský
@rebolek
certainly parens and also other function-like types (natives, ops, actions, ...).Maybe I missed something
GiuseppeChillemi
@GiuseppeChillemi
You can't insert into a block a RANGE (from position/to position) of another block and keep the link, can it ? You can do this only using copy but you loose the link capabilities.
Gregg Irwin
@greggirwin
Correct. There is no concept of block "slices" in Red. I would say "at this time" but while it comes up in chat occasionally, it's not on our roadmap.
GiuseppeChillemi
@GiuseppeChillemi
@greggirwin It seems there are discussions dated back to 2004 ;) I have just found this
hiiamboris
@hiiamboris
Shows how high demand is ;)
GiuseppeChillemi
@GiuseppeChillemi
Resistance is futile, someday your blocks will be sliced and assimilated in a composite one.
GiuseppeChillemi
@GiuseppeChillemi

I am studing function passing throught function Inferface. I supposed

f: func [:arg][type? :arg] 
probe f print
Gives the same result as:
f: func [arg] [type? :arg]
probe f :print

REBOL has the same native!result, while for Red print is just a word in the first situation.

REBOL:

>> f: func [:arg] [type? :arg]
>> probe f print
native!
== native!
>> f: func [arg] [type? :arg]
>> probe f :print
native!
== native!
>>

RED

>>  f: func [:arg] [type? :arg]
== func [:arg][type? :arg]
>> probe f print
word!
== word!
>>  f: func [arg] [type? :arg]
== func [arg][type? :arg]
>> probe f :print
native!
== native!
>>

It is not mentioned in RED-REBOL Differencies and also I do not know if it is intended.

hiiamboris
@hiiamboris
It is
GiuseppeChillemi
@GiuseppeChillemi
I don't understand the reason. Could you explain?
hiiamboris
@hiiamboris
I can only guess ☻ Maybe for more control?
This behavior is inherited from R3 btw
Do you like this in R2?
>> probe quote print
native
GiuseppeChillemi
@GiuseppeChillemi
I have learnt something new, thanks.I will propose to add an entry to the differences document on red/doc
hiiamboris
@hiiamboris
Strictly speaking it's R2/R3 difference ;)
Dmitry Bubnenkov
@bubnenkoff
Why if we can change value of f by assigning body-of to b, but can't change a by using b in last few line:
>> f: func[] [v: [] append v "aa"]
== func [][v: [] append v "aa"]
>> f
== ["aa"]
>> f
== ["aa" "aa"]
>> f
== ["aa" "aa" "aa"]
>> 
>> b: body-of :f
== [v: ["aa" "aa" "aa"] append v "aa"]
>> 
>> b/2/1
== "aa"
>> b/2/1: "cc"
== "cc"
>> 
>> f
== ["cc" "aa" "aa" "aa"]
>> 
>> 
>> a: "aaa"
== "aaa"
>> b: a
== "aaa"
>> 
>> b: "bbb"
== "bbb"
>> a ; a still aaa
== "aaa"
>>
Boleslav Březovský
@rebolek
Because you reassign where b points to. If you need to change a from b, you need to change the block directly, not just reassign b:
>> a: "aaa"
== "aaa"
>> b: a
== "aaa"
>> change b "bbb"
== ""
>> a
== "bbb"
Oldes Huhuman
@Oldes
@bubnenkoff I don't know what you want to achieve, but what you do now is a way for a trouble! You don't have defined v inside the function as a local, so once you call the f function, the value v will be global! Check this in fresh console:
>> f: func[] [v: [] append v "aa"]
== func [][v: [] append v "aa"]
>> v
*** Script Error: v has no value
*** Where: catch
*** Stack:  

>> f
== ["aa"]
>> v
== ["aa"]
I'm quite not sure if it is good that body-of does not copy the function body like Rebol does so you can mess with it like @bubnenkoff does.
ne1uno
@ne1uno
foot: the: self: shoot: your: unset!
^H^H^H^H woops
Gregg Irwin
@greggirwin
Identifying the real goal is key. There may be easier ways.
GiuseppeChillemi
@GiuseppeChillemi

Is this hierarchy of values retrieving I am looking at ?
Who told f2 to take the context of f and associate to it's a in place of system/words ? Has the context of a in f2 been set at function definition or at runtime ?


a: 22
f: func [/local a] [a: 33 
    f2: func [] [print ["A value: " a]]
        f2
]


f
;f2

Result

 A value:  33

(Note, the commented f2 if removed prints "a value: 33" in R2 and "Context for a is not available" in Red for reasons already explained from Vladimir months ago.)

hiiamboris
@hiiamboris
body of f was bound at the time of func evaluation
GiuseppeChillemi
@GiuseppeChillemi
@hiiamboris could words with no context exist and be at runtime automatically associated with the current one (if the concept of "corrent context" exists, because it seems to me we have not a current one).
hiiamboris
@hiiamboris
no and no ;)
GiuseppeChillemi
@GiuseppeChillemi
A double no, bingo !
The context is defined at loading and creation.
GiuseppeChillemi
@GiuseppeChillemi

Another question:

when inside a function you encounter set words to static structures like:

a: "hello word!"

And you use the function multiple times, what actually happen at each round when the set-word is found ?

1) The link between the word and the context with the value is set again ?
2) It's just a printout of the things as they actually are.

hiiamboris
@hiiamboris
1) yes
2) I don't what you mean here
you can test things yourself with probe and context? btw
GiuseppeChillemi
@GiuseppeChillemi

2) For a moment I supposed the SET WORD had already a link to the context and the string. But I remembered its a dynamic connection.

About encountering a set word in a funcion:
Set word to a literal: associates word -> context(word) and sets the (word) value to the literal on the right of the set word, even if it already the same. (Set = copy)
Set word to a static structure: sets the link of the word to the static structure in the context, even if the link is already present (Set = link)

GiuseppeChillemi
@GiuseppeChillemi
word -> contexts(word)-Value are dynamic and continuously established at runtime. If you have a set word to a static structure during the program flow, even if already established, Red re-sets the value in the context to the same structure. In other words, there is no connection between set word and the element on the right if the program is not running (code = data) but it is established when it is being interpreted.