Commit 54be00ca authored by POTTIER Francois's avatar POTTIER Francois

Updated comment.

parent d4aae8b6
...@@ -26,23 +26,21 @@ module Make (T : TABLE) = struct ...@@ -26,23 +26,21 @@ module Make (T : TABLE) = struct
(* --------------------------------------------------------------------------- *) (* --------------------------------------------------------------------------- *)
(* OK, OK. I said I would stop using [Obj.magic], yet here we go again. (* OK, OK. I said I would stop using [Obj.magic], yet here we go again. I
I need to extend the type [T.token] with an extra element, which need to extend the type [T.token] with an extra element, which represents
represents the [error] pseudo-token. I don't want to pay an extra the [error] pseudo-token. I don't want to pay an extra box in memory or
box in memory or an extra field in the [env] record. I don't want an extra field in the [env] record. (I have measured the cost of moving
to add a branch to the type [T.token] because that would bother the from 5 to 6 fields in this record to be 30%. This is more than I
user (that would be an incompatible change) and that would make some expected!) I don't want to add a branch to the type [T.token] because
exhaustive case analyses appear non-exhaustive. So, here we go. We that would bother the user (that would be an incompatible change) and
allocate a dummy box in memory and use its address as a unique value that would make some exhaustive case analyses appear non-exhaustive. So,
which cannot possibly be confused with a legit inhabitant of the type here we go. We allocate a dummy box in memory and use its address as a
[token]. (Right?) *) unique value which cannot possibly be confused with a legit inhabitant of
the type [token]. (Right?) *)
let error_token : token = let error_token : token =
Obj.magic (ref 0xDEADBEEF) Obj.magic (ref 0xDEADBEEF)
(* We adopt the convention that we have an [error] token on the input
stream if and only if [env.token] is [deadbeef]. *)
(* --------------------------------------------------------------------------- *) (* --------------------------------------------------------------------------- *)
(* In the code-based back-end, the [run] function is sometimes responsible (* In the code-based back-end, the [run] function is sometimes responsible
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment