<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Is there a way to define a type constructor that accepts keyword arguments? <div><br></div><div>I know that things like the Class type constructor do this already, so is there a way to define something like this myself? </div><div><br></div><div>The reason is I have a struct that represents a dimension (as in dimensional analysis and units) and I want a type constructor that lets me make types for specific instances of it without having to remember what order the fields go in:</div><div><br></div><div><font face="Courier New">(struct: (Length-Expt Mass-Expt Time-Expt Charge-Expt Temp-Expt)</font></div><div><font face="Courier New"> dimension</font></div><div><font face="Courier New"> ([length-expt : Length-Expt]</font></div><div><font face="Courier New"> [mass-expt : Mass-Expt]</font></div><div><font face="Courier New"> [time-expt : Time-Expt]</font></div><div><font face="Courier New"> [charge-expt : Charge-Expt]</font></div><div><font face="Courier New"> [temperature-expt : Temp-Expt])</font></div><div><font face="Courier New"> )</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(define (dimension--kws #:length^ [length-expt 0]</font></div><div><font face="Courier New"> #:mass^ [mass-expt 0]</font></div><div><font face="Courier New"> #:time^ [time-expt 0]</font></div><div><font face="Courier New"> #:charge^ [charge-expt 0]</font></div><div><font face="Courier New"> #:temperature^ [temp-expt 0])</font></div><div><font face="Courier New"> (dimension length-expt mass-expt time-expt charge-expt temp-expt))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">;; I want to be able to do something that would do the same thing as this: (it doesn't have to be this easy)</font></div><div><font face="Courier New">(define-type (Dimmension--kws #:length^ Length-Expt</font></div><div><font face="Courier New"> #:mass^ Mass-Expt</font></div><div><font face="Courier New"> #:time^ Time-Expt</font></div><div><font face="Courier New"> #:charge^ Charge-Expt</font></div><div><font face="Courier New"> #:temperature^ Temp-Expt)</font></div><div><font face="Courier New"> (dimension Length-Expt Mass-Expt Time-Expt Charge-Expt Temp-Expt))</font></div><div><br></div><div><br></div></body></html>