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
viayuve
@viayuve
0.9.5 right ?
Boleslav Březovský
@rebolek
I guess so.
Rebootr
@Rebootr
@hiiamboris You're right! in the McAfee log I found this: BehavesLike.Win32.Dropper.th, GenericRXGX-HD!9F7841A16EA4
Vladimir Vasilyev
@9214
@Rebootr please report it as a false positive. We fight an uphill battle with AV vendors whose recognize Red as "generic malware", McAfee included.
GaryMiller
@GaryMiller
Couldn't you compress the .exe file before distribution to prevent it from being falsely identified as Malware.
Semseddin Moldibi
@endo64

my one program compilation takes about 5 to 7 min

@viayuve You might compile your program with -r if it is not necessary compile without it, it would be faster (if you don't have R/S in your code of course)

GiuseppeChillemi
@GiuseppeChillemi
This message was deleted
Ops... wrong group
No... right one !

@9214
Well, I have tried the SET words-block values-block solution with no success.

test: function 
[
    action 
    passed-args-block [block!]
]
[

        args-def: [
        add 
        [
            the-path [string!]
            key [word!]
            value [any-type!]
        ]

        del
        [
            the-path [string!]
            key [string!]
        ]
    ]

        function-words: extract select args-def action 2

        set function-words passed-args-block         

]

test 'add ["a-path" "a-key" "a-value"]


probe the-path 
probe key 
probe value
"a-path"
"a-key"
"a-value"
>>>

Words set into function seems to exists after function exit:

Vladimir Vasilyev
@9214
test: function [
    action arguments
    /local
        path key value
][
    table: [
        add [path key value]
        del [path key]
    ]

    set select table action arguments
]
nedzadarek
@nedzadarek
@GiuseppeChillemi I haven't followed the discussion but:
that's because function only collect set words (+ some exception) and [the-path key value] are words.
ps. if you want post simple code snippets that people would run in the repl then avoid unnecessary new lines (e.g. after function, after first ]. Your code might compile but it won't run correctly in the repl.
GiuseppeChillemi
@GiuseppeChillemi
@9214 is there any solution without enumerating words in the argument block ? I would have the table block as the only source of words.
@nedzadarek what Is the REPL?
Respectech
@Respectech
@GiuseppeChillemi REPL is the Red console. It is a generic term for a console that takes commands and executes them.
nedzadarek
@nedzadarek
@GiuseppeChillemi google is your friend: read–eval–print loop (source). Just like Red's console:
1) it reads what you type
2) evaluates it to some data
3) print that data to the user
4) go to 1 till you close the console
More in-depth information in the source.
Greg T
@gltewalt
@GaryMiller Yes, compressing it with upx tends to be a workaround
@viayuve Are you using -c option to compile as you work. It’s much faster than -r (release mode).
You should only need release mode when your ready to distribute the binary. Release mode might take awhile, but it’s a one time thing
GiuseppeChillemi
@GiuseppeChillemi

@nedzadarek

ps. if you want post simple code snippets that people would run in the repl then avoid unnecessary new lines (e.g. after function, after first ]. Your code might compile but it won't run correctly in the repl.

Those "unnecessary" new lines avoid me being confused. Words are isolated and clear and there are not so many symbols that my mind have to decode.

GiuseppeChillemi
@GiuseppeChillemi
It seems there is no other way to have "local" words in a function other than the argument block (I have not found one). I have tried Bind 'word self with no success. Now I am wondering if SET could have a /current context refinement, to express the context that RED automatically adds to words. Another way would be to have a SET/BIND where you can express one in some way as argument of SET.
GiuseppeChillemi
@GiuseppeChillemi
I have tried even binding directly passing the current function name with no result:
test: function []
[
        set 'should-be-local "You should not see me"
        bind 'should-be-local 'test
]
probe should-be-local 

== "You should not see me"
>>
Boleslav Březovský
@rebolek
of course, that's the expected result
GiuseppeChillemi
@GiuseppeChillemi
@rebolek , I do not expect this but and error 'should-be-local should not be in the global context.
Toomas Vooglaid
@toomasv
@GiuseppeChillemi I don't think you should expect people to first correct your formatting and then advise you:
>> test: function []
*** Script Error: function is missing its body argument
*** Where: function
*** Stack:
Christian Ensel
@gurzgri
@GiuseppeChillemi , function is auto-localising only set-words and using set with a lit-word explicitly bypasses that mechanism, adding should-be-local to the global context. Even if should-be-localwould've been declared in the function's context, bind 'should-be-local 'test would rebind it to the context thetest word is bound to. With the context of the testword being the global context rather than the function's context (as you seem to assume).
The main question probably is why you would need a way to have local words in a function by other means than declaring them in the argument block at all.
GiuseppeChillemi
@GiuseppeChillemi
@toomasv Tooms, I have never tested my own code from coping and paste from gitter. Thanks to your example I have now realized that writing on the REPL console causes this problem. I thought @nedzadarek complain was about my "uncommon" formatting and not about unusability.
GiuseppeChillemi
@GiuseppeChillemi

@gurzgri Having a lot of functions operating on the the same kind of dataset, usually you have identical or simular arguments block.

I am experimenting a "simpler" approach which let me express in a way like:

