Differences between execution in DrRacket and Command Line

45 views
Skip to first unread message

Rhazes Spell

unread,
Jul 2, 2021, 11:25:01 AM7/2/21
to Racket Users
Hello-
I have been using Racket for about 18 months for personal projects and teaching. I have been doing all of my work in DrRacket but I wanted to interact with a module that I wrote on the interactive command line this morning. I am getting an error while using the command line that I am not getting in the Dr.Racket Interactions window.

This is the code that runs fine in the Interactions window of DrRacket:
(input-financial-data) deserializes the data properly and populates the list variable that I am using correctly. The lines of code in the module are:

...
(define data (input-financial-data data-file))
(printf "~a data records read~n" (length data))
(define closed-trades (filter trade-closed? data))
...

On the command line when running:
$> racket -i
...
> (enter! "year-1-analysis.rkt")
I get an error while trying to read a file of serialized structs. The error is:

given value instantiates a different structure type with the same name
  expected: trade?
  given: (trade #1=(date* 0 0 0 21 04 2017 3 294 #t -25200 0 "PDT") 'PYPL "simInvest" (list (transaction 29555578996 #1# "simInvest" 'PYPL 'BOUGHT 30 43.70) (transaction 29556891965 (date* 0 0 0 23 04 2017 3 294 #t -25200 0 "PDT") "simInvest" 'PYPL 'B...


My question is what are the differences between using a module in DrRacket versus on the command line? Thank you in advance for your assistance.

Cheers,
r..

Shu-Hung You

unread,
Jul 12, 2021, 11:49:31 AM7/12/21
to Racket Users
One difference is that DrRacket works as if you had enter!-ed the file
"year-1-analysis.rkt" from the very beginning and never left the
module or re-required it. However, I don't see how that could trigger
the current issue.

The error message suggests that the module defining the trade
structure has been instantiated multiple times in different
namespaces. It could be that some other operations unintentionally
caused the problem.

> --
> You received this message because you are subscribed to the Google Groups "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/b438252e-ef79-4bfe-ac7b-2f508d3419ddn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages