parlortricks
2020-9-21 08:43:40

@parlortricks has joined the channel


joshibharathiramana
2020-9-21 16:59:42

@joshibharathiramana has joined the channel


wmblackerby
2020-9-22 01:42:06

@wmblackerby has joined the channel


dyllongagnier
2020-9-22 02:50:30

One trick I do is to have a macro which lets me turn off these contacts for my own code most of the time but turn them on when I’m trying to find the source of a bug. You could probably even generalize this to to allow for two contacts per function, one for debug and one that should always be active. I know Matthias has said you shouldn’t turn them off, but I find it useful to have flexibility in checking that my binary tree structure is correct at every step when debugging that binary tree, but that is far too expensive and of little value once it has been thoroughly tested.


kellysmith12.21
2020-9-22 03:30:00

Is there a relatively simple way to get a non-blocking character source from a port?


dyllongagnier
2020-9-22 03:36:41

Also, I have tried using universals but found them to be lackluster since the match has to be pretty much exact. I understand why that is, it can just be surprising coming from a statically typed language.


shu--hung
2020-9-22 03:53:42

Though operationally it is surprising, in languages like Haskell it will be exact (for type variables not qualified by class constraints)


dyllongagnier
2020-9-22 04:23:55

Is there a reason why you don’t want to use a thread? They are relatively lightweight since they do not map to an OS thread. They do take up memory, but not nearly as much as an OS thread.


kellysmith12.21
2020-9-22 04:25:17

My apologies, I just need a non-blocking character source. I assumed that it would have something to do with ports. I’m new to parallelism/asynchronous programming.


buchireddy.s
2020-9-22 04:28:07

@buchireddy.s has joined the channel


dyllongagnier
2020-9-22 04:34:55

There are nonblocking variants in the form of {op}-avail but I would recommend using threads if you just want to avoid blocking UI updates or some other critical logic.


kellysmith12.21
2020-9-22 04:35:42

Ok, then I’ll look into threads. Thank-you!


dyllongagnier
2020-9-22 04:41:14

Not sure how practical this is in your case but I would often just rent a VM from a cloud provider when I needed to do really heavyweight stuff in terms of memory/cores. It’s expensive if it needs to run continuously, but it is great if you just need it for a day or two. Also, you can save even more with this approach if you use a spot instance.


dyllongagnier
2020-9-22 04:46:15

On another note, it can actually be a bad idea to try and share even immutable data between independent threads and can be better to give each thread/process its own copy. Modern CPUs extremely complicated and will sometimes predict that a thread will write to memory despite that memory being immutable. In that case, you may see a performance hit due to cache coherance overhead. The only surefire way to avoid issues like this is to keep threads as isolated as possible.