I don't know if this is a feature request or just a whine, but I would love to be able to introduce local before list abbreviations.
Unfortunately, you can't use local in BSL, because the macro raises an error if you have a define that's not on the top level. I can use let, but local is especially nice, because it doesn't involve new syntax. Students just keep using the define they used at the top level, but hide the scope inside a function (or an expression or whatever). In particular, it's nice that local lets them use define to name constants or functions, whereas let would require the introduction of lambda for that.
I looked at the code to see if I could easily fix the problem, but the code is quite dense.
I similarly was trying to figure out if I could modify define-struct in two ways:
-
I wanted students to be able to put signatures for fields:
(define-struct student ([first String] [last String] [grade Natural])and have signatures provided formake-studentand the selectors. -
I wanted to auto-create something like lenses for structs. Especially when you're trying to create worlds, you spend a lot of time copying state. A handler may want to modify one or two fields in a struct that has several, so you
(make-struct (struct-field1 orig-struct) (struct-field2 orig-struct) ... (f (struct-fieldn orig-struct)))and you forget what you were trying to do, or your code gets long and you can't see all of it at once.
What I'm envisioning is that a struct like posn would get posn-with-x and posn-with-y, that would take a posn and a new x or y value and handle all the boilerplate.
In other words, to promote a student stu to the next grade, you'd just do (student-with-grade stu (+ 1 (student-grade stu))).
Unfortunately, I think I found out where define-struct is defined, but there's a ton of stuff in there, and I can't find the place where the constructors, selectors, and predicate are actually generated. I guess it's possible because they're actually generated by something like define-record-type, but I kind of got lost in the details.