[erlang-questions] Reassigning variables

Matthew Dempsky <>
Wed Mar 18 07:07:55 CET 2009


On Tue, Mar 17, 2009 at 10:35 PM, Matthew Dempsky <> wrote:
> I'd prefer not to post the actual code that motivated this discussion,
> but I will point out some code in OTP that uses numbered variables:
> the Erlang compiler.  It uses them quite significantly, with some
> functions

Sorry, this was supposed to read "with some functions going as high as
St10".

Also, here's a list of a few other functions in OTP that use numbered
variables:

  - zip:put_z_files/6
  - epp:predef_macros/1
  - erl_lint:post_traversal_check/2
  - global:resolved/5
  - asn1ct_parser2:parse_Type/1
  - mnesia_log:do_backup_master/1
  - xmerl_scan:scan_document/1
  - xmerl_xsd:element_content/3
  - tftp_engine:server_init/2

Of course, this isn't a comprehensive listing of functions that do so
(e.g., the asn1 and xmerl applications use them a ton, and I only
quickly looked through a few apps and grabbed some concrete examples),
but instead to show that it's not just a bad practice limited to my
code. :P

I'll also admit I've only quickly looked over the above examples, and
there might be reasons why the numbered variables will *never* need to
be renumbered (e.g., I found inet_dns:encode/1 uses numbered
variables, but that's arguably excusable because DNS is never going to
add more sections to the wire format), but I doubt that's generally
the case.



More information about the erlang-questions mailing list