‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Thursday, September 26, 2019 9:56 AM, Matthew Flatt <mfl...@cs.utah.edu> wrote:
> At Thu, 26 Sep 2019 00:46:23 +0000, "'Wayne Harris' via Racket Users" wrote: > > > I think my message below neither asked any question nor did it contain the > > adequate politeness which I so much think every e-mail should have. > > I don't see any problem with your message. It's more that the handin > server doesn't get a lot of love. I know the little part that I use, > and not much else... I guess there wasn't technically, but it did lack the care that is usual of me, so I didn't really like it and wanted to express that. Thanks for your attention. > > > I haven't figured out how to forbid the use of length in submitted code. > > > I'm a little lost with > > > :language > > > :with-submission-bindings > > > I did understand > > > :requires > > > so I'm able to let submissions use extra libraries, but I'd like to > > > forbid, > > > say, length in '(special beginner) too. > > There doesn't seem to be a simple way of disallowing the use of > `length`. Since `submission` is bound to the whole submission content, > you could have `pre:` action that reads and searches for the symbol > 'length: > > #lang s-exp handin-server/checker > (require racket/gui/base) > > (check: :language '(special beginner)) > > (pre: > (define (mentions-length? r) > (cond > [(eq? r 'length) #t] > [(pair? r) (or (mentions-length? (car r)) > (mentions-length? (cdr r)))] > [else #f])) > (define-values (defns interactions) (unpack-submission submission)) > (define p (open-input-text-editor defns)) > (parameterize ([read-accept-reader #t]) > (let loop () > (define r (read p)) > (unless (eof-object? r) > (when (mentions-length? r) > (error "length not allowed")) > (loop))))) (I think ``my editor'' couldn't help but destroy your indentation. I wonder if there anything I could do. Sorry about that.) I think you're scanning the user code and looking for any mention of length. That is nice! I can use that for many other things. Thanks! > A more precise approach would be to expand the program and check > whether there's any identifier bound to `length` that was part of the > original program (as opposed to introduced by a macro), but that's > probably more than you need. I'm not sure I get this idea, but let me take one thing at a time. Let me study and investigate the first approach which seems to suffice for now. Thanks! > Or, of course, you could have a language > that's like Beginner without `length`, but that's probably too much > trouble for your students to set up. I suppose it would --- if they'd submit from home, say. -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CBDxkV-H6eGfxTHxroWHOk7PEiKvAyFFHsfjlcbww4dNxIoZZF3a-mXJ-ETXE0gAQZ6hcfATO3cNXYH8L-C061cxASI1jxr3FsmEP4huhS0%3D%40protonmail.com.