From: <jfa...@us...> - 2011-07-06 08:03:32
|
Revision: 7040 http://oorexx.svn.sourceforge.net/oorexx/?rev=7040&view=rev Author: jfaucher Date: 2011-07-06 08:03:21 +0000 (Wed, 06 Jul 2011) Log Message: ----------- More work on source literals : adapt the samples to new capabilities Modified Paths: -------------- sandbox/jlf/_diary.txt sandbox/jlf/samples/concurrency/binary_tree.cls sandbox/jlf/samples/concurrency/coactivity-test.rex sandbox/jlf/samples/concurrency/coactivity.cls sandbox/jlf/samples/concurrency/deadlock2.rex sandbox/jlf/samples/concurrency/std/binary_tree-std.cls sandbox/jlf/samples/extension/doers.cls sandbox/jlf/samples/extension/extensions.cls sandbox/jlf/samples/extension/functional-test.rex sandbox/jlf/samples/extension/functionals.cls sandbox/jlf/samples/pipeline/deadlock1.rex sandbox/jlf/samples/pipeline/pipe.rex sandbox/jlf/samples/pipeline/pipe_extension.cls sandbox/jlf/samples/pipeline/pipe_extension_test.output.txt sandbox/jlf/samples/pipeline/pipe_extension_test.rex Added Paths: ----------- sandbox/jlf/samples/functional/_readme.txt Modified: sandbox/jlf/_diary.txt =================================================================== --- sandbox/jlf/_diary.txt 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/_diary.txt 2011-07-06 08:03:21 UTC (rev 7040) @@ -45,6 +45,31 @@ =============================================================================== 2011 july 06 +Adapted the package doers.cls to source literals. +The class String is no longer used to hold routine's source or method's source. +Now RexxContextualSource is used for that. + doer = {use arg name; say "hello" name}~doer + say doer~class -- The Routine class + doer~do("John") -- hello John + + doer = {::method say "hello" self}~doer + say doer~class -- The Method class + doer~do("John") -- hello John +Strings are still used for doers of type Message. + doer = "length"~doer + say doer~class -- The String class + say doer~do("John") -- 4 + + +Adapted the samples in extension, concurrency, pipeline : +- No longer need to call Doers.AddVisibilityFrom(.context). +- Source fragments are no longer strings, but source literals. +- Use abbreviated syntax when passing source literals + + +=============================================================================== +2011 july 06 + When a source literal was evaluated by an interpret instruction, the package associated to the RexxContextualSource (at parse time) was not holding the right informations for class & routine lookup scope. Modified: sandbox/jlf/samples/concurrency/binary_tree.cls =================================================================== --- sandbox/jlf/samples/concurrency/binary_tree.cls 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/samples/concurrency/binary_tree.cls 2011-07-06 08:03:21 UTC (rev 7040) @@ -78,10 +78,10 @@ self~rootNode~insert(value) ::method ascendingValues - return .Coactivity~new("visitAscending", , , self~rootNode) + return .Coactivity~new("visitAscending", , self~rootNode) ::method descendingValues - return .Coactivity~new("visitDescending", , , self~rootNode) + return .Coactivity~new("visitDescending", , self~rootNode) /* Modified: sandbox/jlf/samples/concurrency/coactivity-test.rex =================================================================== --- sandbox/jlf/samples/concurrency/coactivity-test.rex 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/samples/concurrency/coactivity-test.rex 2011-07-06 08:03:21 UTC (rev 7040) @@ -5,11 +5,6 @@ signal on any name error signal on syntax name error --- See doers.cls for more details, but in summary, the one-liner routines/methods have a default --- lookup scope which is limited to the doers package. Consequence : the .Coactivity class is not --- visible by default, and I have to pass explicitely the .context each time a one-liner routine/method --- is created. This is tedious, and I prefer to dynamically extend the lookup scope of the doers package. -call Doers.AddVisibilityFrom(.context) call demo call terminate return @@ -34,7 +29,7 @@ say say "A coactivity implemented by a one-liner routine" -c = .Coactivity~new('say "running coactivity" ; return 1', .false) +c = .Coactivity~new({say "running coactivity" ; return 1}, .false) c~start say c~resume signal on syntax name trap_syntax1 @@ -44,7 +39,7 @@ say say "A coactivity implemented by a one-liner routine, used as a generator" -c = .Coactivity~new("do i = 1 to 10 ; .yield[i] ; end") +c = .Coactivity~new{do i = 1 to 10 ; .yield[i] ; end} c~resume do while var("result") say result @@ -54,7 +49,7 @@ say say "Iteration with a supplier" -c = .Coactivity~new("do i = 1 to 10 ; .yield[i] ; end") +c = .Coactivity~new{do i = 1 to 10 ; .yield[i] ; end} supplier = c~supplier do while supplier~available say supplier~index ":" supplier~item @@ -64,7 +59,7 @@ say say "do over a finite coactivity" -c = .Coactivity~new("do i = 1 to 10 ; .yield[i] ; end") +c = .Coactivity~new{do i = 1 to 10 ; .yield[i] ; end} do v over c say v end @@ -73,13 +68,13 @@ say say "do over an infinite coactivty : needs a limit" say "Local limit setting" -c = .Coactivity~new("i = 1 ; do forever ; .yield[i] ; i += 1 ; end") +c = .Coactivity~new{i = 1 ; do forever ; .yield[i] ; i += 1 ; end} do v over c~makeArray(15) say v end say "Global limit setting (default is ".Coactivity~makeArrayLimit")" .Coactivity~makeArrayLimit = 15 -c = .Coactivity~new("i = 1 ; do forever ; .yield[i] ; i += 1 ; end") +c = .Coactivity~new{i = 1 ; do forever ; .yield[i] ; i += 1 ; end} do v over c say v end Modified: sandbox/jlf/samples/concurrency/coactivity.cls =================================================================== --- sandbox/jlf/samples/concurrency/coactivity.cls 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/samples/concurrency/coactivity.cls 2011-07-06 08:03:21 UTC (rev 7040) @@ -88,9 +88,9 @@ The default entry is the couple ("main", self). By default, the coactivity is started (the 'start' method is called) */ - use strict arg action="main", start=.true, context=.nil, self~object=(self) + use strict arg action="main", start=.true, self~object=(self) - self~doer = action~doer(context) + self~doer = action~doer self~status = .Coactivity~notStarted if start then self~start Modified: sandbox/jlf/samples/concurrency/deadlock2.rex =================================================================== --- sandbox/jlf/samples/concurrency/deadlock2.rex 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/samples/concurrency/deadlock2.rex 2011-07-06 08:03:21 UTC (rev 7040) @@ -18,8 +18,8 @@ T1 A9 V1 1 >I> Method ENDALL */ -call Doers.AddVisibilityFrom(.context) -c = .coactivity~new(".coactivity~yield(1) ; return 2") +--call Doers.AddVisibilityFrom(.context) +c = .coactivity~new({.coactivity~yield(1) ; return 2}) say c say c~resume --say c~resume -- If we don't resume to get the 2nd value, then we can have a deadlock Modified: sandbox/jlf/samples/concurrency/std/binary_tree-std.cls =================================================================== --- sandbox/jlf/samples/concurrency/std/binary_tree-std.cls 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/samples/concurrency/std/binary_tree-std.cls 2011-07-06 08:03:21 UTC (rev 7040) @@ -79,10 +79,10 @@ self~rootNode~insert(value) ::method ascendingValues - return .Coactivity~new(.ExtendedString~new("visitAscending"), , , self~rootNode) + return .Coactivity~new(.ExtendedString~new("visitAscending"), , self~rootNode) ::method descendingValues - return .Coactivity~new(.ExtendedString~new("visitDescending"), , , self~rootNode) + return .Coactivity~new(.ExtendedString~new("visitDescending"), , self~rootNode) /* Modified: sandbox/jlf/samples/extension/doers.cls =================================================================== --- sandbox/jlf/samples/extension/doers.cls 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/samples/extension/doers.cls 2011-07-06 08:03:21 UTC (rev 7040) @@ -5,49 +5,13 @@ --::options trace i ----------------------------------------------------------------------------- -/* -Extract from rexxref, .Routine~new : -The context allows the created routine to inherit class and routine lookup scope from another source. If -specified, context can be a Method object, a Routine object, or a Package object. If not specified, the -newly created method will inherit the class and routine search scope from the caller of new method. - -So, by default, any routine created by StringDoer will have a lookup scope limited to the doers package, -because the routines are created from here, not from the caller's package. -StringDoer~doer accepts a context parameter to let the caller pass its own lookup scope, but this is -tedious to pass it explicitely. -That's why I provide this routine which lets see from doers the same packages/methods/routines as the caller. -Usage from caller's package : -call Doers.AddVisibilityFrom(.context) - -Note : this is a temporary workaround. The good approach is to add support for first-class -expressions/instructions that are parsed in place, instead of being parsed by StringDoer.. -https://sourceforge.net/mailarchive/message.php?msg_id=19912031 -*/ - -::routine Doers.AddVisibilityFrom public - use strict arg package -- can be a .Package or a .RexxContext - if package~isA(.RexxContext) then package = package~package - do p over package~importedPackages - .context~package~addPackage(p) - end - classes = package~classes - do c over classes - .context~package~addClass(c, classes[c]) - end - routines = package~routines - do r over routines - .context~package~addRoutine(r, routines[r]) - end - ------------------------------------------------------------------------------ -- Mixins. -- A Doer is an object who knows how to execute itself (understands "do") ::class RoutineDoer mixinclass Object public ::method doer - use strict arg context=.nil - if context <> .nil then raise syntax 93.900 array ("Context not supported") + use strict arg -- none return self ::method needsObject @@ -72,8 +36,7 @@ ::class MethodDoer mixinclass Object public ::method doer - use strict arg context=.nil - if context <> .nil then raise syntax 93.900 array ("Context not supported") + use strict arg -- none return self ::method needsObject @@ -93,28 +56,8 @@ ::class StringDoer mixinclass Object public ::method doer - use strict arg context=.nil - parse var self word1 rest - - -- When the source string contains a single word without '(', it's a message name - if rest == "" & word1~pos("(") == 0 then do - if context <> .nil then raise syntax 93.900 array ("Context not supported") - return self - end - if word1~caselessEquals("::method") then do - if context == .nil then return .Method~new("", rest) - if context~isA(.RexxContext) then context = context~package - return .Method~new("", rest, context) - end - if word1~caselessEquals("::routine") then do - if context == .nil then return .Routine~new("", rest) - if context~isA(.RexxContext) then context = context~package - return .Routine~new("", rest, context) - end - -- Routine by default - if context == .nil then return .Routine~new("", self) - if context~isA(.RexxContext) then context = context~package - return .Routine~new("", self, context) + use strict arg -- none + return self -- When used as a doer, a string is a message ::method needsObject return .true -- Must pass an object as first argument when calling do or doWith @@ -129,3 +72,15 @@ object~sendWith(self, array) if var("result") then return result + +::class RexxContextualSourceDoer mixinclass Object public + +::method doer + use strict arg -- none + parse value self~source with word1 rest + + if word1~caselessEquals("::method") then return .Method~new("", rest, self~package) + if word1~caselessEquals("::routine") then return .Routine~new("", rest, self~package) + -- Routine by default + return .Routine~new("", self~source, self~package) + Modified: sandbox/jlf/samples/extension/extensions.cls =================================================================== --- sandbox/jlf/samples/extension/extensions.cls 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/samples/extension/extensions.cls 2011-07-06 08:03:21 UTC (rev 7040) @@ -9,6 +9,7 @@ ::extension MutableBuffer inherit MutableBufferMap ::extension Routine inherit RoutineDoer ::extension Method inherit MethodDoer +::extension RexxContextualSource inherit RexxContextualSourceDoer ::extension Collection inherit CollectionReduce CollectionIterator ::extension OrderedCollection inherit OrderedCollectionMap ::extension Supplier inherit SupplierReduce SupplierIterator Modified: sandbox/jlf/samples/extension/functional-test.rex =================================================================== --- sandbox/jlf/samples/extension/functional-test.rex 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/samples/extension/functional-test.rex 2011-07-06 08:03:21 UTC (rev 7040) @@ -56,31 +56,31 @@ say "-----------------------------------------------------------------" -- A source with more than one word is a routine source by default -.Array~of(1,2,3,4)~map("return arg(1) * 2")~dump -- an Array : 2, 4, 6, 8 -.Array~of(1,2,3,4)~map("use arg n ; if n == 0 then return 1 ; return n * .context~executable~call(n - 1)")~dump -- an Array : 1, 2, 6, 24 +.Array~of(1,2,3,4)~map{return arg(1) * 2}~dump -- an Array : 2, 4, 6, 8 +.Array~of(1,2,3,4)~map{use arg n ; if n == 0 then return 1 ; return n * .context~executable~call(n - 1)}~dump -- an Array : 1, 2, 6, 24 -.List~of(1,2,3,4)~map("return arg(1) * 2")~dump -- a List : 2, 4, 6, 8 -.List~of(1,2,3,4)~map("use arg n ; if n == 0 then return 1 ; return n * .context~executable~call(n - 1)")~dump -- a List : 1, 2, 6, 24 +.List~of(1,2,3,4)~map{return arg(1) * 2}~dump -- a List : 2, 4, 6, 8 +.List~of(1,2,3,4)~map{use arg n ; if n == 0 then return 1 ; return n * .context~executable~call(n - 1)}~dump -- a List : 1, 2, 6, 24 -.Queue~of(1,2,3,4)~map("return arg(1) * 2")~dump -- a Queue : 2, 4, 6, 8 -.Queue~of(1,2,3,4)~map("use arg n ; if n == 0 then return 1 ; return n * .context~executable~call(n - 1)")~dump -- a Queue : 1, 2, 6, 24 +.Queue~of(1,2,3,4)~map{return arg(1) * 2}~dump -- a Queue : 2, 4, 6, 8 +.Queue~of(1,2,3,4)~map{use arg n ; if n == 0 then return 1 ; return n * .context~executable~call(n - 1)}~dump -- a Queue : 1, 2, 6, 24 -.CircularQueue~of(1,2,3,4)~map("return arg(1) * 2")~dump -- 2,4,6,8 : 2, 4, 6, 8 (strange : the class is not displayed) -.CircularQueue~of(1,2,3,4)~map("use arg n ; if n == 0 then return 1 ; return n * .context~executable~call(n - 1)")~dump -- 1,2,6,24 : 1, 2, 6, 24 +.CircularQueue~of(1,2,3,4)~map{return arg(1) * 2}~dump -- 2,4,6,8 : 2, 4, 6, 8 (strange : the class is not displayed) +.CircularQueue~of(1,2,3,4)~map{use arg n ; if n == 0 then return 1 ; return n * .context~executable~call(n - 1)}~dump -- 1,2,6,24 : 1, 2, 6, 24 -"abcdefghijklmnopqrstuvwxyz"~mapchar("return arg(1)~verify('aeiouy')")~dump -.MutableBuffer~new("abcdefghijklmnopqrstuvwxyz")~mapchar("if arg(1)~verify('aeiouy') == 1 then return arg(1) ; else return ''")~dump +"abcdefghijklmnopqrstuvwxyz"~mapchar{return arg(1)~verify('aeiouy')}~dump +.MutableBuffer~new("abcdefghijklmnopqrstuvwxyz")~mapchar{if arg(1)~verify('aeiouy') == 1 then return arg(1) ; else return ''}~dump /* todo : doesn't work because the variable translation has no value when evaluating the doer translation = .Directory~of("quick", "slow", "lazy", "nervous", "brown", "yellow", "dog", "cat") translation~setMethod("UNKNOWN", "return arg(1)") -"The quick brown fox jumps over the lazy dog"~mapword("return translation~arg(1)",,.context~package)~dump -.MutableBuffer~new("The quick brown fox jumps over the lazy dog")~mapword("return translation[arg(1)]", .false, .context~package)~dump +"The quick brown fox jumps over the lazy dog"~mapword{return translation~arg(1)}~dump +.MutableBuffer~new("The quick brown fox jumps over the lazy dog")~mapword({return translation[arg(1)]}, .false)~dump */ -- A source can be tagged explicitely as a routine (but you don't need that, because it's the default) -.Array~of(1,2,3,4)~map("::routine return arg(1) * 2")~dump -- an Array : 2, 4, 6, 8 -.Array~of(1,2,3,4)~map("::routine use arg n ; if n == 0 then return 1 ; return n * .context~executable~call(n - 1)")~dump -- an Array : 1, 2, 6, 24 +.Array~of(1,2,3,4)~map{::routine return arg(1) * 2}~dump -- an Array : 2, 4, 6, 8 +.Array~of(1,2,3,4)~map{::routine use arg n ; if n == 0 then return 1 ; return n * .context~executable~call(n - 1)}~dump -- an Array : 1, 2, 6, 24 -- A routine object can be used directly .Array~of(1,2,3,4)~map(.context~package~findRoutine("factorial"))~dump -- an Array : 1, 2, 6, 24 @@ -98,7 +98,7 @@ ) -- A source can be tagged explicitely as a method (you need that, because it's a routine by default) -colors~map('::method return self~rgbInteger "("self~redIntensity", "self~greenIntensity", "self~blueIntensity")"')~dump -- an Array : 0 (0, 0, 0), 255 (0, 0, 255), 32768 (0, 128, 0), 12500670 (190, 190, 190) +colors~map{::method return self~rgbInteger "("self~redIntensity", "self~greenIntensity", "self~blueIntensity")"}~dump -- an Array : 0 (0, 0, 0), 255 (0, 0, 255), 32768 (0, 128, 0), 12500670 (190, 190, 190) -- A method object can be used directly -- No need to define the method on the receiver class Modified: sandbox/jlf/samples/extension/functionals.cls =================================================================== --- sandbox/jlf/samples/extension/functionals.cls 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/samples/extension/functionals.cls 2011-07-06 08:03:21 UTC (rev 7040) @@ -12,22 +12,22 @@ ::class StringReduce mixinclass Object public ::method reduce - use strict arg action, context=.nil - return self~makearray("")~reduce(action, context) + use strict arg action + return self~makearray("")~reduce(action) ::class CollectionReduce mixinclass Object public ::method reduce - use strict arg action, context=.nil - return self~supplier~reduce(action, context) + use strict arg action + return self~supplier~reduce(action) ::class SupplierReduce mixinclass Object public ::method reduce - use strict arg action, context=.nil - doer = action~doer(context) -- parse only once, before iteration + use strict arg action + doer = action~doer -- parse only once, before iteration if \ self~available then return .nil r = self~item self~next @@ -48,14 +48,14 @@ forward message "mapChar" ::method mapchar - use strict arg action, inplace=.false, context=.nil + use strict arg action, inplace=.false if inplace == .true then raise syntax 93.900 array ("in place not applicable to string") - return .MutableBuffer~new(self)~mapchar(action, .true, context)~string + return .MutableBuffer~new(self)~mapchar(action, .true)~string ::method mapword - use strict arg action, inplace=.false, context=.nil + use strict arg action, inplace=.false if inplace == .true then raise syntax 93.900 array ("in place not applicable to string") - return .MutableBuffer~new(self)~mapword(action, .true, context)~string + return .MutableBuffer~new(self)~mapword(action, .true)~string ::class MutableBufferMap mixinclass Object public @@ -64,8 +64,8 @@ forward message "mapChar" ::method mapchar - use strict arg action, inplace=.true, context=.nil - doer = action~doer(context) -- parse only once, before iteration + use strict arg action, inplace=.true + doer = action~doer -- parse only once, before iteration r = self if \inplace then r = self~copy string = r~string @@ -76,8 +76,8 @@ return r ::method mapword - use strict arg action, inplace=.true, context=.nil - doer = action~doer(context) -- parse only once, before iteration + use strict arg action, inplace=.true + doer = action~doer -- parse only once, before iteration r = self if \inplace then r = self~copy string = r~string @@ -98,8 +98,8 @@ ::class OrderedCollectionMap mixinclass Object public ::method map - use strict arg action, inplace=.false, context=.nil - doer = action~doer(context) -- parse only once, before iteration + use strict arg action, inplace=.false + doer = action~doer -- parse only once, before iteration r = self if \inplace then r = self~copy current = self~first @@ -117,16 +117,16 @@ ::class StringRepeater mixinclass Object public ::method times - use strict arg action, context=.nil - doer = action~doer(context) -- parse only once, before iteration + use strict arg action + doer = action~doer -- parse only once, before iteration do i = 1 to self doer~do(i) end return self ::method upto - use strict arg upperLimit, action, context=.nil - doer = action~doer(context) -- parse only once, before iteration + use strict arg upperLimit, action + doer = action~doer -- parse only once, before iteration do i = self to upperLimit doer~do(i) end @@ -140,16 +140,16 @@ ::class CollectionIterator mixinclass Object public ::method each - use strict arg action, context=.nil - self~supplier~each(action, context) + use strict arg action + self~supplier~each(action) return self ::class SupplierIterator mixinclass Object public ::method each - use strict arg action, context=.nil - doer = action~doer(context) -- parse only once, before iteration + use strict arg action + doer = action~doer -- parse only once, before iteration do while self~available doer~do(self~item, self~index) -- I suppose that most of the time, we need only the item self~next Added: sandbox/jlf/samples/functional/_readme.txt =================================================================== --- sandbox/jlf/samples/functional/_readme.txt (rev 0) +++ sandbox/jlf/samples/functional/_readme.txt 2011-07-06 08:03:21 UTC (rev 7040) @@ -0,0 +1,5 @@ +The code in this directory is now deprecated (but still works). + +Replaced by : +extensions\functionals.cls +extensions\functional-test.rex Property changes on: sandbox/jlf/samples/functional/_readme.txt ___________________________________________________________________ Added: svn:eol-style + LF Modified: sandbox/jlf/samples/pipeline/deadlock1.rex =================================================================== --- sandbox/jlf/samples/pipeline/deadlock1.rex 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/samples/pipeline/deadlock1.rex 2011-07-06 08:03:21 UTC (rev 7040) @@ -24,9 +24,9 @@ T1 resume +1 */ -call Doers.AddVisibilityFrom(.context) +--call Doers.AddVisibilityFrom(.context) -.coactivity~new('.coactivity~yield("a") ; .coactivity~yield("b")')~pipe(.upper|.displayer) +.coactivity~new({.coactivity~yield("a") ; .coactivity~yield("b")})~pipe(.upper|.displayer) --::options trace i ::requires "extension/extensions.cls" Modified: sandbox/jlf/samples/pipeline/pipe.rex =================================================================== --- sandbox/jlf/samples/pipeline/pipe.rex 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/samples/pipeline/pipe.rex 2011-07-06 08:03:21 UTC (rev 7040) @@ -383,13 +383,13 @@ ::attribute strict ::method init -expose items context -use strict arg context=.nil -- will be used for the options of type expression +expose items +use strict arg -- none items = .array~new -- create a new list forward class (super) ::method initOptions -expose descending caseless quickSort strict criteria context +expose descending caseless quickSort strict criteria descending = .false caseless = .false quickSort = .false -- use a stable sort by default @@ -397,23 +397,26 @@ unknown = .array~new criteria = .array~new do a over arg(1, "a") - if "byIndex"~caselessAbbrev(a, 3) then criteria~append(.array~of("sortBy", "index")) - else if "byValue"~caselessAbbrev(a, 1) then criteria~append(.array~of("sortBy", "value")) - else if "ascending"~caselessAbbrev(a, 1) then criteria~append(.array~of("descending=", .false)) - else if "descending"~caselessAbbrev(a, 1) then criteria~append(.array~of("descending=", .true)) - else if "case"~caselessAbbrev(a, 4) then criteria~append(.array~of("caseless=", .false)) - else if "caseless"~caselessAbbrev(a, 5) then criteria~append(.array~of("caseless=", .true)) - else if "stableSort"~caselessAbbrev(a, 3) then criteria~append(.array~of("quickSort=", .false)) - else if "quickSort"~caselessAbbrev(a, 1) then criteria~append(.array~of("quickSort=", .true)) - else if "numeric"~caselessAbbrev(a, 1) then criteria~append(.array~of("strict=", .false)) - else if "strict"~caselessAbbrev(a, 3) then criteria~append(.array~of("strict=", .true)) - else do -- assume this is an expression or a function + if a~isA(.String) then do + if "byIndex"~caselessAbbrev(a, 3) then do ; criteria~append(.array~of("sortBy", "index")) ; iterate ; end + if "byValue"~caselessAbbrev(a, 1) then do ; criteria~append(.array~of("sortBy", "value")) ; iterate ; end + if "ascending"~caselessAbbrev(a, 1) then do ; criteria~append(.array~of("descending=", .false)) ; iterate ; end + if "descending"~caselessAbbrev(a, 1) then do ; criteria~append(.array~of("descending=", .true)) ; iterate ; end + if "case"~caselessAbbrev(a, 4) then do ; criteria~append(.array~of("caseless=", .false)) ; iterate ; end + if "caseless"~caselessAbbrev(a, 5) then do ; criteria~append(.array~of("caseless=", .true)) ; iterate ; end + if "stableSort"~caselessAbbrev(a, 3) then do ; criteria~append(.array~of("quickSort=", .false)) ; iterate ; end + if "quickSort"~caselessAbbrev(a, 1) then do ; criteria~append(.array~of("quickSort=", .true)) ; iterate ; end + if "numeric"~caselessAbbrev(a, 1) then do ; criteria~append(.array~of("strict=", .false)) ; iterate ; end + if "strict"~caselessAbbrev(a, 3) then do ; criteria~append(.array~of("strict=", .true)) ; iterate ; end + end + if a~hasMethod("doer") then do if .pipeExtensions~available then do - function = .pipeExtensions~makeFunctionDoer(a, context) + function = .pipeExtensions~makeFunctionDoer(a) criteria~append(.array~of("sortBy", function)) + iterate end - else unknown~append(a) end + unknown~append(a) end forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options @@ -461,8 +464,10 @@ quickSort = .false -- use a stable sort by default unknown = .array~new do a over arg(1, "a") - if "quickSort"~caselessAbbrev(a, 1) then quickSort = .true - else unknown~append(a) + if a~isA(.String) then do + if "quickSort"~caselessAbbrev(a, 1) then do ; quickSort = .true ; iterate ; end + end + unknown~append(a) end forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options @@ -627,23 +632,28 @@ countSpecified = .false unknown = .array~new do a over arg(1, "a") - if "first"~caselessAbbrev(a, 1) then do - if lastSpecified then raise syntax 93.900 array("You can't specify 'first' after 'last'") - if countSpecified then raise syntax 93.900 array("You can't specify 'first' after the number") - firstSpecified = .true - first = .true + if a~isA(.String) then do + if "first"~caselessAbbrev(a, 1) then do + if lastSpecified then raise syntax 93.900 array("You can't specify 'first' after 'last'") + if countSpecified then raise syntax 93.900 array("You can't specify 'first' after the number") + firstSpecified = .true + first = .true + iterate + end + if "last"~caselessAbbrev(a, 1) then do + if firstSpecified then raise syntax 93.900 array("You can't specify 'last' after 'first'") + if countSpecified then raise syntax 93.900 array("You can't specify 'last' after the number") + lastSpecified = .true + first = .false + iterate + end + if a~dataType("W") then do + count = a + countSpecified = .true + iterate + end end - else if "last"~caselessAbbrev(a, 1) then do - if firstSpecified then raise syntax 93.900 array("You can't specify 'last' after 'first'") - if countSpecified then raise syntax 93.900 array("You can't specify 'last' after the number") - lastSpecified = .true - first = .false - end - else if a~dataType("W") then do - count = a - countSpecified = .true - end - else unknown~append(a) + unknown~append(a) end forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options @@ -711,23 +721,28 @@ countSpecified = .false unknown = .array~new do a over arg(1, "a") - if "first"~caselessAbbrev(a, 1) then do - if lastSpecified then raise syntax 93.900 array("You can't specify 'first' after 'last'") - if countSpecified then raise syntax 93.900 array("You can't specify 'first' after the number") - firstSpecified = .true - first = .true + if a~isA(.String) then do + if "first"~caselessAbbrev(a, 1) then do + if lastSpecified then raise syntax 93.900 array("You can't specify 'first' after 'last'") + if countSpecified then raise syntax 93.900 array("You can't specify 'first' after the number") + firstSpecified = .true + first = .true + iterate + end + if "last"~caselessAbbrev(a, 1) then do + if firstSpecified then raise syntax 93.900 array("You can't specify 'last' after 'first'") + if countSpecified then raise syntax 93.900 array("You can't specify 'last' after the number") + lastSpecified = .true + first = .false + iterate + end + if a~dataType("W") then do + count = a + countSpecified = .true + iterate + end end - else if "last"~caselessAbbrev(a, 1) then do - if firstSpecified then raise syntax 93.900 array("You can't specify 'last' after 'first'") - if countSpecified then raise syntax 93.900 array("You can't specify 'last' after the number") - lastSpecified = .true - first = .false - end - else if a~dataType("W") then do - count = a - countSpecified = .true - end - else unknown~append(a) + unknown~append(a) end forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options @@ -890,49 +905,59 @@ ::constant indexSeparator "|" ::method init -expose items context -use strict arg context=.nil -- will be used for the options of type expression +expose items +use strict arg -- none forward class (super) ::method initOptions -expose actions context +expose actions unknown = .array~new actions = .array~new do a over arg(1, "a") - parse var a first "." rest - if "index"~caselessAbbrev(first, 1) then do - indexWidth = -1 - if rest <> "" then do -- index.width - if rest~dataType("W") then indexWidth = rest - else raise syntax 93.900 array("Expected a whole number after "index". in "a) + if a~isA(.String) then do + parse var a first "." rest + if "index"~caselessAbbrev(first, 1) then do + indexWidth = -1 + if rest <> "" then do -- index.width + if rest~dataType("W") then indexWidth = rest + else raise syntax 93.900 array("Expected a whole number after "index". in "a) + end + actions~append(.array~of("displayIndex", indexWidth)) + iterate end - actions~append(.array~of("displayIndex", indexWidth)) - end - else if "value"~caselessAbbrev(first, 1) then do - valueWidth = -1 - if rest <> "" then do -- value.width - if rest~dataType("W") then valueWidth = rest - else raise syntax 93.900 array("Expected a whole number after "value". in "a) + if "value"~caselessAbbrev(first, 1) then do + valueWidth = -1 + if rest <> "" then do -- value.width + if rest~dataType("W") then valueWidth = rest + else raise syntax 93.900 array("Expected a whole number after "value". in "a) + end + actions~append(.array~of("displayValue", valueWidth)) + iterate end - actions~append(.array~of("displayValue", valueWidth)) - end - else if "space"~caselessAbbrev(first, 1) then do - spaceWidth = -1 - if rest <> "" then do -- space.width - if rest~dataType("W") then spaceWidth = rest - else raise syntax 93.900 array("Expected a whole number after "space". in "a) + if "space"~caselessAbbrev(first, 1) then do + spaceWidth = -1 + if rest <> "" then do -- space.width + if rest~dataType("W") then spaceWidth = rest + else raise syntax 93.900 array("Expected a whole number after "space". in "a) + end + actions~append(.array~of("displaySpace", spaceWidth)) + iterate end - actions~append(.array~of("displaySpace", spaceWidth)) + if "newline"~caselessAbbrev(a, 1) then do + actions~append(.array~of("displayNewline")) + iterate + end + actions~append(.array~of("displayString", a)) + iterate end - else if "newline"~caselessAbbrev(a, 1) then actions~append(.array~of("displayNewline")) - else do - -- assume this is an expression or a function + if a~hasMethod("doer") then do if .pipeExtensions~available then do - function = .pipeExtensions~makeFunctionDoer(a, context) + function = .pipeExtensions~makeFunctionDoer(a) actions~append(.array~of("displayExpression", function)) + iterate end - else unknown~append(a) end + unknown~append(a) end forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options @@ -955,6 +980,10 @@ use strict arg dummy, value, index .output~lineout("") +::method displayString +use strict arg string, value, index +.output~charout(string) + ::method displayExpression use strict arg expression, value, index .output~charout(expression~do(value, index)) @@ -988,8 +1017,10 @@ caseless = .false unknown = .array~new do a over arg(1, "a") - if "caseless"~caselessAbbrev(a, 5) then caseless = .true - else unknown~append(a) + if a~isA(.String) then do + if "caseless"~caselessAbbrev(a, 5) then do ; caseless = .true ; iterate ; end + end + unknown~append(a) end forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options @@ -1020,8 +1051,10 @@ caseless = .false unknown = .array~new do a over arg(1, "a") - if "caseless"~caselessAbbrev(a, 5) then caseless = .true - else unknown~append(a) + if a~isA(.String) then do + if "caseless"~caselessAbbrev(a, 5) then do ; caseless = .true ; iterate ; end + end + unknown~append(a) end forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options @@ -1048,8 +1081,10 @@ caseless = .false unknown = .array~new do a over arg(1, "a") - if "caseless"~caselessAbbrev(a, 5) then caseless = .true - else unknown~append(a) + if a~isA(.String) then do + if "caseless"~caselessAbbrev(a, 5) then do ; caseless = .true ; iterate ; end + end + unknown~append(a) end forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options @@ -1116,8 +1151,10 @@ caseless = .false unknown = .array~new do a over arg(1, "a") - if "caseless"~caselessAbbrev(a, 5) then caseless = .true - else unknown~append(a) + if a~isA(.String) then do + if "caseless"~caselessAbbrev(a, 5) then do ; caseless = .true ; iterate ; end + end + unknown~append(a) end forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options @@ -1155,8 +1192,10 @@ caseless = .false unknown = .array~new do a over arg(1, "a") - if "caseless"~caselessAbbrev(a, 5) then caseless = .true - else unknown~append(a) + if a~isA(.String) then do + if "caseless"~caselessAbbrev(a, 5) then do ; caseless = .true ; iterate ; end + end + unknown~append(a) end forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options @@ -1186,8 +1225,10 @@ caseless = .false unknown = .array~new do a over arg(1, "a") - if "caseless"~caselessAbbrev(a, 5) then caseless = .true - else unknown~append(a) + if a~isA(.String) then do + if "caseless"~caselessAbbrev(a, 5) then do ; caseless = .true ; iterate ; end + end + unknown~append(a) end forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options @@ -1373,9 +1414,9 @@ /******************************************************************************/ --- A fileText pipeStage to get the contents of the file line by line. +-- A getFiles pipeStage to get the contents of a list of files line by line. -- The input value can be a string (used as a path) or a .File instance. -::class fileText public subclass pipeStage +::class getFiles public subclass pipeStage ::method process use strict arg value, index Modified: sandbox/jlf/samples/pipeline/pipe_extension.cls =================================================================== --- sandbox/jlf/samples/pipeline/pipe_extension.cls 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/samples/pipeline/pipe_extension.cls 2011-07-06 08:03:21 UTC (rev 7040) @@ -62,16 +62,16 @@ -- A function always return a result. The "return" instruction is automatically inserted, if missing. -- A function is not allowed to run a command. ::method makeFunctionDoer public class - use strict arg doable, context=.nil - if doable~isA(.String) then do - source = doable + use strict arg doable + if doable~isA(.RexxContextualSource) then do + source = doable~source if source~strip <> "" then do if source~caselessPos("return ") == 0 then source = "return" source source = "use arg value, index;" source end - doable = source + doable~source = source end - doer = doable~doer(context) + doer = doable~doer if doer~hasMethod("setSecurityManager") then doer~setSecurityManager(.CommandNotAllowed~new) -- A doer can be a message, which has not this method return doer @@ -79,15 +79,15 @@ -- An action can return optionnally a result, it's up to the user to insert the "return". -- An action can run a command, so no security restriction. ::method makeActionDoer public class - use strict arg doable, context=.nil - if doable~isA(.String) then do - source = doable + use strict arg doable + if doable~isA(.RexxContextualSource) then do + source = doable~source if source~strip <> "" then do source = "use arg value, index;" source end - doable = source + doable~source = source end - doer = doable~doer(context) + doer = doable~doer return doer @@ -108,13 +108,18 @@ -- that supplier to its primary output. ::class append public subclass pipeStage -::method init +::method initOptions expose supplier - use strict arg producer, context=.nil - if producer~hasMethod("doer") then producer = .pipeExtensions~makeFunctionDoer(producer, context)~do - if \producer~hasMethod("supplier") then supplier = .array~of(producer) -- for convenience, accept a non-supplier - supplier = producer~supplier - forward class (super) + supplier = .nil + unknown = .array~new + do a over arg(1, "a") + if supplier <> .nil then raise syntax 93.900 array("Only one producer is supported") + producer = a + if producer~hasMethod("doer") then producer = .pipeExtensions~makeFunctionDoer(producer)~do + if \producer~hasMethod("supplier") then supplier = .array~of(producer) -- for convenience, accept a non-supplier + supplier = producer~supplier + end + forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options ::method eof expose supplier @@ -137,14 +142,9 @@ -- pipeline before injecting the items produced by the supplier. ::class inject public subclass pipeStage -::method init - expose doer - use strict arg function, context=.nil - doer = .pipeExtensions~makeFunctionDoer(function, context) - forward class (super) - ::method initOptions - expose recursive limit depthFirst append pushIndex + expose doer recursive limit depthFirst append pushIndex + doer = .nil recursive = .false limit = -1 depthFirst = .true @@ -152,22 +152,30 @@ pushIndex = .false unknown = .array~new do a over arg(1, "a") - parse var a first "." rest - if "recursive"~caselessAbbrev(first, 3) then do - -- recursive[.limit|.depthFirst|.breadthFirst]* - recursive = .true - do while rest <> "" - parse var rest first "." rest - if first~dataType("W") then limit = first - else if "depthFirst"~caselessAbbrev(first, 1) then depthFirst = .true - else if "breadthFirst"~caselessAbbrev(first, 1) then depthFirst = .false - else raise syntax 93.900 array("Expected 'depthFirst' or 'breadthFirst' after "first". in "a) + if a~isA(.String) then do + parse var a first "." rest + if "recursive"~caselessAbbrev(first, 3) then do + -- recursive[.limit|.depthFirst|.breadthFirst]* + recursive = .true + do while rest <> "" + parse var rest first "." rest + if first~dataType("W") then limit = first + else if "depthFirst"~caselessAbbrev(first, 1) then depthFirst = .true + else if "breadthFirst"~caselessAbbrev(first, 1) then depthFirst = .false + else raise syntax 93.900 array("Expected 'depthFirst' or 'breadthFirst' after "first". in "a) + end + iterate end + if "append"~caselessAbbrev(a, 1) then do ; append = .true ; iterate ; end + if "replace"~caselessAbbrev(a, 3) then do ; append = .false ; iterate ; end + if "pushIndex"~caselessAbbrev(a, 1) then do ; pushIndex = .true ; iterate ; end end - else if "append"~caselessAbbrev(a, 1) then append = .true - else if "replace"~caselessAbbrev(a, 3) then append = .false - else if "pushIndex"~caselessAbbrev(a, 1) then pushIndex = .true - else unknown~append(a) + if a~hasMethod("doer") then do + if doer <> .nil then raise syntax 93.900 array("Only one producer is supported") + doer = .pipeExtensions~makeFunctionDoer(a) + iterate + end + unknown~append(a) end forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options @@ -258,14 +266,19 @@ -- the commands are authorized here, so DON'T FORGET the "return" instruction -- if you want to return a value !!!! -- Ex : assuming value==10 --- .do["2*value"] will not insert 20 in the pipeline, but will instead run the command "20". +-- .do {2*value} will not insert 20 in the pipeline, but will instead run the command "20". ::class do public subclass pipeStage -::method init +::method initOptions expose doer - use strict arg action, context=.nil - doer = .pipeExtensions~makeActionDoer(action, context) - forward class (super) + doer = .nil + unknown = .array~new + do a over arg(1, "a") + if doer <> .nil then raise syntax 93.900 array("Only one action is supported") + if a~hasMethod("doer") then do ; doer = .pipeExtensions~makeActionDoer(a) ; iterate ; end + unknown~append(a) + end + forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options ::method process expose doer @@ -280,12 +293,18 @@ -- A select pipeStage to execute a boolean filter passed as argument. ::class select public subclass pipeStage -::method init +::method initOptions expose doer - use strict arg filter, context=.nil - doer = .pipeExtensions~makeFunctionDoer(filter, context) - forward class (super) + doer = .nil + unknown = .array~new + do a over arg(1, "a") + if doer <> .nil then raise syntax 93.900 array("Only one filter is supported") + if a~hasMethod("doer") then do ; doer = .pipeExtensions~makeFunctionDoer(a) ; iterate ; end + unknown~append(a) + end + forward class (super) arguments (unknown) -- forward the initialization to super to process the unknown options + ::method process expose doer use strict arg value, index @@ -304,11 +323,14 @@ -- Use the option 'recursive' to search subdirectories recursively. ::class fileTree public subclass inject -::method init +::method initOptions expose doer doer = .context~package~findRoutine("fileTreeFind") - self~init:super(doer) + args = arg(1, "a") + args~append(doer) + forward class (super) arguments (args) + ::routine fileTreeFind use arg value, index if \value~isA(.File) then value = .File~new(value~string) Modified: sandbox/jlf/samples/pipeline/pipe_extension_test.output.txt =================================================================== --- sandbox/jlf/samples/pipeline/pipe_extension_test.output.txt 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/samples/pipeline/pipe_extension_test.output.txt 2011-07-06 08:03:21 UTC (rev 7040) @@ -1,7 +1,7 @@ -- The coactivity yields two results. -- The hello outputs are not in the pipeline flow (not displayed by the .displayer). -.coactivity~new("echo hello ; .yield[a] ; say hello ; .yield[b]")~pipe(.upper|.displayer) +.coactivity~new{echo hello ; .yield[a] ; say hello ; .yield[b]}~pipe(.upper|.displayer) HELLO 1 : A HELLO @@ -95,7 +95,7 @@ -- Do something for each item (no returned value). -.array~of(1, 2, 3)~pipe(.do["say 'value='value 'index='index"] | .displayer) +.array~of(1, 2, 3)~pipe(.do {say 'value='value 'index='index} | .displayer) value=1 index=an Array 1 : 1 value=2 index=an Array @@ -105,7 +105,7 @@ -- Do something for each item (the returned result replaces the item's value). -.array~of(1, 2, 3)~pipe(.do["return 2*value"] | .displayer) +.array~of(1, 2, 3)~pipe(.do {return 2*value} | .displayer) 1 : 2 2 : 4 3 : 6 @@ -113,7 +113,7 @@ -- Inject a value for each item (the returned value is appended). -- The index of the injected value is pushed on the current index. -.array~of(1, 2, 3)~pipe(.inject["value*10"] pushIndex append | .displayer) +.array~of(1, 2, 3)~pipe(.inject {value*10} pushIndex append | .displayer) 1 : 1 1|1 : 10 2 : 2 @@ -123,7 +123,7 @@ -- Inject two values for each item (each item of the returned collection is written in the pipe). -.array~of(1, 2, 3)~pipe(.inject[".array~of(value*10, value*20)"] pushIndex append | .displayer) +.array~of(1, 2, 3)~pipe(.inject {.array~of(value*10, value*20)} pushIndex append | .displayer) 1 : 1 1|1 : 10 1|2 : 20 @@ -139,18 +139,18 @@ -- The default order is depth-first. -- If the recursion is infinite, must specify a limit (here 0, 1 and 2). -- The option 'append' is not used, so the initial value is discarded. -.array~of(1, 2, 3)~pipe(.inject["value*10"] pushIndex recursive.0 | .displayer) +.array~of(1, 2, 3)~pipe(.inject {value*10} pushIndex recursive.0 | .displayer) 1|1 : 10 2|1 : 20 3|1 : 30 -.array~of(1, 2, 3)~pipe(.inject["value*20"] pushIndex recursive.1| .displayer) +.array~of(1, 2, 3)~pipe(.inject {value*20} pushIndex recursive.1| .displayer) 1|1 : 20 1|1|1 : 400 2|1 : 40 2|1|1 : 800 3|1 : 60 3|1|1 : 1200 -.array~of(1, 2, 3)~pipe(.inject["value*30"] pushIndex recursive.2 | .displayer) +.array~of(1, 2, 3)~pipe(.inject {value*30} pushIndex recursive.2 | .displayer) 1|1 : 30 1|1|1 : 900 1|1|1|1 : 27000 @@ -164,11 +164,11 @@ -- Factorial, no value injected for -1 -- The option 'pushIndex' is not used, so the index remains made of one value. -.array~of(-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)~pipe(.inject[, - "use arg n;", - "if n < 0 then return;", - "if n == 0 then return 1;", - "return n * .context~executable~call(n - 1)"] | .displayer) +.array~of(-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)~pipe(.inject { + use arg n + if n < 0 then return + if n == 0 then return 1 + return n * .context~executable~call(n - 1)} | .displayer) 2 : 1 3 : 1 4 : 2 @@ -183,7 +183,7 @@ -- Select files whose name contains "rexx" in c:\program files\oorexx .file~new("c:\program files\oorexx")~listFiles~pipe(, - .select["value~name~caselessPos('rexx') <> 0"] |, + .select {value~name~caselessPos('rexx') <> 0} |, .displayer, ) 11 : c:\program files\oorexx\ooRexxTry.rex @@ -204,7 +204,7 @@ -- Select files whose name contains "rexx" in c:\program files\oorexx, sorted by file size. -- The "length" message is sent to the value. .file~new("c:\program files\oorexx")~listFiles~pipe(, - .select["value~name~caselessPos('rexx') <> 0"] |, + .select {value~name~caselessPos('rexx') <> 0} |, .sortWith[.MessageComparator~new("length/N")] |, .displayer, ) @@ -225,8 +225,8 @@ -- Same as above, but simpler... You can sort directly by length, no need of MessageComparator .file~new("c:\program files\oorexx")~listFiles~pipe(, - .select["value~name~caselessPos('rexx') <> 0"] |, - .sort "value~length" |, + .select {value~name~caselessPos('rexx') <> 0} |, + .sort {value~length} |, .displayer, ) 16 : c:\program files\oorexx\rexx.ico @@ -246,8 +246,8 @@ -- Sort by file size, then by file extension (with only one .sort pipestage) .file~new("c:\program files\oorexx")~listFiles~pipe(, - .select["value~name~caselessPos('rexx') <> 0"] |, - .sort "value~length" "filespec('e', value~name)" |, + .select {value~name~caselessPos('rexx') <> 0} |, + .sort {value~length} {filespec('e', value~name)} |, .displayer, ) 12 : c:\program files\oorexx\orexxole.cls @@ -318,7 +318,7 @@ -- All private methods of the context. .context~instanceMethods~pipe(, - .select["value~isPrivate"] |, + .select {value~isPrivate} |, .sort byIndex |, .displayer, ) @@ -331,7 +331,7 @@ -- Each class is written in the pipeline (option append), followed by the returned methods. -- The option pushIndex lets have the name of the method in the index. .array~of(.RexxContext, .Package, .Method)~pipe(, - .inject["value~instanceMethods(value~class)"] append pushIndex |, + .inject {value~instanceMethods(value~class)} append pushIndex |, .sort byIndex |, .displayer, ) @@ -420,9 +420,9 @@ -- Methods (not inherited) of all the classes whose id starts with "R". .environment~pipe(, - .select["value~isA(.class)"] |, - .select["value~id~caselessAbbrev('R') <> 0"] |, - .inject["value~methods(value)"] append pushIndex |, + .select {value~isA(.class)} |, + .select {value~id~caselessAbbrev('R') <> 0} |, + .inject {value~methods(value)} append pushIndex |, .sort byIndex |, .displayer, ) @@ -465,6 +465,12 @@ REXXCONTEXT|PACKAGE : a Method REXXCONTEXT|RS : a Method REXXCONTEXT|VARIABLES : a Method +REXXCONTEXTUALSOURCE : The RexxContextualSource class +REXXCONTEXTUALSOURCE|CONTEXT : a Method +REXXCONTEXTUALSOURCE|COPY : a Method +REXXCONTEXTUALSOURCE|PACKAGE : a Method +REXXCONTEXTUALSOURCE|SOURCE : a Method +REXXCONTEXTUALSOURCE|SOURCE= : a Method REXXQUEUE : The RexxQueue class REXXQUEUE|DELETE : a Method REXXQUEUE|EMPTY : a Method @@ -488,52 +494,23 @@ -- All packages that are visible from current context, including the current package (source of the pipeline). --- Notice the circular dependency between packages (supported by inject - the recursion is stopped) : --- extensions.cls --> doers.cls --> extensions.cls --- This is because of Doers.AddVisibilityFrom. .context~package~pipe(, - .inject["value~importedPackages"] recursive append pushIndex |, + .inject {value~importedPackages} recursive append pushIndex |, .displayer index.15, - "' '~copies(index~items)", - ".file~new(value~name)~name", + {' '~copies(index~items)}, + {.file~new(value~name)~name}, newline, ) 1 pipe_extension_test.rex 1|1 extensions.cls 1|1|1 doers.cls -1|1|1|2 coactivity.cls -1|1|1|2|1 activity.cls -1|1|1|3 pipe_extension.cls -1|1|1|3|1 pipe.rex -1|1|1|3|3 coactivity.cls -1|1|1|3|3|1 activity.cls -1|1|1|3|4 rgf_util2_wrappers.rex -1|1|1|3|4|1 rgf_util2.rex -1|1|1|4 rgf_util2_wrappers.rex -1|1|1|4|1 rgf_util2.rex 1|1|2 functionals.cls 1|1|2|1 doers.cls -1|1|2|1|2 coactivity.cls -1|1|2|1|2|1 activity.cls -1|1|2|1|3 pipe_extension.cls -1|1|2|1|3|1 pipe.rex -1|1|2|1|3|3 coactivity.cls -1|1|2|1|3|3|1 activity.cls -1|1|2|1|3|4 rgf_util2_wrappers.rex -1|1|2|1|3|4|1 rgf_util2.rex -1|1|2|1|4 rgf_util2_wrappers.rex -1|1|2|1|4|1 rgf_util2.rex 1|2 coactivity.cls 1|2|1 activity.cls 1|3 pipe_extension.cls 1|3|1 pipe.rex 1|3|2 doers.cls -1|3|2|1 extensions.cls -1|3|2|1|2 functionals.cls -1|3|2|2 coactivity.cls -1|3|2|2|1 activity.cls -1|3|2|4 rgf_util2_wrappers.rex -1|3|2|4|1 rgf_util2.rex 1|3|3 coactivity.cls 1|3|3|1 activity.cls 1|3|4 rgf_util2_wrappers.rex @@ -544,10 +521,10 @@ -- Same as above, but in breadth-first order .context~package~pipe(, - .inject["value~importedPackages"] recursive.breadthFirst append pushIndex |, + .inject {value~importedPackages} recursive.breadthFirst append pushIndex |, .displayer index.15, - "' '~copies(index~items)", - ".file~new(value~name)~name", + {' '~copies(index~items)}, + {.file~new(value~name)~name}, newline, ) 1 pipe_extension_test.rex @@ -563,46 +540,20 @@ 1|3|3 coactivity.cls 1|3|4 rgf_util2_wrappers.rex 1|4|1 rgf_util2.rex -1|1|1|2 coactivity.cls -1|1|1|3 pipe_extension.cls -1|1|1|4 rgf_util2_wrappers.rex 1|1|2|1 doers.cls -1|3|2|1 extensions.cls -1|3|2|2 coactivity.cls -1|3|2|4 rgf_util2_wrappers.rex 1|3|3|1 activity.cls 1|3|4|1 rgf_util2.rex -1|1|1|2|1 activity.cls -1|1|1|3|1 pipe.rex -1|1|1|3|3 coactivity.cls -1|1|1|3|4 rgf_util2_wrappers.rex -1|1|1|4|1 rgf_util2.rex -1|1|2|1|2 coactivity.cls -1|1|2|1|3 pipe_extension.cls -1|1|2|1|4 rgf_util2_wrappers.rex -1|3|2|1|2 functionals.cls -1|3|2|2|1 activity.cls -1|3|2|4|1 rgf_util2.rex -1|1|1|3|3|1 activity.cls -1|1|1|3|4|1 rgf_util2.rex -1|1|2|1|2|1 activity.cls -1|1|2|1|3|1 pipe.rex -1|1|2|1|3|3 coactivity.cls -1|1|2|1|3|4 rgf_util2_wrappers.rex -1|1|2|1|4|1 rgf_util2.rex -1|1|2|1|3|3|1 activity.cls -1|1|2|1|3|4|1 rgf_util2.rex -- The .take pipeStage lets stop the preceding pipeStages when the number of items to take -- has been reached, whatever its position in the pipeline. supplier = .array~of(1,2,3,4,5,6,7,8,9)~supplier -supplier~pipe(.displayer '"2*"' value '"="' | .do["return 2*value"] | .take 2 | .displayer value newline) +supplier~pipe(.displayer "2*" value "=" | .do {return 2*value} | .take 2 | .displayer value newline) 2*1=2 2*2=4 say supplier~index 3 -supplier~pipe(.displayer '"4*"' value '"="' | .do["return 4*value"] | .take 4 | .displayer value newline) +supplier~pipe(.displayer "4*" value "=" | .do {return 4*value} | .take 4 | .displayer value newline) 4*3=12 4*4=16 4*5=20 @@ -633,7 +584,7 @@ supplier2 = .array~of(10,11,12,13,14,15,16,17,18,19)~supplier -- The first .take limits supplier1 to 2 items. -- The second .take sees the two items produced by supplier1, so only 3 items are accepted from supplier2. -supplier1~pipe(.take 2 | .append[supplier2] | .take 5 | .displayer) +supplier1~pipe(.take 2 | .append supplier2 | .take 5 | .displayer) 1 : 1 2 : 2 1 : 10 @@ -643,7 +594,7 @@ 3 say supplier2~index 4 -supplier1~pipe(.take 4 | .append[supplier2] | .take 9 | .displayer) +supplier1~pipe(.take 4 | .append supplier2 | .take 9 | .displayer) 3 : 3 4 : 4 5 : 5 @@ -669,7 +620,7 @@ -- The *.txt files of ooRexx "c:\program files\oorexx"~pipe(, .fileTree recursive |, - .select["filespec('e', value~name) == 'txt'"] |, + .select {filespec('e', value~name) == 'txt'} |, .displayer, ) 1 : c:\program files\oorexx\CPLv1.0.txt @@ -682,7 +633,7 @@ 1 : c:\program files\oorexx\samples\oodialog\wav\readme.txt --- Alphanumeric words found in the *.txt files of ooRexx. +-- Alphanumeric words of 15+ chars found in the *.txt files of ooRexx. -- -- Exemple of result : -- 1|c:\program files\oorexx\CPLv1.0.txt|149|8 : appropriateness @@ -693,8 +644,8 @@ -- "c:\program files\oorexx"~pipe(, .fileTree recursive |, - .select["filespec('e', value~name) == 'txt'"] |, - .fileText | .words | .select["value~datatype('a') & value~length >= 15"] |, + .select {filespec('e', value~name) == 'txt'} |, + .getFiles | .words | .select {value~datatype('a') & value~length >= 15} |, .sort caseless | .displayer, ) 1|c:\program files\oorexx\CPLv1.0.txt|149|8 : appropriateness Modified: sandbox/jlf/samples/pipeline/pipe_extension_test.rex =================================================================== --- sandbox/jlf/samples/pipeline/pipe_extension_test.rex 2011-07-06 07:59:16 UTC (rev 7039) +++ sandbox/jlf/samples/pipeline/pipe_extension_test.rex 2011-07-06 08:03:21 UTC (rev 7040) @@ -1,4 +1,3 @@ -call Do... [truncated message content] |