kamil.beker
2019-12-5 10:10:46

Another cool newbie question: What does Dr. Racket have that combination with Text Editor of your choice / REPL does not have?


alexharsanyi
2019-12-5 10:53:09

kamil.beker
2019-12-5 10:54:00

woah, thats cool


kamil.beker
2019-12-5 10:54:01

:slightly_smiling_face:


psnively
2019-12-5 14:28:01

@kamil.beker: I would say: Dr. Racket is a rich environment supporting programming language research along multiple dimensions. It shows this both by supporting a significant array of languages, mostly Scheme dialects, but see e.g. Dracula and ALGOL for significant exceptions, and PLT-Redex for its use as a tool for designing new languages. Also, Dr. Racket offers its own GUI environment as libraries to use, and there’s a whole Functional Reactive Programming language, FrTime, that allows you to develop GUI programs with it. In fact, I was just discussing that with @samth yesterday. For example, if you choose "FrTimefrom the "Language..." menu, then type e.g.seconds` into the REPL, you’ll see the current seconds (since the epoch, I guess) update dynamically in the REPL history.


psnively
2019-12-5 14:29:05

@kamil.beker: So maybe think of “Racket” as a language, and “Dr. Racket” as a language workbench.


psnively
2019-12-5 14:32:38

@samth: Speaking of, should we elaborate the issue you created on my behalf to express the fact that something weird about frame construction is going on, where text rendering bleeds outside the frame, etc.?


samth
2019-12-5 14:32:51

Yes that would be great


samth
2019-12-5 14:32:56

With a screenshot


psnively
2019-12-5 14:33:03

@samth: Also, I’m happy to help diagnose if I can, but I honestly don’t even know where to start.


psnively
2019-12-5 14:33:12

@samth: OK. Let me find that issue and edit.


psnively
2019-12-5 14:37:06

Done.


kamil.beker
2019-12-5 14:38:36

Great!


elyandarin
2019-12-5 15:18:02

OK, new approach. Expressions can be manipulated, right? And a function definition is an expression, right? So I can probably make a copy of the function, search-and-replace in the datum, and paste a new, changed, function.

Something like, (define simple-tokenizer (except-with-replacement make-tokenizer "lexer-src-pos" "lexer")) OK, what’s the syntax for “produce the datum for the function with this name”?


elyandarin
2019-12-5 15:27:10

Newbie question: Is there a way to get the datum of a function just by using the function name?


soegaard2
2019-12-5 15:28:10

A datum is a literal value. Like 42 “foo” ’bar. Functions do not have datums.


elyandarin
2019-12-5 15:28:42

datums are basically code, right?


soegaard2
2019-12-5 15:28:52

No.


soegaard2
2019-12-5 15:29:10

Well, depends on what “code” is :slightly_smiling_face:


elyandarin
2019-12-5 15:29:17

OK, so what’s the terminology for ‘code’, then?


elyandarin
2019-12-5 15:29:54

I want to copy the code of a function, make changes in it, and paste it as a new function.


soegaard2
2019-12-5 15:30:12

That’s the problem - is code short for machine code?


soegaard2
2019-12-5 15:30:29

Ah! Now I get it.


soegaard2
2019-12-5 15:31:02

When a function is compiled, the original source code is not stored in the function value.


elyandarin
2019-12-5 15:32:02

I’m OK with doing it at compile-time, with a macro of some sort.


soegaard2
2019-12-5 15:32:50

What is the overall goal here? To define some functions that are similar?


elyandarin
2019-12-5 15:33:34

It’s that tokenizer I was fiddling with, that’s still not working.


elyandarin
2019-12-5 15:34:41

So I thought, ‘hey, the only difference is “lexer” vs “lexer-src-pos”, so couldn’t I do a search-and-replace?’


elyandarin
2019-12-5 15:35:29

Something like, (define simple-tokenizer (except-with-replacement make-tokenizer "lexer-src-pos" "lexer"))


soegaard2
2019-12-5 15:36:54

