IRC channel logs
2024-08-20.log
back to list of logs
<old>is this normal behavior? (inexact->exact 0.2) => 3602879701896397/18014398509481984 ; instead of just 1/5 <Arsen>>>> 18014398509481984%3602879701896397 <Arsen>can 0.2 be represented inside computers via floats even <old>I was thinking that ->exact was going to reduce the fraction to its minimum <old>weary-traveler: can you be more specific? <weary-traveler>old: i have an external process $foo which when run results in a file $bar being accessed. i'd like to run the process in a manner s.t. $foo sees a modified version of $bar, but the actual file $bar (to other processes) isn't modified <weary-traveler>$foo is currently being run using with-output-to-string from (ice-9 ports) <old>so you want a "fake" file for a certain process <old>have you considered Linux FUSE? <old>You can basically mount a filesytem in userspace and implement callback in userspace for syscalls access to this filesystem <old>Thus you could do something like this in theory: (define (open file pid) (if (and (string=? file "bar") (= pid foo-pid)) (%open "fake-bar") (%open file)) <weary-traveler>old: i'm confused. are you suggesting something that's done external to guile program invoking $foo ? <old>I don't recall how does FUSE work. But I believe you have a monitor process <old>that takes decision on what to do on every filesystem syscalls related of the mounted userspace filesystem <old>thus different process could see different content for the same file <old>or maybe you want something simpler in Guile? <old>You could do it by using LD_PRELOAD with a shared lib that override open(2), openat(2), etc. <old>then implement your logic there in C <old>"pyfakefs will not work with Python libraries that use C libraries to access the file system. This is because pyfakefs cannot patch the underlying C libraries' file access functions--the C libraries will always access the real file system. " <old>If you goal is to only handle Guile access, I guess you could redefine core bindings? <weary-traveler>mwette: yes, if $foo was written in a way that access to $bar was explicitly provided via a port, that would work <old>how is $bar provided to $foo? <old>inherit filedescriptor with fork? Filepath in environment? Command line argument? <mwette>regarding Arsen's comment it seems 0.2 is not not 1/5 when double: C code `double d; sscanf("0.2", "%lf", &d); printf("%a\n", d);' generates `0x1.999999999999ap-3'