Fork me on GitHub
#cursive
<
2023-05-09
>
Matthew Davidson (kingmob)09:05:25

I think Cursive isn't recognizing deftype field access when the fields have a "-" in them. It doesn't complain about the fields without dashes, and the type hint doesn't help.

serioga10:05:21

I suppose this code won't work as well.

Matthew Davidson (kingmob)10:05:48

? The code works just fine

Matthew Davidson (kingmob)10:05:14

Without the type hint, I get a reflection warning, but that's it.

serioga11:05:11

I thought this is about such code in CLJ

(deftype HttpFile [-chunk-size])

(.-chunk-size (HttpFile. 1))
Execution error (IllegalArgumentException) at user.playground/eval28391 (playground.clj:230).
No matching field found: chunk_size for class user.playground.HttpFile

Matthew Davidson (kingmob)11:05:58

The field is called chunk-size, not -chunk-size.

Matthew Davidson (kingmob)11:05:41

. calls it as a method, .- retrieves the value of the field

serioga11:05:46

I see, Cursive understands only (.-chunk_size (HttpFile. 1))

cfleming21:05:40

That should work, Cursive does understand that syntax for class fields. Is this CLJ, CLJS or CLJC?

Matthew Davidson (kingmob)04:05:05

@U0567Q30W CLJ. It's aleph.http.core. There's two uses, and afaict, Cursive doesn't understand either, though it does understand the other fields in the HttpFile type. My guess was the hyphen was the cause, but ¯\(ツ)

cfleming02:05:12

I can’t reproduce this in the general case, I’ll check Aleph:

cfleming02:05:35

There’s definitely something odd there. Most of those are working, e.g. from HttpFile. However, .-chunk-size does not work, for some reason.

cfleming02:05:18

Ah, I think I have found the problem. .-chunk_size does work, because that’s what the actual field is called.

cfleming02:05:50

(dash replaced with underscore)

cfleming02:05:59

However, Clojure does accept the .-chunk-size format, it must do some magic there.

cfleming02:05:08

Ah, I see I didn’t read your first message closely enough, I thought you were saying that the .-field access method didn’t work, but plain dot access (`.field`) did. Either way, I’ll fix that.

Matthew Davidson (kingmob)07:05:24

> Ah, I see I didn’t read your first message closely enough, I thought you were saying that the .-field access method didn’t work, but plain dot access (`.field`) did. No, that was the other person. I think they were confused. But I was talking about dashes after the field start. Thanks for fix!