flix icon indicating copy to clipboard operation
flix copied to clipboard

feat: annotate methods in `java.lang.System`

Open jaschdoc opened this issue 11 months ago • 11 comments

I think we should discuss some of these annotations more.

I understand Env as read-only from system properties, but Sys as writing. That means that if you have Sys you also have Env when it interacts with the system properties. Maybe this is not entirely correct.

Note, that the effects file is not sorted alphabetically. I will do that in a subsequent PR. Right now they appear in the order mentioned in the java doc.

Closes https://github.com/flix/flix/issues/9512

jaschdoc avatar Jan 05 '25 13:01 jaschdoc

I think this also calls for the discussion in https://github.com/flix/flix/issues/9499

jaschdoc avatar Jan 05 '25 13:01 jaschdoc

CI failures

magnus-madsen avatar Jan 05 '25 19:01 magnus-madsen

I understand Env as read-only from system properties, but Sys as writing.

I think to a first approximation that is OK. But env is not just properties, it could also be e.g. number of CPUs etc. (which is not an environmental variable).

That means that if you have Sys you also have Env when it interacts with the system properties. Maybe this is not entirely correct.

Yes, but there is no subeffecting. So you have to put both.

Note, that the effects file is not sorted alphabetically. I will do that in a subsequent PR. Right now they appear in the order mentioned in the java doc.

OK

magnus-madsen avatar Jan 05 '25 19:01 magnus-madsen

In the case of Runtime and System it might be worth annotating every method explicitly no matter what we decide to do in general. The reasoning being that these classes are very special and we don't want to miss anything.

magnus-madsen avatar Jan 05 '25 19:01 magnus-madsen

I think to a first approximation that is OK. But env is not just properties, it could also be e.g. number of CPUs etc. (which is not an environmental variable).

Ah yeah apologies for the confusion. The java documentation treats env vars as system properties along with other things.

jaschdoc avatar Jan 08 '25 14:01 jaschdoc

@mlutze @JonathanStarup Do we morally agree with these breakages?

magnus-madsen avatar Jun 17 '25 15:06 magnus-madsen

@mlutze @JonathanStarup Do we morally agree with these breakages?

It has my blessing.

mlutze avatar Jun 17 '25 15:06 mlutze

I am ambivalent about whether asking for platform newline or CPUs should really be a primitive effect. Hmm. But I suppose it HAS to be some effect.

magnus-madsen avatar Jun 17 '25 15:06 magnus-madsen

I am ambivalent about whether asking for platform newline or CPUs should really be a primitive effect. Hmm. But I suppose it HAS to be some effect.

I am not ambivalent. It is definitely an effect in my book.

mlutze avatar Jun 17 '25 17:06 mlutze

Nice if pure code was somewhat immue to "it works on my machine"

JonathanStarup avatar Jun 17 '25 20:06 JonathanStarup

I understand Env as read-only from system properties, but Sys as writing. That means that if you have Sys you also have Env when it interacts with the system properties.

Not sure this is Env

What does this even do?

Does not actually seem like Env at all tbf

Maybe its impractical, but it feels like these annotations should have "doc comments" on them

JonathanStarup avatar Jun 18 '25 09:06 JonathanStarup

Should we do another review of this and see if we can merge it?

jaschdoc avatar Sep 15 '25 09:09 jaschdoc

Maybe its impractical, but it feels like these annotations should have "doc comments" on them

We could map each function to an object with the shape { "effects": effect-str, "comment": str }

jaschdoc avatar Sep 15 '25 09:09 jaschdoc

No longer relevant.

magnus-madsen avatar Oct 04 '25 11:10 magnus-madsen