
@mflatt further investigation of the launcher issue suggests that it’s this code that’s wrong: https://github.com/racket/racket/commit/572b96a6efc4dcb6c4e00fd4abeaedcae5eae868#diff-7a63c515d4e7d5db783c3786ebd72110R473

In particular, it generates this line in the shell script:

# {{{ librktdir
librktdir="$bindir/../../home/samth/sw/plt/racket/lib"
# }}} librktdir

which includes an absolute path inside the relative path

I don’t understand why that code is trying to generate something relative to dest
, since it’s then used relative to $bindir

@samth I think you’re right that I made the wrong change there, and your patch is the right repair as far as I can tell

@jaz has joined the channel

@leafac I’ve been using http://Glip.com\|Glip.com for a project for a while now. It’s free, has no history limit that I’m aware of, supports links, supports at least as much Markdown as Slack does, and allows uploading files with preview. If you link to a Google Docs you can even edit in inline.

(I have no association with the company)

@dstorrs: Nice. I didn’t know about Glip. Thanks for the suggestion. (But, contrary to what Racket team is doing, for the stuff I administer, I’m trying to move away from SaaS and self-host everything I can. Mainly because of the “if you’re not the customer, you’re the product” thing; I want the Internet to be as decentralized as possible. Specially in the weird times in which we live.)

> Specially in the weird times in which we live.
Preach it.

@leafac While I understand that impulse, it’s hard to maintain something large-scale with the same reliability as something like GitHub or slackbot

as we saw with the outage of several Racket services over new years

also, there are advantages of Slack beyond just hosting, since people know it, it has good mobile apps, etc

I agree. Just because I want to do this for the services I administer, it doesn’t mean I want everyone to do the same :slightly_smiling_face:

Same thing with licenses, too. Just because I use GPL for my personal projects, doesn’t mean I wouldn’t happily sign the relicensing permission to move Racket to MIT/Apache 2 (https://github.com/racket/racket/issues/1570#issuecomment-271853248) :slightly_smiling_face:

“I want the Internet to be as decentralized as possible. Specially in the weird times in which we live.” Also agree. “When the going gets weird, the weird turn pro.”

@bill_temps the valence of the latter line seems ambiguous these days …

Can someone recommend an example of a project that’s using rackunit on a large scale? I would like to see how certain things are automated, like running all tests in a project automatically, or just specific tests, or how to best define objects to be initialized before a testcase runs.

@pocmatos Typed Racket uses Rackunit extensively, see here: https://github.com/racket/typed-racket/tree/master/typed-racket-test

syntax-parse uses it here; that might be easier to follow: https://github.com/racket/racket/tree/master/pkgs/racket-test/tests/stxparse

@samth thanks, that’s useful.

Is floating point arithmetic more reliable in Racket than other languages?

I mean, the same 3 multiplications give me the following results:

javascript: 0.15 0.50 0.35

racket: 0.16 0.48 0.36

nlightnfotis: For float-only operations, Racket should just use your CPU’s floating point operations, as I’d expect JS would.

Could you share the programs you’re using? Possibly on pasterack?

stamourv Sure

Here is the racket program


And here is the js


I am always open to suggestions on how to make it better, I’m still a newbie as far as Racket is concerned

I mean, if you see something that could be more idiomatic

Oh, and I forgot to mention that I run it on racket v6.6 and node v6.9.1

nlightnfotis: Well, the main difference I see between the two is that your JS code explicitly rounds intermediate results by calling _round_number. That could have an effect.’

@nlightnfotis: the JS one seems to be explicitly rounding numbers in _next_gen
, which would explain a loss of precision

oops, Vincent beat me to it :)

:)

Okay. But is the rounding in _next_gen
enough to cause the discrepancies in the results?

I mean, the js version without the rounding would still produce 0.150000004 or something to that effect, while the racket version still produces 0.160000003

Am I right on that?

Ahh, okay, I checked it out.

It seems that without the rounding they both report the same numbers

@robby: I’m currently trying to fix https://github.com/racket/racket/issues/1412, and the more I look at it, the more I’m convinced the current default is the wrong one. Even the example in the syntax/parse
docs should really have the blame swapped. http://docs.racket-lang.org/syntax/exprc.html

However, I’m unsure if just swapping the blame for wrap-expr/c
is good enough, since I guess someone could theoretically want the current blame. What would be a decent way of exposing that choice to a user? Just including a boolean keyword argument called #:blame-swap?
seems pretty vague, but I’m having trouble coming up with a better name.

I originally tried adding a #:use-style
keyword argument that could be 'binding
or 'expression
, but that doesn’t really make sense, since what really matters is which party is responsible for providing the contract relative to the party providing the expression.

I’m not really sure how expr/c
is meant to be used but unless there is a clear notion of a boundary between two different parties, it will be hard to make this work. You would need to start there — where is the boundary and how can you get the names of the two parties on the opposite sides of the boundary?

Well, in my opinion, the user’s perspective of the boundary is usually extremely similar to the boundary formed by assigning an arrow contract to a function. In my case, I have a macro that implements some SQL-y syntax, and one of the inputs should satisfy a sql-expression?
contract. When a user writes this: (select from t where some-pred)
…then some-pred
is, in the mind of the user, just like an argument to a function, even though select
is a macro. If some-pred
turns out to be 3
, then a contract violation should be signaled where select
itself is the negative party. (I think, at least, I sometimes get which party is the negative one and which one is the positive one confused.)

@robby: One of the key issues here, though, is that the error message for a contract violation uses blame-swapped?
to decide whether or not to include a “broke its own contract” error message. Just changing the parties in the use of contract
that expr/c
expands to does not change blame-swapped?
.

that is correct.

And, I believe, the correct behavior.

swapping the arguments means that yoru broundary starts out hte other way, not that self-blame happened.

I agree. It just means that the current behavior of expr/c
will always produce a “broke its own contract” message, which I think is wrong.

I think that expr/c needs to establish a notion of boundary and I don’t see how it has the right information to do that (maybe it does and I just dno’t get it tho). without that, it isn’t clear how best to proceed.

I’m not sure that’s the issue here? Though obviously you know much more about this than I do so I am likely wrong. :) From my point of view, though, in the select
macro from above, the sql-expression?
contract applied to some-pred
is semantically like a contract used in the domain of an arrow contract; that is, its blame would normally be swapped during the contract’s projection.

But because expr/c
just attaches the contract directly, that never happens. An easy hack to change this is to write a (possibly naughty) contract combinator that swaps the blame: (define (blame-swapped/c ctc)
((cond [(flat-contract? ctc) make-flat-contract]
[(chaperone-contract? ctc) make-chaperone-contract]
[else make-contract])
#:name (contract-name ctc)
#:first-order (contract-first-order ctc)
#:projection (λ (blame) ((contract-projection ctc) (blame-swap blame)))
#:stronger (λ (x y) (contract-stronger? ctc y))
#:list-contract? (list-contract? ctc)))
This produces the right error message because expr/c
uses information from the source location of the syntax object provided as well as syntax-local-context
to establish which parties are involved, and the blame gets swapped to match the idea that this contract is a part of the macro’s domain.

This is obviously pretty hacky, though. Am I committing some gross atrocity against the contract system by doing that sort of thing?

I don’t think that’s quite the right approach. In the acse of the select
macro, I’d say that hte two parties are probably the runtime code that it expands into a calls to and the module where select
appears. If you put those two names into the two positions, do you get good error messages? If not, then I think a change to expr/c
is in order.

Probably writing blame-swapped/c
isn’t a good route.

@robby: Not really. Let me give an example. Consider this simplified, contrived piece of code: (define-simple-macro (use-integer {~var x (expr/c #'integer?
#:name "1st argument"
#:positive 'use-site
#:negative "use-integer/proc")})
(use-integer/proc x.c))
(define (use-integer/proc x)
(add1 x))
> (use-integer "hi")
1st argument of use-integer: broke its own contract
promised: integer?
produced: "hi"
in: integer?
contract from: anonymous-module
blaming: anonymous-module
(assuming the contract is correct)
at: unsaved-editor:28.13
Note the “broke its own contract” error message. Compare the alternative using the blame-swapped/c
hack: (define-simple-macro (use-integer {~var x (expr/c #'(blame-swapped/c integer?)
#:name "1st argument"
#:positive "use-integer/proc"
#:negative 'use-site)})
(use-integer/proc x.c))
(define (use-integer/proc x)
(add1 x))
> (use-integer "hi")
1st argument of use-integer: contract violation
expected: integer?
given: "hi"
in: integer?
contract from: anonymous-module
blaming: anonymous-module
(assuming the contract is correct)
at: unsaved editor:28.13

(Maybe a bad example because the macro and the use are being used in the same module. I should try it again with them in separate modules to get more illustrative error messages.)

I think I must be being clear. If we don’t start from a clear definition of the boundaries, then there are no answers.

Deciding who to blame for a contract violation where you don’t have an “us” and “them” on the opposite sides of the contract makes no sense.

The boundary here is effectively between the macro and the macro user.

(I left off a “not” in the “I think …” line. sorry)

The boundary needs to have some (ideally syntactic) manifestation in the program. Eg, between two modules. Or between the body of a definition and the rest of the module it contains.

So “the macro” doesn’t really count, since the macro is gone by the time the program runs and the contracts are checked.

Or, perhaps, I am missing some way to thnk o that as a boundary?

Is that a requirement, though? Each party still has a precise source location. The macro can use that information to collect enough info to create a meaningful boundary, even if there isn’t an obvious place in the runtime program where you can point to and say “here’s the boundary”.

I dunno if it is a requirement. I am just saying that without a boundary I don’t know how to design a contract system.

Maybe the boundary is the enclosing module of the use of the macro and the enclosing module of the definition of the macro?

Yeah, I think that’s what I’m getting at, even if I don’t really have a firm grasp on the formal model. :) At least, that’s what the implementation of expr/c
currently assumes.

@robby: Is there a reason the macro itself cannot be a party like a function can be a party?

The function isn’t a party. :slightly_smiling_face:

oh— unless you’re talking about define/contract?

I am, yes.

define/contract
is a shorthand for with-contract
really. And that establishes the boundary at the expression level.

Ie, things inside this “pair of parens” vs outside this pair of parens.

Sure, you could do something like htat.

I think modules are a better unit to choose for most things (it is less confusing when there are no free variables and the error messages make more sense and it seems to ust generally fit better with how we develop code) but it isn’t necessary

In the code fragment above, I don’t see “use-integer/proc” or “use-sit” showing up in the messages, so I’m not sure what to make of it.

(I have to go now, sorry)

No worries. This has given me stuff to think about, so I’ll keep trying some things. I think this has helped my understanding, though, so thank you.

(And for what it’s worth, 'use-site
is specially handled by expr/c
and basically turns into (quote-module-source)
.)