Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: steel... update... of the week (for more advanced rebolers)

From: g:santilli:tiscalinet:it at: 28-Jun-2003 10:03

Hi Maxim, On Saturday, June 28, 2003, 12:43:57 AM, you wrote: MOA> But I sorely miss some aspects like private methods and MOA> members which, are most usefull (I find) when developping MOA> frameworks, api, and tools. The nice thing about REBOL is that you can add them yourself to the language. :-) MOA> aren't custom types just in the sdk? Nope, they're an hack of mines (with help from Ladislav and Romano). ;-) You can find it both on: http://www.compkarori.com/vanilla/ and: http://www.rebol.it/giesse/custom-types.r http://www.rebol.it/giesse/complex.r complex.r implements the complex! custom type. WARNING: just an hack, undocumented, etc. etc. Feel free to ask me about how it works etc. MOA> last-arg-used: my-facet-word-function args MOA> new-offset: find vid-spec last-arg-used? It does something like: new-offset: next my-facet-word-function args Let me see if I can find the real code... Ok, inside LAYOUT you have: new: select styles value if not new [error "Unknown word or style:" value break] set [specs facets] do-facets specs new/words styles new: make new either val: select facets 'with [expand-specs new val] [[]] if :var [set :var new new/var: to-word :var var: none] new/style: value new/pane-size: pane-size new/styles: styles new/flags: exclude new/flags state-flags if not flag-face? new fixed [new/offset: where] grow-facets new facets With DO-FACETS and GROW-FACETS being: do-facets: func [ {Build block of parameters (and attribute words) while not a vid word or style.} specs words styles /local facets item ][ facets: copy [] forall specs [ item: first specs if set-word? :item [break] either word? :item [ if any [find vid-words item find styles item] [break] facets: insert facets either any [ all [words find words item] all [find facet-words item] ] [to-lit-word item] [item] ] [ facets: insert/only facets :item ] ] reduce [specs reduce head facets] ] grow-facets: func [new args /local pairs texts colors files blocks tmp][ new/facets: args pairs: clear [] texts: clear ["imanXwin kludge"] colors: clear [] files: clear [] blocks: clear [] images: clear [] forall args [ val: first args switch/default type?/word val [ pair! [append pairs val] integer! [append pairs val] string! [append texts val] tuple! [append colors val] block! [append/only blocks val] file! [append files val] url! [append files val] image! [append images val] char! [new/keycode: val] logic! [new/data: new/state: val] decimal! [new/data val] time! [new/rate: val] word! [ any [ if all [new/words tmp: find new/words :val] [ until [function? first tmp: next tmp] args: do first tmp new args ] if tmp: find facet-words :val [ either 0 >= offset? tmp fw-with [ until [function? first tmp: next tmp] args: do first tmp new args ] [ either tail? args: next args [error "Missing argument for" :val] [ set in new val either positive? offset? fw-feel tmp [ first args ] [ if first args [make any [get in new val vid-face/:val] first args] ] ] ] ] ] ] ] [ error "Unrecognized parameter:" val ] ] new/multi/text new texts new/multi/size new pairs new/multi/file new files new/multi/image new images new/multi/color new colors new/multi/block new blocks ] Notice that DO-FACETS is converting "keywords" to lit-words and then applying REDUCE to the whole block. The result is the ARGS block that then is passed to GROW-FACETS. Here, ARGS is used in a FORALL loop (and this is the reason for the "extra" NEXT you get); the part that uses custom facets from face/words is: if all [new/words tmp: find new/words :val] [ until [function? first tmp: next tmp] args: do first tmp new args ] MOA> And it works fine... Am I just lucky? See above. You're just ignoring any other facet after your ATTACH. :-) Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r