On Montag, 3. Mai 2004 23:23, Gregg Irwin wrote:
> Hi Anton, Andreas, et al
>

> Any other candidate host functions that map to this functionality?
>
> GI> What about a refinement on PROBE that makes it produce DUMPed
> GI> output?
>

probe/dump - longer to type. when i debug i want it short. even shorter than 
probe. ?? most of the time. How about a name similar to that? but 'dump would 
work.

>
>   * It means less to learn because once they find PROBE they've
>     already found DUMP
>

how about: 
help probe ->>
"Prints a molded, unevaluated value and returns the same value. similar: ? ?? 
dump"
Also
!>>help dump
Found these words: 
   dump-face       function! Print face info for entire pane. (for debugging) 
   dump-obj        function! Returns a block of information about an object. 
   dump-pane       function! Print face info for entire pane. (for debugging) 
there is a convention to call such functions dump-*. that the integrator is 
called 'dump makes sense.

>   * You don't have to add extra docs in each one saying how they
>     differ, you just doc the refinement that tells how it changes
>     the behavior.
>

that can be done with a naming-convention too. because "help round-" would do 
a "wildcard-search". In case of 'round i prefer refinements. In case of 'dump 
i would prefer lots of dump-* and dump with a switch. because then its most 
easy to add new dumpers. We could even have some support to add new dumpers 
on the fly, like
  add-dump ['my-type = val/type][dump-my-type]

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

;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 


>
> -- Gregg

-Volker

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

Reply via email to