
I noticed when I tried something like this that period doesn’t normalize, so you can have a period with 120 seconds

Yep, it seems to work well now. Thanks again!

@jaz Thanks for getting back to me. I actually was able to get things going for my needs using Racket. It was a bit weird, wrapping a lot of (minute+ ...)
around each other, but I got what I needed. What was I doing? Well, I’m a pilot, I do a lot of flying for Civil Air Patrol, I have web pages that are generated by Racket to show my flying status, I had to send something like that to the FAA the other day to get permission to fly a fundraiser for the local YWCA auction (they auctioned off a flight with me which was my donation). Then lately I started towing gliders for CAP, this afternoon I’m getting a logbook endorsement from my glider instructor from 2010, so I went back to my glider logbook, and found I had to add up lots of values in hours and minutes. I already put the glider logbook entries into PostgreSQL, which is where I noticed PostgreSQL’s Interval type was really nice, and that made me wonder about Racket, because I have to add my glider stats to my general stats web page (generated by Racket).

Update on the project to host an archive of the Racket Slack: I have been directed to some privacy issues with the current proof-of-concept. Until these issues are resolved, I have made the repository private and taken down the site.
If you have a copy of the archive files or site, I must ask that you refrain from using them publicly until those impacted have a chance to decide what to do.
If you wish to participate in the discussion, please join the Racket Slack [1,2] and use the channel #slack-archive You can also reach out privately to me and Sam Tobin-Hochstadt, as we have become the organizers behind the archive. So that I remain accountable and transparent, I would prefer any private communication with me to include Sam.
The crux of the issue is data privacy: What data is in the archive? What are we doing with private data? How are we using data from the archive? How are we going to explain that to people? What will opt-in/opt-out look like? &c. More details in Slack.
[1] https://racket.slack.com/ [2] https://racket-slack.herokuapp.com/

I’m having a serious brain fart ATM. What’s the racket equiv. of CL’s symbol-function
and symbol-value
?

There isn’t such a function.

But in general you don’t want to do that.

You can use eval
in some cases for that sort of thing, but my suggestion would be to only use eval
if you have unknown Racket code that you need to run (as in DrRacket or a chat bot etc).

(un-sandboxed) Eval is a no-no. But symbol-function (et al) are used all the time in CL. There’s shouldn’t be a reason not to in Scheme/Racket.

You may be looking for namespace-variable-value
. But beware that the default mode (unless you provide #f
as the second argument) is not all that different from eval
, which lets it report values for identifiers that have contracts.

As an example of what I’m (poorly) attempting to translate from CL -> Racket:
• Load a file off disk (e.g. a CSV) • Filename -> structure name • Column names -> structure fields So, given:
# employees.csv
name,age,salary
You’d end up with (pseudo-code) being executed at runtime:
(eval `(struct ,(string->symbol "employees") [,@(map string->symbol column-names)] #:prefab))
Use of eval here just for purposes of example, but may be necessary?
Subsequently, the return value of the function that does this would be (in CL): (symbol-function 'employees)
, since struct
doesn’t actually return anything.
I hope this provides enough context to describe what I’m going for.

I think in this case make-struct-type
is what you want to use.

Which would let you write that snippet quite directly without eval
or anything like it.

Ah, awesome! I knew it’d be simple. :slightly_smiling_face:

@gorniakowski has joined the channel

does it require a macro to create a syntax form like, for example, (make-ordering blah #:dependent)
where #:dependent
is just a flag and not a keyword argument?

Yes, if you want a flag for a function the usual way is an argument that takes a boolean

Back in the day … case-lambda was used to handle optional arguments.

Here is an example of how to do it using syntax-parse https://github.com/tgbugs/rrid-metadata/blob/d64417ca54b4d0b305d90d5989365f0407731e71/rrid/utils.rkt#L62-L81

(~optional (~seq #:keys (~bind [show-keys #'#t])) #:defaults ([show-keys #'#f])

Yeah @samth, since periods can include fields like months
and years
, which don’t have an exact cash value, you can’t normalize them in general. (Well, not unless you stipulate a meaning of those units in terms of nanoseconds, or whatnot.)

@jaz have you thought about adding a duration type to Gregor?

wow, so many people have stumbled on match
expansion issues in Typed Racket such that it has a label now https://github.com/racket/typed-racket/labels/match It’s definitely one of the most visible macros that Type Racket has to deal with

Also a way to combine a date
and a time
into a datetime