Trap

  

Trap[expr] 

...has no effect on expr unless...

Return[returnExpr] 

...is encountered while evaluating expr. 

 

If elicit is an ElicitationForm, 

Trap[elicit, eval] 

...returns the first instance of elicit encountered in the evaluation of eval. 

If elicit is not encountered anywhere in eval, Trap[elicit, eval] is equivalent to eval.

  

Trap[elicit, eval , exec] 

...evaluates exec if elicit is encountered in the execution of eval. 

If elicit is not encountered, the result of eval is returned, and exec is not executed. 

If elicit is encountered in eval, all or part of that matching form can be used to substitute values into exec, which is then evaluated and returned.

  

  

See English definition of "trap".



TrapReturn

The elicitation...

(1)                    Trap[expr]

...has no effect on expr unless...

(2)                    Return[returnExpr]

...is encountered, in which case returnExpr is evaluated and returned as (1)'s output.  If Return[...] is not encountered anywhere in expr, then (1) is equivalent to expr.



TrapName


A trap is set for a Pattern using an ElicitationForm as bait.

If elicit is an ElicitationForm,


(3)                    Trap[elicit, eval]


...returns the first instance of elicit encountered in the evaluation of eval.

If elicit is not encountered anywhere in eval, (3) is equivalent to eval. All or part of the Expression caught in a Trap, is used to parameterize the last parameter in the 3 argument Trap:
 

(4)                    Trap[elicit, eval, exec]

...evaluates exec if elicit is encountered in the execution of eval.

If elicit is not encountered, the result of eval is returned, and exec is not evaluated.

If an Expression matching elicit is encountered in the evaluation of eval,  the SubstitutionNames in elicit (if any), are used to parameterize exec, which is then evaluated as the trap result.

The Trap in either (3) or (4) is a scoping construct for the ElicitationForm together with any contained SubstitutionNames, (Type[_, _] constructs), in elicit.  The Trap[elicit,...]-construct is a lexical scoping device in the sense that it is a locally elicited process sequence with two or three arguments. In the constructs in (3) or (4), "elicit" is a TrapName because it is a local (trapped) ElicitationForm assignment.

The 2-argument Trap[_, _] defined in (3), and the 3-argument Trap[_, _, _] in (4) are both composed from the Trap[...Return[...]...] construct defined in (1) and (2).  See TrapElicitEvalExec for details.




English definition of "trap"

  

trap n. 

1. A device, as a pitfall, snare, or machine that shuts suddenly as with a spring, for taking game, destructive animals, etc.; a gin. 

2. Something by or in which one is unsuspectingly caught, injured, led astray, discovered in lawbreaking, or the like; a condition, device, expedient, etc., for entrapping the unwary; as, a golf course with many traps; this stretch is a trap for speeding motorists. 

3. Slang. a Trickery; cunning. 

     b Brit. & Colonial. A detective or policeman.  

     c Mouth; as, to shut one�s trap. 

     d A mold for a counterfeit coin. 

4. Any of various devices permitting one kind of thing to pass through while restraining another; as; 

    a A device to separate sand and silt from flowing water. 

    b A stream trap. 

5. a A place I a water pipe, pump, etc., where something is held, as an air pocket. 

    b A recess for oil bottles, etc., in the butt of a musket or rifle. 

6. Short for TRAPBALL, TRAP CROP, TRAP DOOR, TRAP NEST. 

7. Fishing. A net, or a part of a net, so constructed as to lure fish into an enclosed space from which it is difficult for them to escape; a trap net. 

8. Music. A percussion instrument; specif. and usually, pl., the group of such instruments, esp. in a dance or theater orchestra. 

9. Ore Dressing. A device to catch mercury or amalgam escaping from amalgamation plates. 

10. Plumbing. A device for drains, sewers, etc,, consisting of a bend or partitioned chamber in which the liquid forms a seal to prevent the passage of sewer gas, etc., as, a stench trap. 

...


trap v. 

1. To catch, take, or make fall, in or as in a trap; to capture, defeat, detect, confound, etc,, by stratagem; to ensnare; entrap; as, to trap foxes or beaver; to trap a foe, a lawbreaker, or a witness. 

2. To provide with a trap or traps; as: 

   a To set with traps, or snares; as, to trap a field infested with rabbits.  

   b To install a trap (sense 10) in; as, to trap a drain. 

3. To stop a hold by a trap (senses 5a, 10); to separate by a trap, as water from stream; --sometimes with out. 

4. To release or discharge from a trap (sense 11 b). 

5. Baseball. To field (the ball) with a pickup. 

-- Intransitive. 

1. To set traps for game; to make a business of trapping game or, esp., fur-bearing animals; as, to trap for beaver. 

2. To manage a trap (sense 11 b) or traps for shooting. 

3. To become trapped as steam in a radiator by air. 

Ant. Free, liberate, loose, release, extricate. 

                                    [From Websters1949Unabridged.] 


  

equivalent adj. 

In this Language Specification, two Expressions are said to be equivalent, when they evaluate to the same result and have the same environmental consequence.  Two equivalent Expressions may require different amounts of Time to evaluate and may have different forms.  Equivalence transformations or identities are used in language processing systems for expression simplification and usually to ascribe meaning.




Grok32`

(c) 2004-2007 by 

John Van Wie Bergamini. 

All rights reserved.

Hosted by www.Geocities.ws

1