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

[REBOL] Re: [bug?] Problem with 'load

From: moliad:aei:ca at: 29-Nov-2003 12:05

Sunanda et al. thanks for asking me to post an example of encompass in action. I, myself, was looking for meaningfull examples, and its fun to have one in the context of a real problem. here is an example of how to patch load so that the /all refinement works as expected. I have used the method of Romano (hope you don't mind... I take no credit for that :-) to safely load the header (with a tiny improvement which allows me to find the 'rebol word even if its not at the begining. rload: :load load: encompass/pre 'rload [ ; check if header refinement was used if header [ ; header and library modes are not compatible (but could be). if not library [ ; the /all refinement is the ONLY case where the header should not be read if all [ ; source is defined in load, so it will have the same meaning here if string! <> type? source [ source: read source ] ; at this point we ARE SURE TO HAVE TEXT! ; source: a if source: script? find source "rebol" [ attempt [source: construct/with first load/next find source "[" system/standard/script] ] return source ; this will actually shortcut the load call. ] ] ] ] script: {rebol [author: "someone" needs: [view 2.0.0]] gkjnfdkljhn dfihroih ro[h rtoi } ; --- THIS WILL WORK !!! --- probe load/header/all script ; --- THIS WILL FAIL (which is expected) !!! --- probe load/header script Hope this helps. -MAx