## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### 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
change num-list: [] to num-list: copy []
pimgeek
@pimgeek
change num-list: [] to num-list: copy []
Oh, thanks very much! I will have a try
Boleslav Březovský
@rebolek
@pimgeek good idea :) If you have any questions, feel free to ask. Just a note, in Red, functions do not use (...) for arguments. It works in your case, because your function has just one argument and parenthesis evaluate all values and return last. So (3) in your case becomes 3. But if you'll have function with more than one arg, it won't work.
pimgeek
@pimgeek
oh, my god ... I mistyped it and didn't notice
I have checked the manual and found the following BEGGINER MUST KNOW, thanks for your kind help, I will finish all of BEGGINER's reading.
Boleslav Březovský
@rebolek
You're welcome!
pimgeek
@pimgeek
BTW, is there anything in Red like (let ... ) in the Lisp language?
I mean, data "processing" without side effects?
bitbegin
@bitbegin
>> range: function [num [integer!]][list: clear [] repeat i num [append list i] list]
== func [num [integer!] /local list i][list: clear [] repeat i num [append list i] list]
>> range 10
== [1 2 3 4 5 6 7 8 9 10]
>> range 10
== [1 2 3 4 5 6 7 8 9 10]
>>
Boleslav Březovský
@rebolek
In Red, words have their value based on context in which they are defined, so it possible to do something like let, but differently.
>> a: context [b: 1 print b context [b: 3 print b] print b]
1
3
1
@bitbegin or you can use collect and get rid of local block:
>> range: func [num][collect [repeat i num [keep i]]]
== func [num][collect [repeat i num [keep i]]]
>> range 5
== [1 2 3 4 5]
bitbegin
@bitbegin
:+1:

@9214 @greggirwin

create some words

When you use parse you can set words to some value, for example in parse [a] [set w word!], parse creates word w.

Fixed it for you.

No. You are wrong.

There's plenty of functionality to make it work the way you want, but you seem to ignore all of it so as to strengthen your argument.

Why do you think I'm using function by default? It's the closest to a "I don't care, just don't mess global space - make everything local" attitude. I'm not ignoring anything - it's just they are less suited to more complex code. Let's dissect your examples.

f: func [/local z][parse [a][set z skip]]

You have only one local word z. What if you have 10 or 20 words that have more than 4 characters in it? For example:

f: func [
][..]

