Ticket #183 (new defect)

Opened 16 years ago

Last modified 16 years ago

dracula rename export example from reference docs does not work

Reported by: pnkfelix Owned by: cce
Priority: major Milestone:
Component: cce/dracula.plt Keywords:
Cc: Version:
Racket Version: 4.1.5

Description

Here is (slightly modified) code from the 8.2 reference manual:

(interface IAssociative
  (sig mulop (x y))
  (con mulop-associative
       (equal (mulop a (mulop b c))
              (mulop (mulop a b) c))))

(interface ICommutative
  (include IAssociative)
  (con mulop-commutative
       (equal (mulop a b) (mulop b a))))

(interface IDistributive
  (include IAssociative)
  (include ICommutative)
  (sig addop (x y))
  (con addop/mulop-distributive
       (equal (mulop a (addop b c))
              (addop (mulop a b) (mulop a c)))))

(module MDistributiveA
  (defun add (a b) (+ a b))
  (defun mulop (a b) (* a b))
  (export IAssociative (addop add))
  (export ICommutative (addop add))
  (export IDistributive (addop add)))

(module MDistributiveB
  (defun add (a b) (+ a b))
  (defun mul (a b) (* a b))
  (export IAssociative (addop add))
  (export ICommutative (addop add))
  (export IDistributive (addop add) (mulop mul)))

Hitting RUN for this example raises the following error:

. mulop: undefined in: mulop

(it also highlights the mulop in the IAssociative interface, which is not terribly useful and may be a usability bug; read on for why I think this.)

If I comment out the definition of MDistributiveB, so that MDistributiveA is the only module providing relevant exports, then the code runs fine.

I assume the problem here is something along the lines of "the docs should be changed so that the MDistributive module exports mul/mulop instead of add/addop into the IAssociative interface.


More generally, all of the examples in the dracula docs need to be tested directly.

Change History

Changed 16 years ago by pnkfelix

In particular, this version of MDistributive also seems to work, and is probably the example that Carl had intended:

(module MDistributive
  (defun add (a b) (+ a b))
  (defun mul (a b) (* a b))
  (export IAssociative (mulop mul))
  (export ICommutative (mulop mul))
  (export IDistributive (addop add) (mulop mul)))

Changed 16 years ago by pnkfelix

(it also highlights the mulop in the IAssociative interface, which is not terribly useful and may be a usability bug; read on for why I think this.)

In case its not clear: the usability bug I am talking about here is that the wrong thing is being highlighted. I would have had a much easier time understanding what was going wrong here if DrScheme? had highlighed (instead or in addition) the following line in MDistributiveB:

  (export IAssociative (addop add))

The current highlighting makes it seem like the interface definition is inherently wrong, but the problem is not IAssociative on its own, but instead the interaction between IAssociative and MDistributiveB


Note: See TracTickets for help on using tickets.