samth
2021-6-9 12:13:23

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


sorawee
2021-6-9 13:07:19

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


gknauth
2021-6-9 13:31:07

@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).


ben.knoble
2021-6-9 14:09:07

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/


massung
2021-6-9 15:15:32

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


samth
2021-6-9 15:18:51

There isn’t such a function.


samth
2021-6-9 15:19:19

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


samth
2021-6-9 15:20:32

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).


massung
2021-6-9 15:21:07

(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.


mflatt
2021-6-9 15:26:27

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.


massung
2021-6-9 15:43:08

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.


samth
2021-6-9 15:44:58

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


samth
2021-6-9 15:45:27

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


massung
2021-6-9 15:45:59

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


gorniakowski
2021-6-9 16:49:28

@gorniakowski has joined the channel


hazel
2021-6-9 18:20:21

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?


samth
2021-6-9 18:21:17

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


soegaard2
2021-6-9 18:22:37

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


tgbugs
2021-6-9 18:24:24

tgbugs
2021-6-9 18:24:51

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


jaz
2021-6-9 21:23:16

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.)


samth
2021-6-10 02:14:54

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


shu--hung
2021-6-10 03:26:35

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


joel
2021-6-10 03:44:35

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