(define lex/src (lexer-src-pos ...)) ; lexer that returns position tokens (define (lex in) (position-token-token (lex/src in)) ; lexer that returns tokens


soegaard2
2019-12-5 15:39:02

Use lexer-src-pos to define a lexer lex/src that returns tokens with positions (in the form of position tokens). Then define a new lexer that calls the lexer lex/src and simply throws away the source positions.


elyandarin
2019-12-5 16:10:51

What is the “in” argument?


soegaard2
2019-12-5 16:11:12

The input port.


soegaard2
2019-12-5 16:12:04

You can for example try (lex (open-input-string "1+2"))


elyandarin
2019-12-5 16:18:07

Huh… It seems to be working now (I’m still getting errors but not from that part, at least.) Thanks.


soegaard2
2019-12-5 16:21:17

Great.


deactivateduser60718
2019-12-5 18:16:17

This doesn’t seem right. I was expecting ./b. Is this a bug, or am I misunderstanding what this is supposed to do? > (find-relative-path "/a" "/b") #<path:../b>


deactivateduser60718
2019-12-5 18:16:59

This is Racket 7.4


jaz
2019-12-5 18:17:15

I think it’s the latter.


jaz
2019-12-5 18:17:32

The point is to find a path to the second argument, starting from the first.


deactivateduser60718
2019-12-5 18:18:14

But the arguments are both complete paths from root. You can’t cd .. from root.


soegaard2
2019-12-5 18:18:27

If path shares no subpath in common with base, path is returned.


soegaard2
2019-12-5 18:18:59

Here "/b" is the path and "/a" is the base.


samth
2019-12-5 18:19:09

I think you want the more-than-root keyword argument


deactivateduser60718
2019-12-5 18:19:20

Ah, so /a is treated like a path to a directory.


jaz
2019-12-5 18:19:51

(Right — so I was thinking of /a and /b as directories, not as files. Which is why the rule that @soegaard2 mentioned is important.)


deactivateduser60718
2019-12-5 18:20:17

Gotcha. I am approaching this thinking of a and b as files.


deactivateduser60718
2019-12-5 18:24:15

more-than-root causes the output to be "/b" when the paths are just root paths, but it not solve my problem. > (find-relative-path "/blah/a" "/blah/b" #:more-than-root? #t) #<path:../b> Added context: Given an HTML file, I want to generate a relative path to put in src or href attribute relative to that document. The way I’ve been using find-relative-path has caused it to look in a directory above where a desired file actually is.


deactivateduser60718
2019-12-5 18:25:48

From what I’m seeing, I just can’t use a file path as a base argument.


deactivateduser60718
2019-12-5 18:26:32

So this is closer to intended use. &gt; (find-relative-path "/blah" "/blah/b") #&lt;path:b&gt;


deactivateduser60718
2019-12-5 18:26:39

Got it. Thanks all.


samth
2019-12-5 19:05:31

I believe that the intention of find-relative-path is that (simplify-path (build-path a (find-relative-path a b))) produces b.


gknauth
2019-12-5 19:31:16

Has anyone used the db package to connect to SQLServer? I’m having difficulty with the connection string and am looking for examples.


notjack
2019-12-5 19:36:15

Expressions are evaluated at runtime and can be manipulated at compile time, but you can’t mix runtime and compile time together. I think you want a macro like this:

(define-syntax-rule (make-my-tokenizer lexer-type)
  (lexer-type ["foo" (do-foo-stuff)] ["bar" ...] ...))

(define my-ordinary-tokenizer
  (make-my-tokenizer lexer))

(define my-position-tracking-tokenizer
  (make-my-tokenizer lexer-src-pos))

gknauth
2019-12-5 21:16:12

Never mind. I got it to work by creating a DSN (data source name w/config info) using the Windows app ODBC Data Source (64-bit).


ryanc
2019-12-5 21:27:20

That’s what I did when I tested the library against SQL Server (Express).


deactivateduser60718
2019-12-5 22:15:38

What’s the difference between promises and futures, exactly? From the docs I’m guessing that promises run concurrently without attempting to run any operations in parallel. Is that right?


notjack
2019-12-5 22:19:50

Promises are for doing something lazily, they have nothing to do with concurrency or parallelism. Futures are for doing small-but-CPU-intensive operations in parallel.


notjack
2019-12-5 22:21:53

(minor addendum: promises are also for caching)


samth
2019-12-6 01:32:47

There’s also delay/thread which is concurrent.


yfangzhe
2019-12-6 01:35:39

Is there the Racket solution for await/async?


samth
2019-12-6 01:39:55

@yfangzhe Racket has lightweight threads, you should just use those.


samdphillips
2019-12-6 01:42:34

Racket threads are so much nicer imo.


lister.daniel
2019-12-6 02:12:23

@lister.daniel has joined the channel


shu--hung
2019-12-6 03:42:14

OTOH Racket has very powerful control operators.


samth
2019-12-6 03:43:52

yes, you can also just use call/cc to do the equivalent of async/await


ben
2019-12-6 05:23:31

@stchang thanks for the graph library


sorawee
2019-12-6 05:30:11

lol


sorawee
2019-12-6 05:30:39

Is this AOC?


sorawee
2019-12-6 05:32:17

Wut, there’s fewest-vertices-path in the graph library? That’s cheating! lol


sorawee
2019-12-6 05:37:28

Ohhh. It’s just doing the general shortest path. That makes sense. I thought there’s a procedure to find LCA path (which would be weirdly too specific).


wanderley.guimaraes
2019-12-6 07:18:16

Wow! The idea of adding property to the edges and vertices is really cool. That is a really nice way to allow extensions to the algorithms.

Wow wow for the number of algorithms you covered.

@stchang nice job! :clap::clap::clap: