Hello, can someone point me at an appropriate function for random access in a very large file?
@mark.warren Use file-position.
@soegaard2 Thanks, that looks just what I need.
In general do people consider using block a code smell or is it ok?
@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. ¯_(ツ)_/¯
How/why did you think to use/need block? What was your example case?
@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.
Cool. So, you can just use begin.
Having said that, the even more Rackety thing to do is mostly avoid if and instead prefer cond.
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.”
@greg That’s very helpful, thanks for the pointers.
There’s a Racket style guide, have you seen? If not, I can find the link. It talks about things like if vs. cond.
Ah ok, I’ve read some of it, but not all yet, perhaps I should go back to it.
Most of the “Goofus and Gallant” suggestions are in this section https://docs.racket-lang.org/style/Choosing_the_Right_Construct.html
e.g. the cond vs. if thing we were just talking about: https://docs.racket-lang.org/style/Choosing_the_Right_Construct.html#%28part._.Conditionals%29
wonders if anyone else remembers Goofus and Gallant from Highlights magazine :simple_smile:
Cool, I’ll check it out.