mark.warren
2019-7-23 09:04:58

Hello, can someone point me at an appropriate function for random access in a very large file?


soegaard2
2019-7-23 11:42:57

@mark.warren Use file-position.


mark.warren
2019-7-23 11:43:49

@soegaard2 Thanks, that looks just what I need.


mark.warren
2019-7-23 13:45:45

In general do people consider using block a code smell or is it ok?


greg
2019-7-23 14:28:55

@mark.warren Do you mean the block provided by racket/block (as opposed to scribble/text)? If so, I don’t recall seeing that in modern Racket code. I think it’s from a time long long ago when Racket was less flexible about mixing expressions and definitions. AFAICT it’s N/A today. At any rate, it seems to be a no-op in the example provide in the docs: https://docs.racket-lang.org/reference/block.html In that ex, you could replace block with begin. Or more simply lift everything up to the body of f. ¯_(ツ)_/¯


greg
2019-7-23 14:29:21

How/why did you think to use/need block? What was your example case?


mark.warren
2019-7-23 14:31:09

@greg Yes I did mean from racket/block, I wanted to do multiple things in an else part of an if and I found block, but I would rather do it in a rackety way.


greg
2019-7-23 14:31:52

Cool. So, you can just use begin.


greg
2019-7-23 14:32:27

Having said that, the even more Rackety thing to do is mostly avoid if and instead prefer cond.


greg
2019-7-23 14:34:10

In fact one of my cues to switch an if to a cond, is when I would need to add a begin to the if. I think, “it’s getting ‘complicated’ enough, maybe should be a cond.”


mark.warren
2019-7-23 14:34:32

@greg That’s very helpful, thanks for the pointers.


greg
2019-7-23 14:35:04

There’s a Racket style guide, have you seen? If not, I can find the link. It talks about things like if vs. cond.


mark.warren
2019-7-23 14:35:39

Ah ok, I’ve read some of it, but not all yet, perhaps I should go back to it.


greg
2019-7-23 14:36:49

Most of the “Goofus and Gallant” suggestions are in this section https://docs.racket-lang.org/style/Choosing_the_Right_Construct.html


greg
2019-7-23 14:37:24

greg
2019-7-23 14:38:14

wonders if anyone else remembers Goofus and Gallant from Highlights magazine :simple_smile:


mark.warren
2019-7-23 14:39:21

Cool, I’ll check it out.