r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3-OLD1]

Volker
12-May-2006
[942]
'g-checks and 'g are the same, typo.
Ladislav
12-May-2006
[943x2]
example of a control function where it would be useful: control functions 
usually have to ignore non-local returns (rethrow them or whatever 
we call the behaviour), because they are meant for different purposes. 
If we want/need to use return in a control function, we have to use 
a specific (local) return to discern it from non-local returns
so the purpose of local return in a control function may be the same 
as the purpose of ordinary return in ordinary functions
Volker
12-May-2006
[945x2]
What we currently flag with func[[throw]] ?
I understand control-function as  'forall and friends.
Ladislav
12-May-2006
[947]
Volker: yes, to both questions. It is possible that users find other 
applications for functions with local return, though.
MichaelB
12-May-2006
[948]
But wasn
Ladislav
12-May-2006
[949]
anyway, this is a design stage, so the things may change as I understood
MichaelB
12-May-2006
[950]
sorry - was in send on return mode


but wasn't in one of Ladislavs articles already something about these 
two types of return ? this is about the same then ... just looked 
different to me
Ladislav
12-May-2006
[951]
yes, this means we will have some features I described available 
natively
MichaelB
12-May-2006
[952x2]
so the question or discussion is mainly about these two distinct 
types of return and not something else .... because to me it looks 
(outside of this use), also quite disturbing or weird if people start 
to leave a nested functions suddenly to somewhere maybe not immediately 
visible
ok
Volker
12-May-2006
[954]
MAybe some hinting in the control-func? How about a 'catch which 
knows its function-name? and throw/to res 'func-name? Would still 
be short. Although if he have
 a -> b -> c 
and c return to a, 'b must call in that way too.
MichaelB
12-May-2006
[955]
How is this control func thing solved with macros in lisp - I'm just 
curious but whould have to look that up, does somebody know this 
out the mind immediately ? (is it different because kind of preprocessed 
before actually used)
Ladislav
12-May-2006
[956]
I think that different interpreters/compilers of Lisp use different 
solutions.
JaimeVargas
12-May-2006
[957x2]
Well. Lisp has only maybe two control mechanisms, one is tail-recursion, 
and the second call-with-current-cotinuation (kind of goto but with 
the context stack maitain). You can build any other control mechanisme 
from loops to preemptive-threading with this two constructs.
The macros are just a way to do syntactic-enhancement. In a sense 
they are just templates to basic constructs.  But this templates 
are quite 'smart'
Henrik
14-May-2006
[959]
I've been wondering about an extension to EXTRACT as I haven't been 
able to find this particular functionality anywhere else. If it exists, 
then I'm wrong and you can ignore this.


I would like to propose adding a /size refinement to set the number 
of values extracted at each point. This would make it very easy to 
split a string in equal-sized chunks. It could also be used to retrieve 
equal sized parts of a set of database records. Combining this with 
/index, I think this could be very useful.

Here's how I would like it to work:

>> block: [1 2 3 4 5 6 7 8 9]
>> extract block 2
== [1 3 5 7 9]
>> extract block 4
== [1 5 9]
>> extract/index block 2 2
== [2 4 6 8 none]

The refinement at work:

>> extract/size block 4 2
== [[1 2] [5 6] [9 none]]
>> num: to-string 123456789
== "123456789"
>> extract num 3
== [#"1" #"4" #"7"]
>> extract/size num 3 1
== ["1" "4" "7"]
>> extract/size num 3 2
== ["12" "45" "78"]
>> extract/size num 3 3
== ["123" "456" "789"]
>> extract/size num 3 5
== ["12345" "45678" "789"]
>> extract/size/index num 3 5 2
== ["23456" "56789" "89"]
>> extract/size num 3 12
== ["123456789"]

/size would always return a block of series.
Gregg
14-May-2006
[960x5]
Looks like it could be useful Henrik. I might call the refinement 
/part, to match other funcs. For the case of splitting a series into 
equal-sized pieces, or a fixed number of pieces, here's what I use:
split: func [  ; subdivide, chunk, segment  ?

        {See: CLOS pg. 937. Not that mine works the same, but that was
        the inspiration.}
        series [series!]

        size   [integer!] "The size of the chunks (last chunk may be shorter)"

        /into  "split into a set number of chunks (last chunk may be longer 
        than others)."
        /local ct cur-piece result
    ][

        ct: either into [size] [round/down divide length? series size]
        if into [size: to-integer divide length? series size]
        result: copy []
        if zero? size [return result]
        parse series [
            ct [

                copy cur-piece size skip (append/only result cur-piece) mark:
            ]
        ]
        if any [into  not zero? remainder length? series size] [
            cur-piece: copy mark
            either into
                [append last result cur-piece]
                [append/only result cur-piece]
        ]
        result
    ]