You are making code longer (harder to understand, even it's by "a little).

f: does [parse [a] bind [set z skip] context [z: none]]

You find this in someone's code. What's the purpose of the bind here? You have to go to the context to see whenever or not someone are changing some core functionality of the parse. It makes code less readable.

You can even intercept set and copy within callback function and aggregate their arguments for further post-processing.

>> f: function [] [
[    probe unique also words: [] parse/trace [a b c][
[        ahead [copy a [3 word!]]
[        copy c [2 skip]
[        set  d to end
[    ] :callback
[    unset words
[    ]
== func [/local words][
probe unique also words: [] parse/trace [a b c] [ahead [co...
>> a
*** Script Error: a has no value
*** Where: catch
*** Stack:

>> a: 42
== 42
>> f
[]
>> a
== [a b c]

Yes, it's that easy.

What was it with your "no choice" once again..?

If you are going to say I have choice because the language is (is it?) turing complete then you should check what is the Turring tarpit. Is it the turring tarpit? I guess no... but It starts to depart from the Rebol's motto "Rebol against complexity". Especially your binding code.

pimgeek
@pimgeek
😍 So much precious knowledge sharing~
pimgeek
@pimgeek
@nedzadarek Thanks for quoting the Turing-Tarpit anecdote, it's really mind-refreshing 🤯
pimgeek
@pimgeek
@rebolek the collect ... keep procedure is amazing, if you don't show me the code, I would have to struggle much more to understand if by reading the manual 👍😊
@bitbegin Thanks for demonstrating the usage of clear 👏
@pimgeek If you liked collect then you could try cold.
pimgeek
@pimgeek
@nedzadarek Okay, I will star it and create a reference in my TheBrain KB 👌
Do you know whether I can declare a constant value in Red lang?
pimgeek
@pimgeek
Boleslav Březovský
@rebolek
@pimgeek you can't (yet).
pimgeek
@pimgeek
@rebolek thanks for confirming that 👌
Max
doesn't red support a macro prepropressor built-in? or is that just for R/S?
Boleslav Březovský
@rebolek
Hm, it does, I guess. But if you're in console, it doesn't help you very much.
Max
but constants don't really make sense in a console anyways ;-)
Boleslav Březovský
@rebolek
well for testing, they do
@pimgeek nice visualisation - can we see it online?
@9214

Why do you think I'm using function by default?

Because you're naive enough to think that it can cover all cases properly, and take care of set and copy in Parse.

it's just they are less suited to more complex code.

Maybe the problem is in your code then? As you yourself so boldy affirmed: but It starts to depart from the Rebol's motto "Rebol against complexity"

Straw man fallacy. Do you understand how ridiculous it is to "dissect" one-liners written for demonstrative purpose? They show an idea, not an implementation.

What if you have 10 or 20 words that have more than 4 characters in it?

Then you probably should reconsider your design approach.

whenever or not someone are changing some core functionality of the parse. It makes code less readable.

I have a hard time trying to follow this argument. Purpose of bind is evident here, and you can change "core functionality of Parse" from Red, because it's a parsing engine written in R/S.

Yes, it's that easy.

If you try to discredit me, at least do so properly:

>> f: function [][
[        callback: func [event match? rule input stack][
[            also yes if all [match? find [set copy] first rule][
[                append words rule/2
[            ]
[        ]
[
[        probe unique also words: [] parse/trace [a b c][
[            ahead [copy a [3 word!]]
[            copy c [2 skip]
[            set  d to end
[        ] :callback
[
[        unset words
[    ]
== func [/local callback words][
callback: func [event match? rule input stack] [also yes if all [match? find [set copy] first rule] [append words...
>> reduce [:a :b :c]
== [unset unset unset]
>> set [a b c][1 2 3]
== [1 2 3]
>> f
[a b c]
>> reduce [:a :b :c]
== [unset unset unset]

Above works as expected, contrary to your claim.

If you are going to say

Oh, no, I'm not going to say anything. Seeing how you don't have anything constructive (or original) to add to this discussion, I'm rather disinterested in continuing it. Arguing for the sake of arguing is solely your prerogative.

Boleslav Březovský
@rebolek
I think that the discussion can be less personal.
@9214

@pimgeek

is there anything in Red like (let ... ) in the Lisp language?

let: func [environment body][
do bind copy/deep body context environment
]

set [a b][1 2]

let [a: 3 b: 4][
probe a + b
]

probe a + b

@9214

Because you're naive enough to think that it can cover all cases properly, and take care of set and copy in Parse.

Straw man fallacy. Do you understand how ridiculous it is to "dissect" one-liners written for demonstrative purpose?

I'm sorry. I should have used different word. I guess "examine" should be better.

Then you probably should reconsider your design approach.

https://github.com/red/red/blob/master/runtime/allocator.reds#L466

Purpose of bind is evident here,

Yes, it's easy to understand. You know why? Because it's just one line. When you write more line you will start to understand this.

and you can change "core functionality of Parse" from Red, because it's a parsing engine written in R/S.

Not sure why mentioned R/S but I agree, I can change (at least some part) parse.

If you try to discredit me, at least do so properly:
Above works as expected, contrary to your claim.

So, do you expect to destroy some words from some other context? Well, I'm not sure why you corrected it. I'm really confused about this code. We were talking about "local words in the function" (how to make it local) and your function changes/delete those words (and it shouldn't do this)

Oh, no, I'm not going to say anything. Seeing how you don't have anything constructive (or original) to add to this discussion, I'm rather disinterested in continuing it. Arguing for the sake of arguing is solely your prerogative.

I'm sorry. I believe in my arguments but I cannot explain it clearly to you. It might be my knowledge (language and/or programming).
I respect you for your knowledge and willing to help others so I, as you said, I don't want to waste your and mine time.
I'm fine If you don't want to answer to this post.

GiuseppeChillemi
@GiuseppeChillemi
I would try to create self generating code from "specs", either as function, or objects or parse code to create a DSL.
Could I define an object and then make it even if not defined at code start ?
Could I do the same with a function ?
Is there any code I could not create dynamically in RED ?
Boleslav Březovský
@rebolek

Is there any code I could not create dynamically in RED ?

No.

@nedzadarek @9214 I think that there's a misunderstanding. There are no "local words in the function" in Red/Rebol. There are only words that belong to some context and that's what some people don't understand and some people can't explain. But only patient explanation can bring understanding, restlessness is just a distraction. There should be some Zen of Red guide that can calm everyone down.
GiuseppeChillemi
@GiuseppeChillemi

In RED Blog I have read :

Still some features are not yet implemented:

## building a function at runtime (requires the ability to JIT-compile source code)

Boleslav Březovský
@rebolek
@GiuseppeChillemi that's a statement, not a question. It's not implemented, yes.
GiuseppeChillemi
@GiuseppeChillemi
@rebolek It's me who has written this the gitter question and I was asking if this affirmation is still valid.

It's not implemented, yes.

Do you mean "yes, you can't build a function at runtime, this affirmation is valid " ?

Boleslav Březovský
@rebolek
Yes, you can't build a function in Red/System at runtime, this affirmation is valid.
It's really low priority.
It would be nice to have, but compiling is so easy that it's really not a problem.
GiuseppeChillemi
@GiuseppeChillemi
@rebolek Excuse my ignorance: what does mean "building a function at runtime ?" could you make an example ?