tonyg changed the topic of #racket to: The Racket Programming Language -- https://racket-lang.org/ -- https://gather.town/app/wH1EDG3McffLjrs0/racket-users -- http://pasterack.org -- logged at https://libera.irclog.whitequark.org/racket/ -- This is the right place to ask for help with (Dr)Racket. Remember to wait around for an answer!
monkey_ has joined #racket
bremner has quit [Remote host closed the connection]
bremner has joined #racket
notzmv has quit [Ping timeout: 260 seconds]
monkey_ has quit [Ping timeout: 260 seconds]
adium has joined #racket
libertyprime has joined #racket
libertyprime has quit [Quit: leaving]
terrorjack has quit [Quit: The Lounge - https://thelounge.chat]
terrorjack has joined #racket
ur5us has quit [Ping timeout: 255 seconds]
ur5us has joined #racket
ur5us has quit [Ping timeout: 260 seconds]
skapata has quit [Remote host closed the connection]
ur5us has joined #racket
jboy has joined #racket
badkins has joined #racket
badkins has quit [Ping timeout: 252 seconds]
ur5us has quit [Ping timeout: 240 seconds]
codingquark has quit [Quit: No Ping reply in 180 seconds.]
codingquark has joined #racket
jeosol has quit [Quit: Client closed]
amirouche has joined #racket
badkins has joined #racket
skapata has joined #racket
badkins has quit [Ping timeout: 248 seconds]
skapata has quit [Remote host closed the connection]
badkins has joined #racket
jeosol has joined #racket
monkey_ has joined #racket
nij- has joined #racket
<nij-> o/ Completely new to racket.
<nij-> I'm curious how racket allows the user to easily customize the language (evaluator?). Is there any thing I can read to learn more about it?
<bremner> nij-: the book "beautiful racket" is about that
<nij-> Thanks, bremner
lucerne has joined #racket
<nij-> Oh, there's the reader and expander.
<nij-> Is it all? I was actually wondering if it's possible to change the evaluator.
<nij-> For example, in clojure, you can access a slot of a "map" (hash table) by putting a keyword in the 0th position of a lisp form. Something like
<nij-> (:age Jone) ; => 37
<nij-> However, this is beyond reader and macro expansion.
<nij-> The compiler needs to recognize the type of :age in runtime, and decides what to do then.
<nij-> decides how to evaluate/apply the form
<amirouche> My opinion is the one of another Scheme dialect, and (:age Jone) ; => 37 looks really not good
<amirouche> :)
<leah2> in chez, ^J executes the line directly, but in racket it's only like ^M
<amirouche> tho, your initial question already answered the second, with racket #lang foobar you can implement (:age Jone) ; => 37
<ecraven> this leads to lots of follow-up questions, like (map :age jones) ;)
<amirouche> leah2: what is ^J et ^M?
<ecraven> control-j and control-m
<ecraven> aka ascii 10 and 13 (line-feed and carriage-return)
<amirouche> I think chicken has something like this (:age Jone) thingy, there is even a SRFI IIRC
<ecraven> [I assume]
<leah2> yes
<leah2> my actualy question is can i make ^M only send the line if it's fully parenthesized and add a newline else
<amirouche> you use ^J and ^M in the REPL?
<leah2> no i use return
<leah2> which sends ^M
jeosol has quit [Quit: Client closed]
<amirouche> I use vscode :P
<leah2> if you use the repl in the terminal, it works the same
<nij-> amirouche how do I implement (:age Jone) => 37?
<nij-> Macroexpansion happens before evaluation. But this needs a way to tell the type of :age at runtime.
<amirouche> leah2 is impervious to trolls
<leah2> i'm 20 years on irc :p
<ecraven> nij-: you implement it non-portably ;)
<amirouche> nij-: fbbbg?
<amirouche> even fbbbbg: follow beautiful book, beautiful book good, see https://beautifulracket.com/
<ecraven> I've implemented a magic `ref' generic procedure that just references stuff.. I think I like (ref jone :age) more than the *really* magical (:age jone)
<ecraven> (also, I really wish all Schemes supported keywords :-/)
<ecraven> as in, self-evaluating symbols, not syntactic keywords
<amirouche> yeah, using a prefix is 0th can achieve that too
jeosol has joined #racket
<amirouche> what I had in mind is generalized set! @ https://srfi.schemers.org/srfi-17/
<amirouche> I am maybe too much "traditionalist" for that kind of ticks / hacks
<amirouche> s/tick/tricks/
<nij-> fbbbg?? what's that
<ecraven> amirouche: I've come to like that too ;D
<ecraven> leah2: my solution in such cases is mostly "use emacs to interact with it" :D
<leah2> with emacs i can't really send the current line with RET either
<amirouche> nij-: I meant to write fbbbbg as a joke based on https://www.acronymfinder.com/Follow-Book,-Book-Good-(FBBG).html and https://beautifulracket.com/ the latter being the book that explains how to achieve what you want
<amirouche> I am not sure why I do not like generalized set! and generalized ref
<amirouche> or even (:key mapping)
<nij-> amirouche do you mean beautifulracket does talk about how to create a lang so that (:key map) works as I expected?
<amirouche> nij-: yes!
<amirouche> things that comes to mind: 1) I like the idea that most procedure take (most of the time) object with one and only one type that is disjoint; the problem imo with the clojure approach is that I do not see how to implement that, without a set possibly large set of clause in a cond
<amirouche> re generalized set! I can read (set! (car x) (car y)), and even figure what it does, but I keep wondering how that can possibly work with all containers, including records, without again some cond clause or introspection for records?
<nij-> amirouche Before I read the whole book, could you perhaps hint me on why I was wrong?
<nij-> I was saying that in order to make (:key map) to work, the compiler needs to know the type of :key at runtime.
<nij-> This cannot be done by hacking the macroexpander.
<amirouche> I am not sure, I am not expert in racket :)
<amirouche> it depends what the macroexpander does
<nij-> macroexpander comes before the evaluator, and it cannot know what the type of :key is. (I think)
<amirouche> yes, but it depends on how racket implements custom #lang, imo you need a custom lang, and Scheme like macro expansion is not enough to implement what you need
<ski> (presumably `(let ((key :key)) (key map))' wouldn't work)
<nij-> @_@ I'm pretty confused..
<nij-> you're pretty sure this is doable?
<leah2> bah, the expeditor internals are all in unnamed modules so i cant hack them easily :>
<amirouche> sorry, I will let expert do the explaination
<ecraven> amirouche: the usual implementation is to register the setter for each getter, which maps `car' to `set-car!'
<amirouche> ecraven: that is what I call cond clause
<ecraven> ah, but it is not that ;)
<ecraven> however, if you want to make this work, you need implementation support
<ecraven> so define-record-type should register things, some clos-like thing should register things, and so on
<nij-> amirouche no worries! I appreciate your help :D
<ecraven> nij-: in essence, you need to override what application does
<amirouche> ecraven: I do not know why I do not like it, I can't put an explanation... seem like too much magic or something, the definition of set! is along the line: `(set! a b)` associate the variable `a` to the object `b` or the the object associated with `b` when `b` is a variable
<nij-> ecraven what is "application"? Do you mean the stage "apply", as in "eval/apply"?
<amirouche> once you do generalized set! you can write a book about how it works.
<ecraven> nij-: "function calling"
<nij-> sure! Yes, that's what I meant above.
<ecraven> I've done it, it isn't hard, but it's more complex than what set! does now, obviously
<nij-> Sometimes I use EVAL to mean eval+apply, as in REPL instead of REAPL.
<nij-> ecraven Right, so racket even has a way for me to change #'apply?
<ecraven> nij-: yes, and I don't know whether racket supports redefining what application means in custom #langs. I don't know much about racket, sadly
<amirouche> we are pirates from a nearby dimension
<nij-> At least in beautiful racket, it seems what's described are only about the reader and macroexpander.
<nij-> ecraven you said "yes" to.. that racket allows end users to hack APPLY?
<bremner> nij-: yeah, I've done that to add dynamic scope (for a demo)
<nij-> Did you hack the racket implementation itself?
<amirouche> nij-: speed reading beautiful racket, it appears that #lang works as follow: you parse the input, and expand into some "low" level racket lang
<bremner> nij-: no, just redfined %app, iirc
<nij-> amirouche yeah, so just reader and macro expander
<nij-> bremner! woah.
<amirouche> nij-: yes, and no. but look into what bremmer wrote above
<nij-> amirouche which part, exactly?
<ecraven> hm.. search engines don't handle racket very well :-/
<amirouche> https://docs.racket-lang.org/reference/application.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25app%29%29
<ecraven> so in essence, define your own %app that does things with keywords, then provide that as #%app
<nij-> that's cool
<amirouche> welcome to racket land!
<nij-> :D
<nij-> Now this is what I call a truly hackable language.
<ecraven> I *think* this only works for direct calls, so (map :age jones) might not actually work
<ecraven> but I have no idea, actually ;)
<amirouche> ...
<amirouche> With Kernel it is easy to do what you want, but... there is no fast implementation.
<nij-> SO, is %app called every time a lisp form gets evaluated?!
<amirouche> that is the question is asking ecraven
<amirouche> fbbg again ;)
<nij-> If it is true, it may slow down racket..
<amirouche> that is why Kernel is slow :)
<ecraven> well, it looks like this is tied into macro expansion, so that's just what gets expanded, but for (map :age jones), the function is *map*, not *:age*
<amirouche> so it is expanded to (you-app map :age jones)
<leah2> yet map somewhere calls apply
<amirouche> yes, map may call an optimized, lower form kind of apply, or even be completly implemented in C, before racket cs
<ecraven> yes, but not #%app, would be my (completely unfounded) guess
<amirouche> and oblivious of the custom #%app
<amirouche> read the code nij- it is there, it is open, it is free, it is an cli dance away: git clone https://github.com/racket/
<amirouche> git clone https://github.com/racket/racket
<nij-> thanks for the suggestion
nij- has left #racket [Using Circe, the loveliest of all IRC clients]
<bremner> my (ugly) module just exports my-app as #%app, where my-app is defined with define-syntax
badkins has quit [Remote host closed the connection]
badkins has joined #racket
badkins has quit [Ping timeout: 255 seconds]
<amirouche> do not be harsh
<amirouche> :)
lagash has quit [Remote host closed the connection]
jeosol has quit [Quit: Client closed]
lagash has joined #racket
badkins has joined #racket
jeosol has joined #racket
badkins has quit [Ping timeout: 256 seconds]
ec has quit [Remote host closed the connection]
badkins has joined #racket
badkins has quit [Ping timeout: 255 seconds]
ec has joined #racket
ec has quit [Remote host closed the connection]
ec has joined #racket
badkins has joined #racket
snits_ has quit [Ping timeout: 240 seconds]
snits has joined #racket
ec has quit [Remote host closed the connection]
ec has joined #racket
monkey_ has quit [Ping timeout: 256 seconds]
lucerne has quit [Read error: Connection reset by peer]
skapata has joined #racket
ur5us has joined #racket
badkins has quit [Remote host closed the connection]
badkins has joined #racket
aidalgol has quit [Ping timeout: 255 seconds]
aidalgol_ has joined #racket
lucerne has joined #racket
jeosol has quit [Ping timeout: 260 seconds]
lucerne has quit [Read error: Connection reset by peer]
lucerne has joined #racket
aidalgol_ is now known as aidalgol
ec has quit [Remote host closed the connection]
ec has joined #racket
lucerne has quit [Read error: Connection reset by peer]
badkins has quit [Remote host closed the connection]
badkins has joined #racket
badkins has quit [Remote host closed the connection]
badkins has joined #racket
badkins has quit [Ping timeout: 255 seconds]