>> b: [1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4]
== [1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4]
>> chunk b 4
== [[1 1 1 1] [2 2 2 2] [3 3 3 3] [4 4 4 4]]
>> chunk b 2
== [[1 1] [1 1] [2 2] [2 2] [3 3] [3 3] [4 4] [4 4]]
>> chunk/into b 2
== [[1 1 1 1 2 2 2 2] [3 3 3 3 4 4 4 4]]
Hmm, should look at my notes. You'll probably want to add this as 
the first line in that func, or something similar, that handles the 
case where SIZE is larger than the series:

        size: min size length? series
I also have a note that maybe /into should be the default behavior 
and /size or /part should be the refinement. It's an old func, and 
I don't use it too much myself. It can be handy at times though.
Volker
14-May-2006
[965x2]
I need the opposite too, and call them 'enblock and 'deblock.
mainly incombination with 'union and friends.
Graham
14-May-2006
[967x2]
Are we storing these functions in altme, or the mailing list, or 
some other more accessible archive?
Doesn't Gregg have a functions archive somewhere?
Sunanda
14-May-2006
[969]
Altme/REBOL3 is a poor place to keep useful functions: they have 
close to a  0% chance of being found by anyone looking via a search 
engine (only most recemt 300 messsages are visible, remember).....Though 
REBOL2 and the originla REBOL world are even tougher for anyone new 
to mine data from.
(Altme/REBOL3 is a great place to _develop_ useful functions)
***

The ML is slightly better. At least it is visible, though not very 
structured -- it can be hard to tell if you are looking at the latest&greatest 
version of a function, or just one of many interim revisions.
***

You are thinking of http://www.bigbold.com/snippets/tag/REBOL-- 
a code snippets library that Gregg has contributed to.
[unknown: 9]
14-May-2006
[970]
Agreed, shouldn't this by definition be in the library?
Graham
14-May-2006
[971]
A functional language should have a function library?
[unknown: 9]
14-May-2006
[972]
: )
Volker
15-May-2006
[973]
Josh talked about rebol as external process,sharing window. As a 
possibility for plugin. Its not plugin, but could that work between 
rebol-apps? view-desktop could profit a lot.
Henrik
15-May-2006
[974]
that would be very cool. instant desktop service for rebol apps.
Volker
15-May-2006
[975x3]
%index.r could then contain real code and play animations, without 
taking over.
Maybe add a little message-exchange, and konfabulatorisdone.
(call it active icons :)
ScottT
15-May-2006
[978x2]
I think of Acrobat and MSAgent with regard to this--one instance 
of an exe that bridges all the instances.
I am more familiar with msagent.  There is a server process that 
coordinates all the instances of the MSAgent control, wherever they 
may be, windows app, browser window, wherever.
Geomol
20-May-2006
[980]
In REBOL3, would it be an idea to add a /deep refinement to REDUCE, 
so it'll reduce blocks within blocks?
Gregg
20-May-2006
[981]
I'd bet a lot of us have thought of that one. I haven't pushed for 
it, because it seems like the places I think I'd use it most would 
have exceptions in the other direction. That is, I want to reduce 
*almost* everything, but there are exceptions. I also thought about 
a version that let you specify the words you wanted reduced (reduce-only 
series words), and would do a deep reduce, then RT added /only, which 
works backwards from that, so I thought my idea would be confusing.
Anton
20-May-2006
[982]
Could be useful for little things.
Gregg
20-May-2006
[983]
Worth working up as a mezzanine in any case I suppose.
Louis
20-May-2006
[984]
Is rebol3 going to support file locking? I think that is the correct 
term. I need for several users to be entering data into the same 
file at the same time. Is there a way to do this right now?
Volker
20-May-2006
[985]
Gabriele suggest to open a port as server, because a port can only 
be opened by one process. Thus it can act as lock. Os-filelocking 
is not supported.
Louis
20-May-2006
[986]
How do I open a port as a server?
Volker
20-May-2006
[987x2]
port: open tcp://:8912 ;note the ":"
And if that fails somebody has that port open. (or some firewall 
goes angry or whatever, but that is another problem).
Louis
20-May-2006
[989x3]
Ok. Thanks. I'll try that.
As an SOA, REBOL/Services gives you an easy way to create a wide 
variety of applications such as:

Secure file sharing
Does that mean that rebol services would also be a solution to my 
problem?