Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
efm has joined #racket
Ven`` has joined #racket
lockywolf has joined #racket
iyzsong has quit [Ping timeout: 240 seconds]
<wild_buffalo>
Is there a shorthand define for case-lambda?
<jcowan>
A case-define would be easy to write.
<wild_buffalo>
jcowan: what do you mean? I'm new with Racket. Is that a pre-built form or are you suggesting I write one that has that functionality?
real-grue has joined #racket
true-grue has quit [Read error: Connection reset by peer]
<jcowan>
The latter (with help, of course; writing macros is a serious endeavor)
<wild_buffalo>
Ah OK. Well I don't particularly need that functionality, using case-lambda is fine, it was more of a curiosity.
<jcowan>
Until you feel comfortable with run-time-level programming, I wouldn't advise adding new syntax.
YuGiOhJCJ has quit [Ping timeout: 240 seconds]
<wild_buffalo>
jcowan: agreed. I was mostly just curious if there was a shorthand for it.
<jcowan>
It's just that in the Lisp languages we *can* add new syntax easily compared to cracking open a C compiler, say, and adding new syntax there.
cartwright has quit [Ping timeout: 240 seconds]
efm has quit [Quit: Konversation terminated!]
<MustardCheese>
Isn't there define/match ?
YuGiOhJCJ has joined #racket
cartwright has joined #racket
<bremner>
yes. but I believe case-lambda is more general
<bremner>
define/match has a fixed set of arguments that match clauses are tried against, right?
<MustardCheese>
This is true. I've just been experimenting with it
<MustardCheese>
Match asks you to define the arguments before you can use them, while case-lambda happily lets you declare the arguments in the pattern
Sgeo__ has quit [Ping timeout: 264 seconds]
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
sarna has joined #racket
vraid has quit [Quit: Leaving]
pilne has joined #racket
orivej has quit [Ping timeout: 256 seconds]
Sgeo has joined #racket
efm has joined #racket
efm has quit [Ping timeout: 240 seconds]
orivej has joined #racket
acarrico has quit [Quit: Leaving.]
orivej_ has joined #racket
orivej has quit [Read error: Connection reset by peer]
real-grue has quit [Quit: Leaving]
<samth>
lavaflow: I think the code for fixnums in sexp->fasl is probably the right thing to use
<samth>
I doubt the dispatch overhead there will be that significant, but you could measure
<samth>
wild_buffalo: most of the time, just using optional and keyword arguments is enough
<samth>
hagenek: that function will take time proportional to the lentgth of the vector
<hagenek>
yeah I smelled trouble when I saw that I called twice..
<samth>
probably better to use a hash in most cases
<hagenek>
Is it possible to fix with an accumulator? To make it tail-recursive
<hagenek>
How would I do it with using a hash?
<bremner>
immutable hashes work fine as accumulators
<bremner>
(or mutable ones, but not needed usually)
<bremner>
think of it like using a list as an accumulator, and replacing cons with hash-set
<jcowan>
samth: No, not safely, because if f is global, there is no guarantee that f will have the same value at the time it is applied as at the point of definition.
<samth>
jcowan: fortunately in racket this is easy to check
<jcowan>
Providing define-immutable would also work.
<jcowan>
(How do you check?)
aidalgol has quit [Read error: Connection reset by peer]
<samth>
jcowan: all `set!` to a module-top-level variable must be within that module
<jcowan>
True. So it's the REPL that creates the problem, as is often the case.
<samth>
in this case, "optimizing" the top-level is a non-problem
* jcowan
nods
orivej_ has quit [Quit: No Ping reply in 180 seconds.]
orivej has joined #racket
aidalgol has joined #racket
MustardCheese|2 has joined #racket
sagax has quit [Read error: Connection reset by peer]
efm has joined #racket
sagax has joined #racket
wingsorc has joined #racket
narimiran has quit [Ping timeout: 256 seconds]
nullcone has joined #racket
catonano has joined #racket
true-grue has joined #racket
catonano has quit [Quit: catonano]
<setthemfree[m]>
Hi everyone. I'm a bit divided between using let* and define inside a function definition; define somehow make the code look procedural while let* more functional; but are there any recommendations on when to use each form within functions?
<aeth>
I just always use internal lets/etc. because it makes the scope explicit.
<samth>
setthemfree[m]: the usual racket style is to use internal `define`
<setthemfree[m]>
samth: I remember reading it in somewhere in the manual; however it seems to me that there's some implicit difference in how define vs let communicate their purposes to the person reading the code later
<samth>
setthemfree[m]: that isn't how I read them
<samth>
but of course everyone has their own style preferences
<setthemfree[m]>
samth: I'm curious what you think about the following example
<setthemfree[m]>
let's say there is a function that does a HTTP request for some API
<setthemfree[m]>
inside the function there are things in the beginning that are `define`d, for instance the query string is constructed from the function arguments
<setthemfree[m]>
then it proceeds with the HTTP request and starts to exctract some information from the response, perhaps by looking into the JSON structure
<setthemfree[m]>
would you use defines down the road when you are processing the response data? like `(define response ...) (define relevant1 (hash-ref ...)) (define relevant2 (hash-ref ...))`?
<jcowan>
setthemfree[m]: internal define is not quite let*, it is letrec*.
<samth>
setthemfree[m]: yes, usually, if I was binding them
<setthemfree[m]>
samth: okay, thanks!
<setthemfree[m]>
jcowan: thanks for clarifying.
<setthemfree[m]>
I guess maybe my problem is not the `defines` themselves but that I'm writing procedural code:)
<setthemfree[m]>
And I have the terminology mixed up
<setthemfree[m]>
Sorry
Naptra has quit [Remote host closed the connection]
rmnull has joined #racket
rmnull has quit [Client Quit]
efm has quit [Ping timeout: 256 seconds]
efm has joined #racket
Sgeo_ has joined #racket
lavaflow has quit [Ping timeout: 240 seconds]
lavaflow has joined #racket
jboy has quit [Quit: bye]
Sgeo has quit [Ping timeout: 256 seconds]
hagenek has quit [Remote host closed the connection]
jboy has joined #racket
pilne has joined #racket
urbanslug has joined #racket
wingsorc has quit [Quit: Leaving]
urbanslug has quit [Ping timeout: 265 seconds]
urbanslug has joined #racket
MustardCheese|2 has quit [Quit: Quit]
urbanslug has quit [Read error: Connection reset by peer]
true-grue has quit [Read error: Connection reset by peer]