2

What does this warning mean? Is there any way we can avoid this warning? I tried to understand the message from the compiler code here but I couldn't.

frege> native sysin "java.lang.System.in" :: InputStream
native function sysin :: InputStream

3: note that the java expression
java.lang.System.in is supposed to be
constant.

I also tried the code below but got the same warning:

frege> native sysin "java.lang.System.in" :: MutableIO InputStream
native function sysin :: MutableIO InputStream

3: note that the java expression
java.lang.System.in is supposed to be
constant.
Marimuthu Madasamy
  • 13,126
  • 4
  • 30
  • 52

1 Answers1

2

It is simply a reminder that the java value could change over the lifetime of the program, but you, the programmer, assume its de-facto immutability by using this notation.

In fact, one can re-assign those fields on the Java level. In this case, Frege code could still return the previous value that it may have cached somewhere. Or it could violate referential transparency, so that sysin does not mean the same everywhere.

If you need to make sure that you get the current value of a mutable field, you need to declare it as IO or ST.

This feature is thought as a relief for the cases when we know that a value won't change, so that we can write:

dosomething sysin

instead of

sysin >>= dosomething

This is used, for example, in frege.java.IO, where stdin, stdout and stderr are defined that way.

The warning cannot be supressed, except by compiling with nowarn. This feature should simply not be used unless you're absolutly sure you're doing the right thing, that is, when a proper IO or ST action would produce the very same value all the time.

Ingo
  • 36,037
  • 5
  • 53
  • 100