zainab.ali.london
2019-11-14 08:35:47

@zainab.ali.london has joined the channel


popa.bogdanp
2019-11-14 09:02:52

I have! I think the problem is koyo depends on my Postmark client, which conflicts with John Clements’ older package, so koyo seems to inherit that conflict via that dependency. When I look at the package index, it says koyo-docs succeeds but has conflicts and the “conflicts” text points to "https://pkg-build.racket-lang.org/(indirect%20conflicts.txt)", which 404s.

The docs are available here: https://docs.racket-lang.org/koyo@koyo-doc/index.html although I guess the conflict means that they don’t get indexed for search.


popa.bogdanp
2019-11-14 10:07:29

I’ve gone ahead and split out the postmark functionality into a separate package. Hopefully, that’ll resolve that conflict


soegaard2
2019-11-14 10:08:40

Great. It improves discoverability having docs on http://docs.racket-lang.org\|docs.racket-lang.org.


klaus612
2019-11-14 10:14:18

@klaus612 has joined the channel


rokitna
2019-11-14 11:15:33

For the next trick, Slack should have link previews for individual paragraphs of the HTTP spec. :-p


samth
2019-11-14 13:13:42

You could just rename the scrbl file to fix the conflict


samth
2019-11-14 13:14:26

Although there might be other file conflicts


soegaard2
2019-11-14 13:59:13

Is there a more direct way of 1. Defining a worker in a submodule 2. Use it from the same file ?

