cosis the C-like version, concise and accepting radians, convenient for (complex) math expression.
cosineis 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:
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.
I am studing function passing throught function Inferface. I supposed
f: func [ ] 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
>> f: func [:arg] [type? :arg] >> probe f print native! == native! >> f: func [arg] [type? :arg] >> probe f :print native! == native! >>
>> f: func [:arg] [type? :arg] == func [ ] >> probe f print word! == word! >> f: func [arg] [type? :arg] == func [ ][ ] >> probe f :print native! == native! >>
It is not mentioned in RED-REBOL Differencies and also I do not know if it is intended.
>> probe quote print native
b, but can't change
bin 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" >>
vinside the function as a local, so once you call the
ffunction, the value
vwill 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"]
body-ofdoes not copy the function body like Rebol does so you can mess with it like @bubnenkoff does.
Is this hierarchy of values retrieving I am looking at ?
f2 to take the context of
f and associate to it's
a in place of
system/words ? Has the context of
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
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.)
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.
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)