Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
menhir
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
12
Issues
12
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
POTTIER Francois
menhir
Commits
54be00ca
Commit
54be00ca
authored
Dec 05, 2014
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated comment.
parent
d4aae8b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
13 deletions
+11
-13
src/engine.ml
src/engine.ml
+11
-13
No files found.
src/engine.ml
View file @
54be00ca
...
...
@@ -26,23 +26,21 @@ module Make (T : TABLE) = struct
(* --------------------------------------------------------------------------- *)
(* OK, OK. I said I would stop using [Obj.magic], yet here we go again.
I need to extend the type [T.token] with an extra element, which
represents the [error] pseudo-token. I don't want to pay an extra
box in memory or an extra field in the [env] record. I don't want
to add a branch to the type [T.token] because that would bother the
user (that would be an incompatible change) and that would make some
exhaustive case analyses appear non-exhaustive. So, here we go. We
allocate a dummy box in memory and use its address as a unique value
which cannot possibly be confused with a legit inhabitant of the type
[token]. (Right?) *)
(* OK, OK. I said I would stop using [Obj.magic], yet here we go again. I
need to extend the type [T.token] with an extra element, which represents
the [error] pseudo-token. I don't want to pay an extra box in memory or
an extra field in the [env] record. (I have measured the cost of moving
from 5 to 6 fields in this record to be 30%. This is more than I
expected!) I don't want to add a branch to the type [T.token] because
that would bother the user (that would be an incompatible change) and
that would make some exhaustive case analyses appear non-exhaustive. So,
here we go. We allocate a dummy box in memory and use its address as a
unique value which cannot possibly be confused with a legit inhabitant of
the type [token]. (Right?) *)
let
error_token
:
token
=
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment