
@chunsj has joined the channel

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?

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

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

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

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

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

@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.

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

@erviszyka has joined the channel

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

See the threading
package: http://docs.racket-lang.org/threading/index.html

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

Great! Thank you!

Looks like you can still read it all on http://archive.org\|archive.org at least: https://web.archive.org/web/20180320175551/http://library.readscheme.org/

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

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

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…

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

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

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

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

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

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

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

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

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

@notjack code for mocking certain functions in tests

@macocio I wrote this thing for mocking functions: http://docs.racket-lang.org/mock/index.html\|docs.racket-lang.org/mock/index.html

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

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

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

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

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

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

i think mocks have their place

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

(and handling external connections is one sensible place

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

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

@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

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

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

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

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.

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.