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

About Attempt

 [1/5] from: reboler::ifrance::com at: 26-Dec-2002 19:53


Hi List,
>From the syntax shown with "HELP ATTEMPT" it seems possible to use the function like this:
attempt a However when 'a is not defined an error is rised.
>> attempt a
** Script Error: a has no value ** Where: do-boot ** Near: attempt a obviously the right syntax is more like attempt [a] or attempt [1 / 0] Do you think it's worth sending this to RT feedback? Patrick

 [2/5] from: al:bri:xtra at: 27-Dec-2002 9:06


Patrick wrote:
> attempt a > However when 'a is not defined an error is rised.
<<quoted lines omitted: 7>>
> attempt [1 / 0] > Do you think it's worth sending this to RT feedback?
The evaluation of 'a happens "outside" of the value (function!) referred to by 'attempt. But you have found a problem with 'attempt.
>> attempt 123
** Script Error: try expected block argument of type: block ** Where: attempt ** Near: if not error? set/any 'value
>> source attempt
attempt: func [ {Tries to evaluate and returns result or NONE on error.} value ][ if not error? set/any 'value try :value [get/any 'value] ]
>> source try
try: native [ {Tries to DO a block and returns its value or an error.} block [block!] ] 'attempt should have the same function input type as 'try. That's easy to correct. Just insert the following into your %user.r file (or get my %Patches.r script): attempt: func [ {Tries to evaluate and returns result or NONE on error.} value [block!] ][ if not error? set/any 'value try value [get/any 'value] ] Note that I've changed the get-word ":value" to a word "value" as the 'get isn't needed. Now 'attempt works properly:
>> attempt [1 / 0]
== none
>> attempt [1 / 2]
== 0.5
>> attempt a
** Script Error: a has no value ** Near: attempt a
>> attempt 123
** Script Error: attempt expected value argument of type: block ** Near: attempt 123 I'll fill out the feedback form as well. Andrew Martin ICQ: 26227169 http://valley.150m.com/

 [3/5] from: nitsch-lists:netcologne at: 26-Dec-2002 23:37


pat665 wrote:
>Hi List, >>From the syntax shown with "HELP ATTEMPT" it seems possible to use the function like this:
<<quoted lines omitted: 10>>
>attempt [1 / 0] >Do you think it's worth sending this to RT feedback?
No, that is normal behavior. rebol evaluates from left to right, first the arguments, then the function. so first it evaluates 'a, then 'attempt . 'a has no value, so 'bang . 'attempt is never called.
>Patrick >
-volker

 [4/5] from: nitsch-lists:netcologne at: 26-Dec-2002 23:57


Volker Nitsch wrote:
> pat665 wrote: >
[snip]
> No, that is normal behavior. rebol evaluates from left to right,
right to left of course..
> first the arguments, then the function. > so first it evaluates 'a, then 'attempt .
<<quoted lines omitted: 3>>
>> > -volker
-volker

 [5/5] from: reboler:ifrance at: 27-Dec-2002 15:01


Hi Andrew, Thanks for the explanations and the posting to feed back. I noticed from recent post that Carl S. use often 'attemp in its recent request-dir. Amazing the lot one can find from Carl S. code. Patrick _____________________________________________________________________ GRAND JEU SMS : Pour gagner un NOKIA 7650, envoyez le mot IF au 61321 (prix d'un SMS + 0.35 euro). Un SMS vous dira si vous avez gagné. Règlement : http://www.ifrance.com/_reloc/sign.sms

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted