caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Compiler internals question
@ 1998-07-02  8:55 Michael Sperber [Mr. Preprocessor]
  1998-07-04 12:47 ` Xavier Leroy
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Sperber [Mr. Preprocessor] @ 1998-07-02  8:55 UTC (permalink / raw)
  To: caml-list


[ Many thanks, Xavier, for your previous answer to my byterun
question! ]

Consider the following O'Caml fragment:

type bla = A of int | B of int * int | C of int * int * int

match f 5 with B(_, _) -> 17

The latter line is compiled into Lambda intermediate code as:

(catch
  (let (match/51 (apply (global f/49g) 5))
    (catch
      (switch match/51
       case tag 1:
        (let (match/52 (field 0 match/51) match/53 (field 1 match/51)) 17))
     with exit))
 with (raise (makeblock 0 (global Match_failure/12g) [0: "" 0 28])))

Does the inner "catch" serve any purpose or is it redundant?

-- 
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Compiler internals question
  1998-07-02  8:55 Compiler internals question Michael Sperber [Mr. Preprocessor]
@ 1998-07-04 12:47 ` Xavier Leroy
  0 siblings, 0 replies; 2+ messages in thread
From: Xavier Leroy @ 1998-07-04 12:47 UTC (permalink / raw)
  To: Michael Sperber [Mr. Preprocessor], caml-list

> (catch
>   (let (match/51 (apply (global f/49g) 5))
>     (catch
>       (switch match/51
>        case tag 1:
>         (let (match/52 (field 0 match/51) match/53 (field 1 match/51)) 17))
>      with exit))
>  with (raise (makeblock 0 (global Match_failure/12g) [0: "" 0 28])))
> 
> Does the inner "catch" serve any purpose or is it redundant?

It is redundant.  A latter pass (the translation from Lambda to
bytecode) will remove it by applying the equivalence (catch e with exit) == e.

- Xavier Leroy





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-07-06 16:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-07-02  8:55 Compiler internals question Michael Sperber [Mr. Preprocessor]
1998-07-04 12:47 ` Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).