chunsj
2018-11-5 13:07:28

@chunsj has joined the channel


pocmatos
2018-11-5 14:31:14

We can create picts for slideshow with racket code using code. What about other languages? Is there maybe a way to use pygments to do the highlighting before turning it into a pict?


samth
2018-11-5 16:16:23

@pocmatos you could write a color lexer for your other language …


pocmatos
2018-11-5 16:21:43

Sounds too much work to display 3 lines of C in a slide. I was keen to have something ready! :slightly_smiling_face:


ben
2018-11-5 17:13:13

If there’s a #lang C somewhere, you can use that. Here’s an example using PyonR’s #lang python https://github.com/nuprl/retic_performance/blob/master/gm-pepm-2018/nepls-2017/nepls.rkt#L84


macocio
2018-11-5 18:41:18

Don’t think so, … could make one where it pipes the code to gcc and creates ffi wrappers to the generated objects


soegaard2
2018-11-5 19:11:06

I think Joe Marshall wrote a parser for C at some point - at the time Common Larceny was written.


willghatch
2018-11-5 19:26:55

@pocmatos sorry I rarely check slack. But anyway, a rash script is likely to be a bunch of top-level expressions. But you can also define a function, say

(define (f)
  {
     ls
     do stuff
     ...
  })

and then provide it. You can also make submodules and do normal racket stuff.


willghatch
2018-11-5 19:28:22

But if you require a rash module that just has top-level code it will just run once when you require it.


erviszyka
2018-11-5 21:05:41

@erviszyka has joined the channel


contact
2018-11-5 21:30:42

Hello! Is there a way to “pipeline” functions? An operator such that: (f (g (h x))) ≡ h ▶ g ▶ f x ?


lexi.lambda
2018-11-5 21:32:29

lexi.lambda
2018-11-5 21:33:27

Using threading, (~> x h g f) and ((lambda~> h g f) x) are both equivalent to (f (g (h x))).


contact
2018-11-5 21:36:15

Great! Thank you!


asumu
2018-11-5 23:10:17

asumu
2018-11-5 23:50:07

This slack really needs a rudybot (or does it have one already?)


asumu
2018-11-5 23:53:38

Anyway I was amused that this typechecks: http://pasterack.org/pastes/48774 (not in pasterack since it’s not on 7.1 yet)


asumu
2018-11-5 23:54:58

It makes sense since it’s avoiding backwards compat issues with vector-set! I think. Although if you use unsafe-vector-set! it will actually mutate it, but then you’re using unsafe ops anyway…


macocio
2018-11-6 00:03:39

@asumu Doesn’t vector-set! also mutate it? Considering it’s !, or does it merely set the variable to the newly constructed vector?


asumu
2018-11-6 00:04:24

@macocio it just errors in this case because the vector is actually immutable


macocio
2018-11-6 00:05:32

Indeed, the contents are, but (set! x #(4)) is still possible :stuck_out_tongue:


macocio
2018-11-6 00:06:02

I thought there’d be a vector-set for functional construction


macocio
2018-11-6 00:08:08

Where can I find this list? I’m very interested.


asumu
2018-11-6 00:10:28

The trouble is that a vector-set with the current vector representation would be really slow I think. Probably better to use something like pvectors or similar: https://docs.racket-lang.org/pvector/index.html


macocio
2018-11-6 00:12:00

Oh this is neat. Wish persistent data structures were the normal state in Racket


macocio
2018-11-6 02:41:35

What’s a good way of requiring mock files when doing raco test?


notjack
2018-11-6 03:32:24

@macocio mock files? like, files of data read by test cases? or files of code?


macocio
2018-11-6 04:13:42

@notjack code for mocking certain functions in tests


notjack
2018-11-6 04:16:39

notjack
2018-11-6 04:17:24

fair warning: mock-heavy tests are only slightly better than no tests at all


macocio
2018-11-6 04:19:44

I quite strongly disagree. At work we mock our entire HTTP client for instance, and we can locally test that are sending the correct requests to cloud. Extremely useful to prevent regressions. Among other things


notjack
2018-11-6 04:21:46

I agree mock-heavy tests can catch things. But I really believe they’re best used as a kind of stop-gap measure for when fakes are hard to build or there aren’t any off-the-shelf ones you could reuse


macocio
2018-11-6 04:23:10

True, I just reacted to the quite general statement of only being slightly better than no tests at all, context matters.


macocio
2018-11-6 04:23:36

Especially for massive (mln LOC) subsystems that get tested, it’s not realistic to do anything but mock some parts and see what happens


notjack
2018-11-6 04:25:19

at work my codebase is heavily tested with almost no mocks, and it’s a pretty large system (I think between 100k and 1m loc?) - but it took some up-front design work to ensure that could happen


joelmccracken
2018-11-6 04:26:10

i think mocks have their place


macocio
2018-11-6 04:26:18

I think it depends a lot on the type of software I guess. We do lots of cloud and p2p stuff and don’t wanna spin up servers for local testing


joelmccracken
2018-11-6 04:26:37

(and handling external connections is one sensible place


notjack
2018-11-6 04:27:38

external cloud services make this really hard and maintaining a locally-deployable fake implementation of a cloud service is an absurd amount of maintenance work


joelmccracken
2018-11-6 04:28:25

(FWIW i vastly prefer fakes and dependency injection over mocks/stubs)


notjack
2018-11-6 05:29:08

@lexi.lambda I’m attempting to reproduce the example you gave in the mailing list post about struct generativity, and I’m not getting the same results


notjack
2018-11-6 05:29:53

In racket 7.1 when run from DrRacket, this program raises an error:

#lang racket/base

(define the-unsupplied-arg
  (parameterize ([current-inspector (make-inspector)])
    (dynamic-require 'racket/contract 'the-unsupplied-arg)))

(define-values [info skipped?] (struct-info the-unsupplied-arg))

(define another-unsupplied-arg ((struct-type-make-constructor info)))

(equal? the-unsupplied-arg another-unsupplied-arg) ; => #t
(eq? the-unsupplied-arg another-unsupplied-arg)    ; => #f

Specifically, it raises:

struct-type-make-constructor: contract violation
  expected: struct-type?
  given: #f

notjack
2018-11-6 05:30:33

I suspect you ran your example from the command line and the example has different behavior if it’s run in a namespace where racket/contract is already instantiated


lexi.lambda
2018-11-6 05:42:26

Yes, you can’t run it inside DrRacket because you don’t have control over the instantiation of racket/contract.


lexi.lambda
2018-11-6 05:44:19

I didn’t mention DrRacket explicitly in the email, but I did sort of allude to the example being fragile in that way. It isn’t really practical, as written, but the question is more about the ideas than the pragmatics.


notjack
2018-11-6 05:51:20

I think it hints at an idea: while you might be able to get ahold of things you shouldn’t like that through reflective operations, you can’t really get a reflective handle on a module’s secrets in the same context as one where you import the module normally. So the secrets you acquire are practically speaking always unusable.