samth changed the topic of #racket to: Racket v7.6 has been released: https://blog.racket-lang.org/2020/02/racket-v7-6.html -- Racket -- https://racket-lang.org -- https://pkgs.racket-lang.org -- Paste at http://pasterack.org
true-grue has quit [Read error: Connection reset by peer]
badkins has joined #racket
wingsorc has quit [Quit: Leaving]
iyzsong has joined #racket
KDr2 has quit [Remote host closed the connection]
KDr2 has joined #racket
FreeFull has quit [Quit: rebooting]
emacsomancer has quit [Read error: Connection reset by peer]
emacsoma1 has joined #racket
badkins has quit [Remote host closed the connection]
efm has quit [Quit: Konversation terminated!]
efm has joined #racket
iyzsong has quit [Quit: ZNC 1.7.1 - https://znc.in]
iyzsong has joined #racket
KDr21 has joined #racket
KDr2 has quit [Ping timeout: 256 seconds]
libertyprime has joined #racket
Sgeo has quit [Read error: Connection reset by peer]
libertyprime has quit [Read error: Connection reset by peer]
Sgeo has joined #racket
notzmv has quit [Ping timeout: 240 seconds]
libertyprime has joined #racket
selimcan has quit [Ping timeout: 265 seconds]
evdubs has quit [Remote host closed the connection]
orivej has quit [Ping timeout: 258 seconds]
evdubs has joined #racket
dddddd has quit [Remote host closed the connection]
_whitelogger has joined #racket
lavaflow has quit [Ping timeout: 264 seconds]
germ13 has joined #racket
FreeFull has joined #racket
pilne has quit [Quit: Excess flood. Did someone see an ark float by?]
lavaflow has joined #racket
libertyprime has quit [Ping timeout: 256 seconds]
libertyprime has joined #racket
_whitelogger has joined #racket
narimiran has joined #racket
ephemera_ has quit [Ping timeout: 258 seconds]
ephemera_ has joined #racket
_whitelogger has joined #racket
orivej has joined #racket
germ13 has quit [Ping timeout: 240 seconds]
urbanslug has joined #racket
YuGiOhJCJ has joined #racket
catonano has joined #racket
urbanslug has quit [Ping timeout: 256 seconds]
<setthemfree[m]> I have a question about code reuse in functional paradigm; I have a pattern that repeats - the program presents a question, then a value, then awaits an answer, then computes if the answer is correct, then signals the result.
<setthemfree[m]> I'm trying to make an abstraction of this pattern
<setthemfree[m]> And to be able to define variations of the "presents a value" and "computes if answer is correct" parts
<setthemfree[m]> I have tried using a simple function for that
<setthemfree[m]> and a macro
<setthemfree[m]> Here's my attempt with functions https://dpaste.org/KhY3#L1
<setthemfree[m]> The thing I don't like is the repetition of arguments to the two lambdas
<setthemfree[m]> Generalizing the question though - for something that would be done with, say, a base class in some OOP paradigm, where the base class would be inherited and one or two methods of a class would be redefined, what is the standard approach in Scheme?
<setthemfree[m]> My attempt with a macro: https://dpaste.org/PQ6v
<setthemfree[m]> The part I'm not happy with is the syntax-parametrize one
<setthemfree[m]> i.e., that the macro is sort of defining a binding inside an expression provided
<setthemfree[m]> *inside a provided expression
<setthemfree[m]> (comparing the two, the function version still looks cleaner to me)
sarna has joined #racket
<sarna> hello, does racket have something like a condition/restart system? like common lisp does
sarna has quit [Remote host closed the connection]
sarna has joined #racket
sarna has quit [Remote host closed the connection]
laduke has quit [Ping timeout: 256 seconds]
laduke has joined #racket
urbanslug has joined #racket
badkins has joined #racket
srji has quit [Quit: Lost terminal]
badkins has quit [Ping timeout: 264 seconds]
srji has joined #racket
catonano has quit [Read error: Connection reset by peer]
catonano has joined #racket
badkins has joined #racket
Guest66258 has joined #racket
badkins has quit [Remote host closed the connection]
urbanslug has quit [Ping timeout: 264 seconds]
orivej has quit [Ping timeout: 250 seconds]
urbanslug has joined #racket
libertyprime has quit [Read error: No route to host]
libertyprime has joined #racket
catonano has quit [Quit: catonano]
catonano has joined #racket
urbanslug has quit [Ping timeout: 240 seconds]
urbanslug has joined #racket
urbanslug has quit [Ping timeout: 256 seconds]
dddddd has joined #racket
urbanslug has joined #racket
urbanslug has quit [Ping timeout: 256 seconds]
urbanslug has joined #racket
<greghendershott> setthemfree[m]: Something like `make-test`, I would keep that as a function.
<greghendershott> Something like test-word and test-sentence, I would also define them as a function. But. I might _also_ make super simple macros that expand into calling them.
<greghendershott> That is a common technique: Write some function. It uses lambdas. Maybe you find that a bit awkward or ugly. So you write a macro to "sugar away the macros".
<greghendershott> derp. "sugar away the lambdas"
<greghendershott> For instance,sometimes people write a "call-with-xxx" function that takes a procedure as an argument.
<greghendershott> Then also write a "with-xxx" macro as an "alternative front end" to the call-with procedure flavor.
urbanslug has quit [Ping timeout: 252 seconds]
urbanslug has joined #racket
<setthemfree[m]> Aha, that's interesting!
iyzsong has quit [Ping timeout: 272 seconds]
urbanslug has quit [Ping timeout: 256 seconds]
urbanslug has joined #racket
<setthemfree[m]> thanks!
<greghendershott> In general I'd suggest writing macros to do things -- or pieces of things -- that you can't do with a function.
<greghendershott> That usually makes the macros simpler, which is easier to develop and debug.
<greghendershott> Also the macros won't expand into so much code, which sometimes matters.
<greghendershott> As to what only macros can do, there's probably a better explanation, but here's one I wrote awhile back, summarizing other people's explanations: https://www.greghendershott.com/2014/10/why-macros.html
<greghendershott> setthemfree[m]: ^
<setthemfree[m]> greghendershott: thanks a lot, that's very useful
wingsorc has joined #racket
<greghendershott> To be clear I'm not saying macros are bad. Racket has awesome facilities for macros. Definitely experiment and have fun, to learn! But maybe "for real" be a bit more cautious/deliberate, and use the "only if necessary" guideline.
urbanslug has quit [Ping timeout: 265 seconds]
nullcone has quit [Quit: Connection closed for inactivity]
<notnotdan> greghendershott: good points in the blog post
<notnotdan> one simple example that was taught to me: if you define a macro instead of a function, you should remember that you cannot e.g. map over a list using it (without doing some expansion)
<notnotdan> functions are better supported in that regard
libertyprime has quit [Quit: Lost terminal]
urbanslug has joined #racket
urbanslug has quit [Ping timeout: 240 seconds]
johncob_ has quit [Read error: Connection reset by peer]
johncob_ has joined #racket
Naptra has joined #racket
libertyprime has joined #racket
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
<greghendershott> setthemfree[m]: Your more-general question was about default and overridden behavior.
<setthemfree[m]> I guess so:2
<greghendershott> So, there is `racket/class`, and `racket/generic`.
<setthemfree[m]> *:)
<greghendershott> Also, it is common to have Racket parameters with default values.
<greghendershott> The values can of course include functions.
cartwright has quit [Read error: Connection reset by peer]
<greghendershott> The `parameterize` form is a way to supply new values in some dynamic extent.
<greghendershott> And so that is one common way to have default behavior that can be overridden -- and without making every function take umpteen extra/optional parameters.
cartwright has joined #racket
<greghendershott> So things like current-output-port, current-print, current-eval, and on and on.
<greghendershott> If I'm writing a library that doesn't otherwise really need to be OOP or even use generics, I'd define parameters instead.
<greghendershott> That's really not about is-a-kind-of customization, of course. But sometimes that's not really what's needed.
<greghendershott> Oh also. Racket `struct`s can inherit from other `struct`s.
<greghendershott> In some cases you can do the is-a-kind-of test using the struct predicate.
catonano has quit [Quit: catonano]
catonano has joined #racket
<greghendershott> there's no OOP magic where a "this" argument is automatically supplied. it's plain old functions and predicates.
<greghendershott> But that is not necessarily bad. :) Up to you.
catonano has quit [Read error: Connection reset by peer]
<setthemfree[m]> Thank you, that's a lot to explore more in-depth!
pilne has joined #racket
germ13 has joined #racket
catonano has joined #racket
catonano has quit [Remote host closed the connection]
<srandon111> guys ii am having an hard time understanding this twoer of hanoi thing from SICP... https://www.youtube.com/watch?list=PLZHQObOWTQDMRtm8h9bG9P06WINNoBnCR&v=2SUvWfNJSsM can somebody help me? where is the rule about you can move only a single disk at a time in? and how does the system know that he cannot put laarger disks above smaller disks?
ArthurStrong has joined #racket
germ13 has quit [Ping timeout: 240 seconds]
germ13 has joined #racket
true-grue has joined #racket
orivej has joined #racket
_whitelogger has joined #racket
acarrico has joined #racket
lavaflow has quit [Ping timeout: 256 seconds]
lavaflow has joined #racket
germ13 has quit [Ping timeout: 252 seconds]
orivej has quit [Ping timeout: 256 seconds]
germ13 has joined #racket
sauvin has quit [Read error: Connection reset by peer]
Guest66258 is now known as notzmv
lavaflow has quit [Ping timeout: 252 seconds]
<srandon111> guys is there a way in drracket to send a block of code to the interpreter without having to re-run the entire program?
sauvin has joined #racket
libertyprime has quit [Read error: Connection reset by peer]
<jcowan> Since "in Racketland they do things differently", I am curious if anyone has found a use for first-class parameters, as opposed to those that stay bound to a global variable and therefore emulate CL dynamic variables
<jcowan> If I asked this question here before, nm
lavaflow has joined #racket
dddddd has quit [Ping timeout: 256 seconds]
davidl has quit [Ping timeout: 264 seconds]
nullcone has quit [Quit: Connection closed for inactivity]
<samth> srandon111: not really
<samth> jcowan: having parameters be first-class supports a variety of things, such as treating them like functions, putting contracts on them, managing collections of them (called parameterizations in racket)
<jcowan> What are the applications of parameterizations?
<samth> re-applying all the parameters from one place to another
orivej has joined #racket
efm has quit [Ping timeout: 258 seconds]
<samth> jcowan: also, parameters aren't built-in in racket -- they're defined using continuation marks
badkins has joined #racket
<jcowan> I don't see that it matters how they are done, but okay
badkins has quit [Ping timeout: 256 seconds]
<samth> it means there's no reason for them not to be first class
<srandon111> guys when are global variables bad to use?
<srandon111> i mean in other languages i frequently hear that using globals is not a good idea
<srandon111> but here in racket i see them used
<srandon111> so when is it a good practice to use them and when not?
<greghendershott> wH100
* greghendershott should maybe learn how to focus before typing
<greghendershott> That was supposed to be C-w H 100 directed at Emacs, which is bound to something to set my font size to 10 pt on a certain monitor.
<greghendershott> srandon111: My opinion: If you have a small to medium .rkt file, and it's not supposed to work with multiple threads, and you don't `provide` the variable -- then sure make it "global" within the file.
<greghendershott> Otherwise probably make it a parameter. On the one hand that's the moral equivalent of mutating a global variable, but OTOH parameters are at least thread-safe.
endformationage has joined #racket
<samth> srandon111: just like I said yesterday, you are confusing "global variables", which are indeed a bad idea, and constant definitions, which are a good idea
<srandon111> okok thanks samth let's say i have a global constant.. how do i deal with code re-use ?
<srandon111> if i have to move that function to another module i lose the function portability no?
<samth> srandon111: it all depends what you mean by code re-use, but usually you don't re-use functions by copying them to another module. also, when you want to move some code, you also have to keep using all the things it depends on, which might include other functions, or constants, or structure definitions, or other things.
<srandon111> okok samth i got you
<srandon111> thanks a lot it is clear
<notnotdan> May I ask a question about Redex here? I am reading through the tutorial at https://docs.racket-lang.org/redex/redex2015.html
<notnotdan> However, for me (Racket 7.5) the term (term (lambda (x x) y)) is recognized by the grammar
<notnotdan> however if I understand correctly it should be rejected, according to the example in the tutorial
<notnotdan> Am I misunderstanding something here?
exit70 has joined #racket
<notnotdan> Oh, I think that test was supposed to fail according to the tutorial
<notnotdan> sorry, nevermind then
narimiran has quit [Quit: leaving]
nullcone has joined #racket
selimcan has joined #racket
badkins has joined #racket
Naptra has quit [Remote host closed the connection]
efm has joined #racket
badkins has quit [Ping timeout: 252 seconds]
emacsoma1 has quit [Quit: WeeChat 2.7.1]
emacsomancer has joined #racket
YuGiOhJCJ has joined #racket
ArthurStrong has quit [Quit: leaving]
sudden has quit [Ping timeout: 265 seconds]
sudden has joined #racket
badkins has joined #racket
<jcowan> samth: Remember that Steele said it would take too long to develop Scheme with boxes rather than mutable variables
<jcowan> variables are second-class but easier to optimize
<jcowan> (though in the end many compilers do use boxes anyway, with or without optimizing)
<jcowan> I would go so far as to say that the whole point of second-class anything is to make optimization (without a SSC) easy
true-grue has quit [Read error: Connection reset by peer]
orivej has quit [Ping timeout: 256 seconds]
wingsorc has quit [Quit: Leaving]
efm has quit [Read error: Connection reset by peer]
efm has joined #racket