notjack
2021-8-3 08:16:23

There’s many different mechanisms for managing multiple implementations of an interface. Which one to use depends on your use cases. You say that you hope end users can choose between two implementations of some module: what benefit do you hope users will get from making that choice?


chansey97
2021-8-3 09:27:44

You are right. My previous use case was to hope users can switch between different SMT solvers, because different SMT solvers may have different features and limitations (e.g. for the same formula, some solvers may solve it, but others not). So I’d like to know some idiom about how to switch implementations in Racket. Anyway… this is no longer a problem for me. Sorry for wasting your time. Thanks all!


chansey97
2021-8-3 09:27:51

BTW I found an example in rosette (very racket flavor and seems what I want), I did not use it though. #lang rosette (require rosette/solver/smt/cvc4) (current-solver (cvc4 #:path "/path/to/cvc4")) (define-symbolic x (bitvector 5)) (solve (assert (bvsge x (bv 4 5))))


tjeerd
2021-8-3 14:01:02

@tjeerd has joined the channel


artemchernyak
2021-8-3 15:24:56

Are there tangible differences between Racket ports and streams in languages like Python, Java, etc.? They seem to serve the same purpose, but I want to understand the distinction a bit deeper.


soegaard2
2021-8-3 15:30:32

I don’t know much about Python, but normally I’d compare Racket ports to Python file objects:

https://docs.python.org/3/glossary.html#term-file-object


soegaard2
2021-8-3 15:31:56

Racket ports are flexible though, so Racket ports can be used for both files and network connections.


artemchernyak
2021-8-3 15:40:19

Yeah, that’s what I was referring from the python world.

I thinks streams is just a more general term.

> File objects are also called file-like objects or streams.


artemchernyak
2021-8-3 15:43:05

Interesting. I know Java, C and a few other refer to streams when using both network connections and files. Curious why the name change with Racket and Scheme.


soegaard2
2021-8-3 15:46:08

I think, file stream is sometimes used in language that have both file streams and “functional” streams (i.e. where a stream is a data structure that can produce a series of elements, potentially an infinite series).


soegaard2
2021-8-3 15:46:42

If such streams are not present in the language, then people just say stream as a shorthand for file stream.


artemchernyak
2021-8-3 15:48:17

That’s a good point. They are kept as more distinct concepts where as ports seem like just that, a port in every case.


ben.knoble
2021-8-3 16:24:59

I think one of the original terms is stream or I/O stream, based on man stdio from the BSD manuals The standard I/O library provides a simple and efficient buffered stream I/O interface. Input and output is mapped into logical data streams and the physical I/O characteristics are concealed. The functions and macros are listed below; more information is available from the individual man pages. A stream is associated with an external file (which may be a physical device) by opening a file, which may involve creating a new file. Creating an existing file causes its former contents to be discarded. If a file can support positioning requests (such as a disk file, as opposed to a terminal) then a file position indicator associated with the stream is positioned at the start of the file (byte zero), unless the file is opened with append mode. If append mode is used, the position indicator will be placed at the end-of-file. The position indicator is maintained by subsequent reads, writes and positioning requests. All input occurs as if the characters were read by successive calls to the fgetc(3) function; all output takes place as if all characters were written by successive calls to the fputc(3) function.


notjack
2021-8-3 17:52:43

Racket ports are generally much better at enabling concurrent usage than streams in java and most other languages