Tuesday, May 4, 2004, 4:48:10 AM, Volker wrote:

> Now instead of "send" i could not resist to press "hack", and here
> is:

thanks for sharing!

i found it exciting that this piece of code uses loads of typical
REBOL idioms - i.e. it can be considered a piece of REBOL wizardry :)

> ;the code
> dumpers: copy[]
> add-dump: func[guard dump-how][
>  insert dumpers reduce[guard dump-how]
> ]
> dump: func[val][
>  bind dumpers 'val
>  foreach[guard dump-how] dumpers [
>   if attempt guard [attempt dump-how break]
>  ]
>  :val
> ]
> add-dump [true][probe val]

> ;demo, dumping an object smart
> ctx: context[type: 'my-type id: 1 lots-of-data: [1 2 3]]
> dump 1
> dump ctx

> add-dump ['my-type = val/type][
>       print ["my-type" val/id "has" length? val/lots-of-data "elements"]
> ]
> dump 1
> dump ctx

> ;demo-output
> ;first unsmart
> 1  
> make object! [ 
>     type: 'my-type 
>     id: 1 
>     lots-of-data: [1 2 3] 
> ] 
> ;now smarter
> 1 
> my-type 1 has 3 elements 

-- 
Best regards,
 Andreas


-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to