db 'add-table [arguments]
db 'delete-table [arguments]
db 'add-row [arguments]

This because, as I have written: [arguments] is the same for 2 or more functions. Selecting them from a table let me:

1) Change the argument interface once and for all
2) Save a lot of typing
About this point I have still not show the block of code which maps an arguments to multiple methods.

mapping: [
   arguments-block-name-a [method1 method2 method3]
   arguments-block-name-b [method4 method5]
]

or another one (have to choose)

mapping: [
   method1 arguments-block-name-a 
   method2 arguments-block-name-a
   method3 arguments-block-name-a
   method4 arguments-block-name-b
   method5 arguments-block-name-b
   ]

(In my mind I see also function composing built from tables of code but If I won't solve this problem I can't further experiment)

GiuseppeChillemi
@GiuseppeChillemi

@gurzgri

Even if should-be-localwould've been declared in the function's context, bind 'should-be-local 'test would rebind it to the context thetest word is bound to. With the context of the testword being the global context rather than the function's context (as you seem to assume).

If I had a way to express bind this word to test function inner context and not to the outher (global) one. But SELFseems it doesn't exists and this is now blocking.

Christian Ensel
@gurzgri
@GiuseppeChillemi There may be other ways, e.g. something like
spec: [add-table delete-table [db table] add-row [db table row]] ;-- function specs 
code: [add-table [a: 1] delete-table [b: 2] add-row [c: 3]]      ;-- function bodies

db: object collect [foreach name spec [all [
    word? name
    keep reduce [to set-word! name 'function first find find spec name block! select code name]
]]]

? db
GiuseppeChillemi
@GiuseppeChillemi
@gurzgri Yes, it is another way.
But a question remains: why SELF isn't available for functions ?
Is it planned ?
Christian Ensel
@gurzgri
@GiuseppeChillemi , Sorry, I can't make any statements on Red features planned/not planned. I know of no use cases which would require it.
GiuseppeChillemi
@GiuseppeChillemi
@gurzgri extending the words of a function and binding them to the function inner context actually seems an use case.
Christian Ensel
@gurzgri
@GiuseppeChillemi With extend on objects being reserved for future use (or not yet implemented) it seems having selfin functions wouldn't gain you anything for now (I may be missing something here). Why not just have a function local word set to a map! and extend that if you think that's the way to go?
GiuseppeChillemi
@GiuseppeChillemi
@gurzgri Christian, I feel that something is missing not having the ability to access SELF for functions and if you want dynamically add some words from the inner of it, you simply can't do it. But maybe I am still to "young" to express a more argumented opinion.
About EXTEND, I know you can't actually extend an object and I'll wait with curiosity in mind how it will be implemented.
hiiamboris
@hiiamboris

But a question remains: why SELF isn't available for functions ?

@GiuseppeChillemi It's easy: self is used mostly inside object's functions to address that object. If it was overridden inside a function, you wouldn't be able reference the object anymore.

GiuseppeChillemi
@GiuseppeChillemi
@hiiamboris what you mean for overriding It in a function as It does not exists ?
Christian Ensel
@gurzgri
@GiuseppeChillemi Given selfwould be available in functions to access a function's context, self would no longer be available to access the context of a function's outer (object) context. Which is an ubiquitous pattern with OOP, and no doubt used in large codebases.
JLCyclo
@JLCyclo
yep! About github and repository red/community... I would like to add a script in the repository, but I can't make the pull request.. I click "create pull request" on github but nothing appears...
I made a fork: cyclo07/community and I woul like to create a pull request for red/community
GiuseppeChillemi
@GiuseppeChillemi

@gurzgri

@GiuseppeChillemi Given selfwould be available in functions to access a function's context, self would no longer be available to access the context of a function's outer (object) context. Which is an ubiquitous pattern with OOP, and no doubt used in large codebases.

I have read the article. In my scenario, a function is like an encapsulating object for words and functions but it has no way to access extend itself using SELF. It is somehow more limited than an object. While the encapsulator object method to have local variables and access them from the inner function solves thing, it forces to use a OBJECT-NAME/FUNCTION-NAME notation where FUNCTION-NAME is shorter and more readable.

GiuseppeChillemi
@GiuseppeChillemi
@gurzgri
I can see why function SELF could override SELF of the encapsulator object. Also like a newbye I could suggest having SELF with parents to navigate SELVES backwards if possible but I imagine is not so easy. Regarding this topic I have read there is no backlink in blocks and @9214 once "suggested" to read the code and try to write a double linked table (or something like this). Maybe it is the same reason why we have not nested SELVES which are backward accesible.
nedzadarek
@nedzadarek

@GiuseppeChillemi about "unnecessary" lines:
You can always edit it in the browser. Choice is yours.

About local words:
There are probably many ways to simulate it. You can keep local words in a map (1) or bind body words to some context (2).
1) f: function [/local local-words] [local-words: #() local-words/should-be-local: 42]
2) g: function [] bind [should-be-local] context [should-be-local: 42]

GiuseppeChillemi
@GiuseppeChillemi
@nedzadarek What you mean for "you can always edit in the browser" ?
About solution number 2: I do not understand it ;-)
Semseddin Moldibi
@endo64
@JLCyclo You should click on the Pull request link on your own fork: https://github.com/JLCyclo/community
Here you can see:
image.png