;;; Parallel Exercise Generation
(module* worker #f
  (provide worker)
  (define (worker pch)
    (displayln "worker started")
    (match (place-channel-get pch)
      [(list n from) (displayln (list "worker" n from))
                     (run n from exercise-sources-dev)]
      [x             (error 'worker (~a "got: " x))])
    (displayln "worker done"))
  worker)

(define-runtime-module-path-index worker-mpi '(submod "." worker))
(provide worker)
(define (worker pch)
  (define w (dynamic-require worker-mpi 'worker))
  (w pch))

(define-runtime-path worker-path "exercises.rkt")
(define (start)
  (let ([places (for/list ([i (in-range 2)])
                  (dynamic-place worker-path 'worker))])
    (def p1 (first places))
    (def p2 (second places))
    (place-channel-put p1 '(50 0))
    (place-channel-put p2 '(50 50))
    (map place-wait places)))

samth
2019-11-14 14:39:01

I typically use place and put it in a function.


soegaard2
2019-11-14 14:42:40

That does look simpler - I got on the wrong track due the first example in the reference.


deactivateduser60718
2019-11-14 14:52:21

@notjack I understand what you mean. My unspoken goals were to A) make setting relationships between commands a single-step operation, and B) keep all details related to a command contained within its associated module.

I’m looking at making a command tree that’s large enough to make maintaining a centralized specification of its “shape” a bit painful. A naming convention was a cheap way to dodge that.


deactivateduser60718
2019-11-14 14:53:08

This conversation is good evidence that the approach might be for a niche audience, not for everyone that wants to build CLIs in general.


deactivateduser60718
2019-11-14 15:36:45

I understand using (define-runtime-path here ".") to get a directory path relative to the enclosing module, but is there a reliable way to get the enclosing module’s file path?


deactivateduser60718
2019-11-14 15:37:36

deactivateduser60718
2019-11-14 15:38:50

I’m guessing use 'run-file anyway and just discard racket or gracket as part of casework?



samth
2019-11-14 16:17:42

but really I just recommend Eli’s answer to the SO question


soegaard2
2019-11-14 16:28:54

Is there a way to get the number of cores of the cpu on which racket runs?


samth
2019-11-14 16:30:01

processor-count


soegaard2
2019-11-14 16:30:29

Thanks. Tried searching for “cpu” and “core”.


spdegabrielle
2019-11-14 16:30:50

@pocmatos found on reddit > Thank you for doing these. I really enjoy reading them. > > Evžen Wybitul is developing Magic Racket, a VS Code plugin for Racket and has announced REPL integration. > > Can anyone comment on the various virtues of the different VS Code plugins for Racket? https://www.reddit.com/r/Racket/comments/dut9ub/racket_news_issue_19/f7hpyrk/?utm_source=share&utm_medium=ios_app&utm_name=iossmf


pavpanchekha
2019-11-14 16:39:50

Maybe. I’m still not convinced that the suggested architecture would work. (For example, I might only have one plot worker, but I would have one more worker, and that would cost a lot of memory too.) Also, I remember trying to wrap the threading library and found it difficult (you can’t pass closures into or out of a place, and variables behave strangely).


pavpanchekha
2019-11-14 16:40:40

For example, every worker needs to receive a message with current values for each global variables (for us, they usually reflect user parameters so are write-once). Abstracting around that is a pain.


samth
2019-11-14 16:52:58

me too, which means I now know about the cpuinfo package


soegaard2
2019-11-14 16:54:44

FWIW It reported 4 cores. But it really is a 2-core cpu with hyper threading. The OS treats it as 4 cores though, so the reporting is fair.


samth
2019-11-14 16:55:08

yes, sadly hyperthreading is a thing :disappointed:


samth
2019-11-14 16:58:35

A couple things: 1. place/context might help there 2. I got the herbie benchmarks running — where should I look for the code that creates places? 3. I did a simple test of loading various libraries in places, and racketcs indeed saves a lot of memory — it looks like about 5 mb to go from racket/base to plot, vs 60 MB on traditional Racket. Code here: https://gist.github.com/58b9d3a6673f8c746d12199ab41bf6a8


samth
2019-11-14 16:58:36

mflatt
2019-11-14 17:08:12

@samth That doesn’t sound right. Racket CS code is bigger, so it should be even more memory. I think your script needs to wait for each place to finish loading before measuring memory use.


mflatt
2019-11-14 17:11:37

(Maybe I missed something in the preceding thread, but there’s no sharing of module code across places — not even in Racket CS. I’m not sure how difficult it would be to enable sharing.)


samth
2019-11-14 17:13:16

What’s the best way to wait for the place to finish loading?


samth
2019-11-14 17:15:43

and doing something simple does get values that agree with your priors


samth
2019-11-14 17:16:26

@mflatt is that also why racketcs uses 5x more memory on startup, or is that about what’s counted in current-memory-use?


mflatt
2019-11-14 17:20:08

All of the above: the baseline is higher because the compiler’s implementation is included in current-memory-use, other loaded code is larger (bytecode to machine code is about x6), and JIT-generated code is generally not counted in current-memory-use for traditional Racket.


samth
2019-11-14 17:22:09

It seems like sharing machine code (at least the results of compile-linklet) would be a win for @pavpanchekha but I can see that would be hard with optimization for known exports of other linklets whose instances wouldn’t be shared.


pavpanchekha
2019-11-14 18:33:12

@samth The code that creates places is in src/web/thread-pool.rkt. There’s some place-based code in src/web/demo.rkt as well but ignore that.


pavpanchekha
2019-11-14 18:34:10

place/context is interesting, I didn’t know about that. Might be worth a refactor—I’ve added it to our task tracker.


pavpanchekha
2019-11-14 18:34:43

As far as I can tell the discussion with mflatt is about your measuring code, so I can’t contribute much there.


pavpanchekha
2019-11-14 18:34:55

Herbie doesn’t yet run on Racket CS, though I should play around with porting it.


samth
2019-11-14 18:35:16

yes, we concluded that you’re right that plot increases memory use a lot, and Racket CS doesn’t help.


pavpanchekha
2019-11-14 18:35:34

got it


notjack
2019-11-14 19:25:47

Would the large tree have subtrees? Could have something where a command group lists its commands and its subgroups


samth
2019-11-14 19:53:36

btw, I successfully ran bench/hamming on racketcs


deactivateduser60718
2019-11-14 20:05:20

natural-cli package now available.

On index: https://pkgd.racket-lang.org/pkgn/package/natural-cli Source: https://github.com/zyrolasting/natural-cli

For writing the CLIs where even the subcommands have subcommands.


pavpanchekha
2019-11-14 20:10:50

Nice!


pavpanchekha
2019-11-14 20:11:11

I assume that if you pass --disable precision:double to Herbie, it will fail, right?


samth
2019-11-14 20:11:51

the timing results were similar to regular racket; I can’t tell whether that’s surprising because racketcs is less good at float computation, unsurprising because racketcs is mostly similar in performance otherwise, or something else


samth
2019-11-14 20:13:07

and yes, that quickly produces an error


deactivateduser60718
2019-11-14 20:13:33

Docs link in README is broken until first build finishes.


pavpanchekha
2019-11-14 20:17:50

Herbie actually doesn’t do much float computation, as a percentage of runtime.


deactivateduser60718
2019-11-14 20:17:55

PDF preview:


pavpanchekha
2019-11-14 20:18:10

It’s mostly doing program transformations and manipulations, so it should have similar results as for general Racket programs


pavpanchekha
2019-11-14 20:18:20

If anything’s unusual about it it would be relatively few string manipulations


samth
2019-11-14 20:19:32

cool


deactivateduser60718
2019-11-14 20:28:25

> Would the large tree have subtrees?

Yes.

> Could have something where a command group lists its commands and its subgroups

Since each command module provides data about itself, a command tree dump means instantiating every module. Might be worth caching.


soegaard2
2019-11-14 20:45:44

How is output to standard out supposed to work when using places? It seems the output is delayed until the places are done. I’d like to print some progress messages to see the how far along the places are.


soegaard2
2019-11-14 20:49:19

It seems flush-output helps.


notjack
2019-11-14 21:36:14

Is instantiating every module a bad thing?


deactivateduser60718
2019-11-14 21:53:00

Probably not. I just don’t know the overhead.


deactivateduser60718
2019-11-14 21:54:01

Is there something special I’m supposed to do with the Travis instance for the package index to make these work on GitHub?


deactivateduser60718
2019-11-14 21:54:17

I’m late to the badge game.


samth
2019-11-14 22:23:19

not sure what you mean. the package index will update automatically.


soegaard2
2019-11-14 22:43:48

The Python folks use https://github.com/dbrgn/coverage-badge to generate the badges. and use this script to compute the coverage: https://github.com/codecov/example-python

I don’t think there is test coverage in https://github.com/greghendershott/travis-racket



deactivateduser60718
2019-11-14 22:49:06

So it looks like the answer to my original question was “yes”, although coveralls has instructions that don’t line up with what I’m seeing here.


soegaard2
2019-11-14 22:50:48

soegaard2
2019-11-14 22:52:00

deactivateduser60718
2019-11-14 22:54:06

That’s the ticket.


pavpanchekha
2019-11-14 23:12:16

Has anyone packaged a Racket library that uses FFI calls to a Rust component?


pavpanchekha
2019-11-14 23:12:49

We’re hoping to replace one component of Herbie with a much faster Rust implementation, but packaging and installation is a concern.


pavpanchekha
2019-11-14 23:13:23

One option is installing Rust and building the component in the package installation script, but that sounds really terrible


pavpanchekha
2019-11-14 23:13:42

Another is shipping binaries, but I’m not sure how to handle platform dependency in that case


pavpanchekha
2019-11-14 23:19:04

We currently have a Racket fallback as well, and it’s not clear how to use that when the Rust component fails.


mflatt
2019-11-14 23:25:29

Creating platform-specific packages for binaries is the way to go. See the “gui-i386-macosx”, etc., packages for an example, and see the way they’re referenced as per-platform dependencies in “gui-lib”: https://github.com/racket/gui/blob/master/gui-lib/info.rkt


mflatt
2019-11-14 23:30:53

For a Racket fallback, one way is to keep track of whether the shared library was loaded successfully, and have a function dispatch to the shared library or Racket code depending. For example, loading libcrypto may fail (https://github.com/racket/racket/blob/master/racket/collects/openssl/libcrypto.rkt) and HTTPS connections use other implementations when that happens (https://github.com/racket/racket/blob/master/racket/collects/net/url-connect.rkt).



mflatt
2019-11-14 23:31:41

On second thought, here’s a simpler fallback example: https://github.com/racket/racket/blob/master/racket/collects/openssl/sha1.rkt


notjack
2019-11-15 00:10:10

It could be, especially since you probably want to be able to dump out info about the command tree at the cli with subsecond latency. And it’s from a cold start too, since running each command has to start up the racket VM.


notjack
2019-11-15 00:10:18

But I have no idea honestly


notjack
2019-11-15 00:10:42

Definitely worth exploring


pavpanchekha
2019-11-15 00:14:04

Thanks!


deactivateduser60718
2019-11-15 00:18:47

Exciting Vulkan upgrade on the way :slightly_smiling_face:


wwall
2019-11-15 04:58:05

hello. Can somebody help with defiiine-syntax? i have code http://pasterack.org/pastes/29560 it convert list into another list, but how i can convert it into define-syntax? i need doing it on compile time.


yfangzhe
2019-11-15 05:11:51

Sorry, I can’t understand what you want well. For an introduction of macro, see “Fear of Macros”


wwall
2019-11-15 06:36:20

why this not work? http://pasterack.org/pastes/20972 how flatten begin in list?


notjack
2019-11-15 07:22:49

@wwall What is define-tokens-ext supposed to do?


wwall
2019-11-15 07:26:08

define-tokens-ext must define structure with predefined fields (name lexeme) and fields from declaration. also must declare function for create structure object F.e. (define-tokens-ext DataTokens ((WS (BOS correct mixed))) must work as (define-struct WS (name lexeme BOS correct mixed) #:transparent) (define (ext-token-WS lexeme BOS correct mixed) (make-WS 'WS lexeme BOS correct mixed)))


notjack
2019-11-15 07:32:54

What’s the use of the name field?


wwall
2019-11-15 07:34:37

name is type of lexeme (WS or ID or some) i want to write simple extension for define-tokens from parser-tools/lex Extend fields in token-struct with my list of field


notjack
2019-11-15 07:36:07

Right but if you’re generating a separate struct type for each type of lexeme, why would you need a name field? You wouldn’t be able to use it anyway, because you would have a separate accessor function like WS-name and COMMA-name for each type.


wwall
2019-11-15 07:38:54

I understand that. but while let it be a field clean it’s never too late


wwall
2019-11-15 07:39:16

now i interesting how rewrite my macros for it work


notjack
2019-11-15 07:40:11

I think you could make the macro clearer by using the syntax/parse library instead of syntax-case, and doing more work in the parse pattern


wwall
2019-11-15 07:40:58

well. thanks


notjack
2019-11-15 07:41:16

one sec, attempting to make an example


notjack
2019-11-15 07:55:43

@wwall I think this does what you want, but I’m not sure:

#lang racket/base

(require (for-syntax racket/base
                     racket/syntax)
         syntax/parse/define)

(begin-for-syntax
  (define-syntax-class token-type
    #:attributes ([name 0] [field-name 1] [constructor-name 0])
    (pattern (name:id (field-name:id ...))
      #:with constructor-name (format-id #'name "ext-token-~a" #'name))
    (pattern (name:id)
      #:with (field-name ...) #'()
      #:with constructor-name (format-id #'name "ext-token-~a" #'name))))

(define-simple-macro
  (define-tokens-ext token-group-name:id (type:token-type ...))
  #:with (private-constructor ...) (generate-temporaries #'(type.name ...))
  (begin
    (begin
      (struct type.name (name lexeme type.field-name ...)
        #:transparent
        #:constructor-name private-constructor)
      (define (type.constructor-name lexeme type.field-name ...)
        (private-constructor 'type.name lexeme type.field-name ...)))
    ...))

(define-tokens-ext DataTokens
  ((WS (BOS correct mixed))
   (COMMA)
   (ID (lang correct))))