[racket-users] Getting the "require" syntax arrows to work right

2015-10-24 Thread Alexis King
I’ve been toying with the idea of making an R7RS implementation in Racket, and one of the things I’ve implemented is the R7RS `import` form. It’s very easy to implement in Racket, and it works fine as far as I can tell, but I can’t figure out how to get the special binding arrows to cooperate wi

Re: [racket-users] Getting the "require" syntax arrows to work right

2015-10-24 Thread Alexis King
Aha, yes, that seems to work. I should have thought of that, but I actually didn’t know you can just copy all properties over with datum->syntax, haha. I guess I should have read the docs for that more carefully. This does seem a little bit like cheating because now the macro-generated racket/b

[racket-users] Why doesn't syntax/module-reader work with extra-argument read procedures?

2015-10-25 Thread Alexis King
When discussing custom `read` and `read-syntax` implementations, the Racket reference states this in section 1.3.18, Reading via an Extension: > The arity of the resulting procedure determines whether it accepts extra > source-location information: a read procedure accepts either one argument > (

[racket-users] R7RS (small) in Racket

2015-10-25 Thread Alexis King
I have built a very small, very incomplete implementation of R7RS in Racket. You can install the “r7rs” package, or you can find it on GitHub here: https://github.com/lexi-lambda/racket-r7rs Most of the standard seems fairly straightforward, but there are two questions I have. First of all, do t

[racket-users] syntax-original? always returns #f within syntax transformers?

2015-10-26 Thread Alexis King
I wrote a simple program that determines whether a piece of syntax is original in two different ways: (define-syntax (print-original stx) (syntax-case stx () [(_ datum) (begin (displayln (syntax-original? #'datum)) #'#'datum)])) (syntax-original? (print-original 'foo))

[racket-users] Changing reader parameters from within a reader extension

2015-11-02 Thread Alexis King
Hi all, I’m continuing to implement R7RS in Racket, and I think I’ve gotten most of the way aside from the various reader differences. The trickiest thing seems to be the #!fold-case and #!no-fold-case directives, which adjust the case-sensitivity of the reader as a side-effect. I’ve implemente

[racket-users] make-readtable with no arguments produces an incompatible readtable?

2015-11-02 Thread Alexis King
I came across some odd behavior today regarding readtables. Specifically, (make-readtable base) seems to produce a readtable that is operationally different from `base` when reading s-expression comments. Consider the following code: ; this works (read (open-input-string "(1 . 2 #;3)")) ;

[racket-users] Re: make-readtable with no arguments produces an incompatible readtable?

2015-11-02 Thread Alexis King
because the reader doesn’t get that far to actually execute the reader extension. Is there any feasible way to fix this in a general sense without reimplementing the entire list reader? Or will I just have to not support this on current versions of Racket? > On Nov 2, 2015, at 8:36 PM, Ale

Re: [racket-users] Help updating racket/function

2015-11-19 Thread Alexis King
Ah, that’s my package, and that issue is my mistake. I had a version exception for 6.2, but I was missing a version exception for 6.2.1. It should work on 6.2.1 now. Try updating alexis-collections (or uninstalling/reinstalling it), and it pull the right version. Thanks for the report! Alexis

Re: [racket-users] reducing pauses with incremental GC

2015-12-02 Thread Alexis King
Wow, this is great. I just tried it with one of my games that I made with big-bang, and the pauses I was having are completely gone, as far as I can tell. (I was doing quite a bit of copying, so I think the GC was triggering fairly often.) Thanks a lot for this; it’s definitely a big improvement

[racket-users] PSA: alexis/collection is dead, long live data/collection

2015-12-05 Thread Alexis King
Earlier this year, Jay suggested I move alexis/collection to data/collection and claim that namespace. In the past week, I’ve finally done so. Instead of using the alexis-collections package, just use the collections package. Otherwise, everything still works identically. The alexis-collections

Re: [racket-users] PSA: alexis/collection is dead, long live data/collection

2015-12-06 Thread Alexis King
The honest answer to your question is that I don’t know (though I’d also be interested to hear the answer). Obviously, I’d like to see generic APIs given more thought, but they are currently somewhat slow due to how dispatch is performed. I don’t think that’s a reason to design APIs in a certain

Re: [racket-users] PSA: alexis/collection is dead, long live data/collection

2015-12-09 Thread Alexis King
> On Dec 6, 2015, at 10:03 PM, George Neuner wrote: > > I would disagree that multiple dispatch isn't needed. The Visitor pattern is > used fairly frequently in real programs and it is just a overly complex, > error-prone way of doing double dispatch. Trying to handle more than 2 > dimensio

Re: [racket-users] about rackjure

2015-12-12 Thread Alexis King
Oft-forgotten feature about the curly-fn package: if you don’t include any arguments, it works as a shorthand for curry. So really, the idiomatic curly-fn solution would just be #{map sqr}, the shortest of the four. (Disclaimer: I wrote the curly-fn package.) Tongue-in-cheek comments aside, the

Re: [racket-users] [ANN] trivial 0.1

2015-12-14 Thread Alexis King
This is pretty neat. Without looking too much into the documentation or implementation, could you briefly elaborate on why these changes are in a separate package rather than improvements to TR itself? At a quick glance, you mention doing some sort of static analysis on arguments in the normal

[racket-users] Error reporting with missing head patterns in syntax/parse

2015-12-19 Thread Alexis King
Consider a macro that works just like `define`, but only allows function definitions. Here’s a simple implementation using the function-header syntax class from syntax/parse/lib: (define-syntax (defn stx) (syntax-parse stx [(_ header:function-header body ...+) #'(define header b

Re: [racket-users] [newbie] Help with streams

2015-12-20 Thread Alexis King
My “collections” package makes fairly heavy use of streams, so it provides a number of utilities to help with what you want to do. The obvious function here would be `generate-sequence`[1], which creates a stream from a generator. You can call `take` on the resulting sequence, since my generic impl

[racket-users] How can I group optional attributes captured with syntax-parse?

2015-12-31 Thread Alexis King
I have created a splicing syntax class that captures keyword options that may be provided in any order. Using the ~optional ellipsis head pattern makes this easy enough: (define-splicing-syntax-class opts (pattern (~seq (~or (~optional (~seq #:a a)) (~optional (

Re: [racket-users] Ligatures for monospace fonts in editors?

2016-01-02 Thread Alexis King
This is well-timed, as I was wondering precisely the same thing myself just yesterday. Atom recently gained support for ligatures, and I was trying out Hasklig, since I normally use Source Code Pro as my monospace font. I tried it out in DrRacket as well, and I was disappointed (though not surprise

Re: [racket-users] Simple regex question. How to match this: "[X] foo"

2016-01-08 Thread Alexis King
> You could make a Racket reader that did this. Or you can find some of the > interesting s-expression regular expression languages (I think Olin Shivers > did one). Or just not use regexps so much > ("http://regex.info/blog/2006-09-15/247”). When telling someone to avoid something useful, it

Re: [racket-users] Racket performance tips

2016-01-16 Thread Alexis King
Those programs appear to depend on input files. Is there any way you could provide those inputs or otherwise make the programs self-contained? I might be interested in taking a look at them, but it’s hard to get a feel for what’s going on without being able to run the programs. > On Jan 16, 201

[racket-users] Store value with unsupported type in Postgres?

2016-01-17 Thread Alexis King
The DB docs for SQL type conversions[1] note that not all Postgres types are supported by Racket, and it recommends using a cast to work around this. It even uses the inet type as an example right at the start of the page. However, I want to store an inet value in my database, not query an inet val

Re: [racket-users] Store value with unsupported type in Postgres?

2016-01-17 Thread Alexis King
I would like to avoid interpolating into a query if at all possible, given that this string is not something I control. I could be very careful about validating or sanitizing it, but this is a pretty textbook use case for parameterized queries. > On Jan 17, 2016, at 16:19, Jon Zeppieri wrote: >

Re: [racket-users] Store value with unsupported type in Postgres?

2016-01-17 Thread Alexis King
Perfect, that works great, thank you! It looks like the precedence works out such that I could do $1::text::inet and have it work properly, which is clean enough for my needs. > On Jan 17, 2016, at 16:39, Marc Burns wrote: > > You can cast first to a supported type: > > (query-exec conn "INSERT

[racket-users] Using the web server without continuations?

2016-01-19 Thread Alexis King
I’ve been using the Racket web server, and I’m very pleased with how easy it’s been to get a simple working application. However, so far, I haven’t been using send/suspend or any of the other features that leverage continuations. I’ve been wondering: since I’m not using send/back (just returning r

Re: [racket-users] Using the web server without continuations?

2016-01-19 Thread Alexis King
Perfect! That was my hope. One more question: if I did want to opt-in to continuations for just a single portion of my application, could I? The way I’ve been structuring my application is to have a module that serves as an entry point that calls serve/servlet and passes a dispatch function defined

Re: [racket-users] Re: #"HTTP/1.1 500 Okay" ??

2016-01-23 Thread Alexis King
For what it’s worth, I ran into this myself during my recent experimentation with the webserver, and I was similarly surprised. Even seeing something like “200 Okay” struck me as different, since most servers seem to use the “200 OK” spelling. I’d always been curious about how those strings were sp

Re: [racket-users] Standardizing the threading macro and organizing packages

2016-01-31 Thread Alexis King
> On Jan 29, 2016, at 21:55, Brian Adkins wrote: > > Was any consensus reached on this? I've been working through some exercises > in Racket that a friend is implementing in Elixir, and I just came across a > "method chaining" situation. I ended up simply writing a wrapper function, > but usin

[racket-users] Expression-style printing and quotation: helpful or harmful?

2016-02-05 Thread Alexis King
It is my understanding that “expression-style” printing was introduced to Racket v5.0, which alters how values are printed in the REPL to permit many printed expressions to be evaluated to produce the same value. In contrast to the traditional Scheme write procedure, this tends to manifest itself a

Re: [racket-users] Expression-style printing and quotation: helpful or harmful?

2016-02-07 Thread Alexis King
I appreciate your input, Matthew, but the location of the documentation is a separate conversation—the point seems to be that the current documentation is insufficient. Throwing a whole book at someone who is confused about apostrophes in their programs’ output is not an ideal answer, in my opinion

[racket-users] Substitude a different value when providing an identifier?

2016-02-18 Thread Alexis King
I have a macro that creates a transformer binding. This binding has prop:procedure on it, so when used, it functions as a macro and expands into something else. This works great, but I have another requirement: when this binding is provided, I actually want to provide an entirely different value in

Re: [racket-users] Re: Nesting structs – I'm confused!

2016-02-23 Thread Alexis King
> I'm not sure whether I should have known that the #:auto value would be the > same object, so to speak, across all instances. Is there a bigger picture, in > that respect, or is it just that structs happen to work that way, and other > data structures might not? A part of me just wants to bla

[racket-users] Requiring parent modules within module* forms?

2016-03-11 Thread Alexis King
The documentation for module* would seem to indicate that submodules declared with module* can require their parent modules: > Like module, but only for declaring a submodule within a module, > and for submodules that may require the enclosing module. However, this doesn’t seem to actually work w

Re: [racket-users] one-source-file package format

2016-03-12 Thread Alexis King
It might be worth noting that there was a thread on the racket-dev list a little while back that covered a similar topic about submodules and search paths: https://groups.google.com/d/msg/racket-dev/8BFT-RBDp9E/Y1xOCyf3nIMJ > On Mar 12, 2016, at 10:22, Jay McCarthy wrote: > > For my taste, I do

Re: [racket-users] IO in racket is painful

2016-03-22 Thread Alexis King
Honestly, judging from the responses in this thread, it would seem there may be a hole in Racket’s toolbox. Nothing I’ve seen so far is particularly stellar, especially since this is a problem that does not seem like it should be hard. It may be overkill for this use case, but I would probably use

[racket-users] Multiple namespaces in Racket

2017-10-12 Thread Alexis King
In discussions with some people at (seventh RacketCon), I managed to solve a few open problems I had in my implementation of Hackett. One thing I didn’t get a good answer for, however, is implementing a language with multiple namespaces. Hackett is not dependently-typed, so it is pointless and inco

Re: [racket-users] Multiple namespaces in Racket

2017-10-12 Thread Alexis King
> On Oct 12, 2017, at 1:46 PM, Matthew Flatt wrote: > > You could put all the type exports in a submodule. Then, you do need > your own variant of `require`, but that variant can mostly just check > for the presence of a type submodule, much the way that TR or > `plai-typed` do. If the submodule

Re: [racket-users] Multiple namespaces in Racket

2017-10-13 Thread Alexis King
This is a cool demo! Unfortunately, I have been thinking about the problem you describe since last night, and I am still totally stumped. This is something that seems difficult or impossible to paper over with more macros because #%require and #%provide are, ultimately, given special treatment by t

Re: [racket-users] Multiple namespaces in Racket

2017-10-14 Thread Alexis King
> On Oct 13, 2017, at 18:52, Geoffrey Knauth wrote: > > Maybe do undisputedly?-evil name-mangling now to get things working, > then become a saint with a better solution down the road. Sometimes > I don't realize how to do something the "good" way until I've traveled > down the path of doing it

Re: [racket-users] Multiple namespaces in Racket

2017-10-15 Thread Alexis King
> On Oct 15, 2017, at 08:59, David Christiansen > wrote: > > What about keeping type bindings separate from program bindings as a > matter of phase? This seems to me to fit in with the Hindley-Milner > program, where types exist only at compile time only, and programs > exist at run time only. I

Re: [racket-users] Multiple namespaces in Racket

2017-10-16 Thread Alexis King
I ended up spending the majority of my weekend working on this, and even after two days, it still doesn’t work quite right. My verdict is that it seems impossible to do perfectly seamlessly, but it seems possible (but maybe hard) to get 85% there. Here’s a (rather long) overview of what I tried and

Re: [racket-users] code reflection

2017-10-17 Thread Alexis King
I’ve noticed that the Racket macro system seems to have a reputation for being impenetrably complicated, which I do not fully understand. Hackett has, indeed, exposed a great deal of complexity, but Hackett is not an ordinary macro, and I found writing macros with syntax/parse to be quite pleasant

Re: [racket-users] Multiple namespaces in Racket

2017-10-17 Thread Alexis King
I’ve been continuing to work on this for the past two days, and I’ve managed to get a lot more working. I figured I’d write a (somewhat shorter) summary of what I have and haven’t solved. 1. The issue with module language imports still seems hopeless. 2. I managed to solve the submodule issue

Re: [racket-users] Multiple namespaces in Racket

2017-10-17 Thread Alexis King
> On Oct 17, 2017, at 20:11, Philip McGrath > wrote: > > It wouldn't solve the problem with shadowing `require`d identifiers, > but would having `#%module-begin` introduce the `require` (with proper > lexical context information), instead of doing it with the reader, > solve at least this part of

Re: [racket-users] Multiple namespaces in Racket

2017-10-18 Thread Alexis King
> On Oct 18, 2017, at 8:09 AM, Matthias Felleisen > wrote: > > Wouldn’t something like this work for Hackett? I don’t think so. Perhaps it would be better illustrated with an example. First, consider the Hackett definition of, say, the `Maybe` type: (data (Maybe a) (Just a) Nothing) This

Re: [racket-users] Multiple namespaces in Racket

2017-10-25 Thread Alexis King
> On Oct 18, 2017, at 1:08 PM, Matthias Felleisen > wrote: > > What I imagined was that you’d define @h-examples, which would > translate the former into the latter. — Matthias I finally did this and got everything working, mostly. I have opened a pull request with the current state of the names

Re: [racket-users] Multiple namespaces in Racket

2017-10-27 Thread Alexis King
-hackett/ And with that, I’ll stop bumping this thread if nobody else replies to it — I just wanted to record the details of my solution to the problem for posterity. :) Thanks to everyone who helped, Alexis > On Oct 25, 2017, at 10:33 AM, Alexis King > wrote: > > I finally did

Re: [racket-users] where does DrRacket get its environment variables on OS X?

2017-11-11 Thread Alexis King
> On Nov 11, 2017, at 08:17, Robby Findler > wrote: > > One example that lives on (in a zombie-like state) is the "search in > files" functionality Sort of off-topic, but I use the Search in Files option all the time, so don’t think nobody’s finding it useful! (Also, I virtually always launch D

[racket-users] Ownership semantics of string types in the FFI

2017-12-26 Thread Alexis King
I have some library that provides a function that produces a string: char* make_string(void); …and the library expects that I will eventually free the returned memory using a custom deallocator: void free_string(char*); …can and should I use the _string C type with ffi/unsafe to call this

[racket-users] The Birth and Death of Units

2018-01-21 Thread Alexis King
Hello, Racket’s units predate its module system. Indeed, it would seem that units were originally intended to *be* Racket’s module system, but evidently, that did not work out. My understanding is their replacement was due in large part to the desire for a more predictable macro compilation model,

Re: [racket-users] The Birth and Death of Units

2018-01-22 Thread Alexis King
Thank you for this explanation. I consider myself largely an outsider looking in on module systems, but I often hear SML and OCaml programmers complaining, wondering when Haskell is going to “get a real module system”. I’d like to do right thing in Hackett if I can, but I don’t really know what th

Re: [racket-users] whither `splicing-parameterize`? or am I doing it wrong?

2018-01-23 Thread Alexis King
Here is an implementation of a version of splicing-parameterize that uses local-expand, a la other forms in racket/splicing: #lang racket (require (for-syntax syntax/kerncase) (for-meta 2 racket/base) syntax/parse/define) (begin-for-syntax (define-synt

Re: [racket-users] Equivalent of dynamic-wind post-thunk for with-handlers

2018-01-24 Thread Alexis King
Based on your question, why not just use dynamic-wind in combination with with-handlers? Just keep in mind that the post-thunk could be called multiple times if there is a continuation jump into value-thunk, so you should also wrap the whole thing with call-with-continuation-barrier if it’s importa

Re: [racket-users] whither `splicing-parameterize`? or am I doing it wrong?

2018-01-25 Thread Alexis King
> On Jan 24, 2018, at 12:57 AM, Ryan Culpepper > wrote: > > It might make sense to `(set! new-parameterization #f)` at the end so > that the parameterization (and the values it holds) can be GC'd sooner > when splicing-parameterize is used at top level or module level. The tricky thing about doi

Re: [racket-users] whither `splicing-parameterize`? or am I doing it wrong?

2018-01-25 Thread Alexis King
> On Jan 25, 2018, at 16:45, Robby Findler > wrote: > > Isn't the last form already required to not be a definition? In that example, yes, but not always, and splicing-parameterize can’t be sure one way or the other. In this example, containing exclusively definitions is completely legal: (

Re: [racket-users] More DrRacket binding arrow woes

2018-02-14 Thread Alexis King
It is worth pointing out that Check Syntax does not see the result of your reader, it sees the fully-expanded module and performs its analysis from there. Therefore, it can be useful to use the macro stepper with macro hiding disabled to inspect the fully-expanded module to make sure that the infor

[racket-users] syntax/parse is not hygienic

2018-03-04 Thread Alexis King
Apologies in advance for both the inflammatory subject and yet another overly long email to this list. I think anyone who knows me knows that I love syntax/parse — I think it’s far and away one of Racket’s most wonderful features — but I’ve long suspected it does not respect hygiene. Consider:

Re: [racket-users] syntax/parse is not hygienic

2018-03-04 Thread Alexis King
> On Mar 4, 2018, at 15:11, Matthew Flatt wrote: > > I think scope-flipping would work, but FWIW, I thought you were going > a different direction here. The scope-flipping approach is a way to > infer an intended scope dynamically. It sounds to me like you want > something more static --- a way o

Re: [racket-users] syntax/parse is not hygienic

2018-03-04 Thread Alexis King
es not include much in the way of comparisons). Are there strong reasons to prefer Racket’s model aside from backwards compatibility and mild convenience when procedurally assembling pieces of syntax? > On Mar 4, 2018, at 19:28, Alexis King wrote: > > Sam suggested I take a look at van

Re: [racket-users] syntax/parse is not hygienic

2018-03-05 Thread Alexis King
Thank you to both of you for your detailed responses! I think this is all fascinating. > On Mar 5, 2018, at 05:18, Ryan Culpepper wrote: > > 1. Yes. To me, at least :) That aspect of hygiene is triggered by a > macro expansion step, and the macro expansion step also defines the > boundary of its

Re: [racket-users] syntax/parse is not hygienic

2018-03-05 Thread Alexis King
For those interested, it turns out you can get a loose approximation of the van Tonder system in Racket in just a few dozen lines of code. Namely, you can write a helper that undoes the macro-introduction scope added by the Racket macro system: (begin-for-syntax (define ((make-unscoped-t

Re: [racket-users] struct-copy question

2018-03-19 Thread Alexis King
I’m late to this thread, but perhaps I can clarify some things that I don’t think have been made entirely clear. First of all, you are absolutely correct that structures, at runtime, know nothing whatsoever about field names. At runtime, structures are fancy vectors; the names provided for their f

Re: [racket-users] Just how hard would it be to add a mutable toplevel language to Racket?

2018-03-21 Thread Alexis King
I haven’t actually used it myself, but Tony Garnock-Jones’s racket-reloadable library seems interesting and relevant. https://github.com/tonyg/racket-reloadable Alexis > On Mar 21, 2018, at 11:16, Christopher Lemmer Webber > wrote: > > Hi Sam! I wasn't familiar with racket/load and it see

Re: [racket-users] struct-copy question

2018-03-21 Thread Alexis King
> On Mar 21, 2018, at 15:32, Eric Griffis wrote: > > This would be a code smell if I didn't trust that our Racket ancestors > knew what they were doing, so the notion of "fixing" structs (or even > struct-copy) seems misguided. > > [snip] > > I can appreciate the architectural decision that str

Re: [racket-users] Question about Racket design philosophy: returning (void)

2018-04-10 Thread Alexis King
> On Apr 10, 2018, at 14:00, David Storrs > wrote: > > Aside from I/O, I can't think of too many cases where (void) is the > intuitively correct or most useful return value, but it is extremely > common throughout the built-in Racket functions. I'm not sure where > you're drawing the lines on 'A

[racket-users] Reimplementing Hackett’s type language: expanding to custom core forms in Racket

2018-04-15 Thread Alexis King
Hello all, I wrote a blog post about my recent experience rewriting the implementation of Hackett’s internal type representation, and on writing languages that expand to custom core forms in Racket in general. For those interested in Hackett and/or (ab)uses of some of the lesser-known features of

[racket-users] On Richard P. Gabriel’s “The Structure of a Programming Language Revolution”

2018-04-18 Thread Alexis King
Hello all, I have a rather different sort of question to ask about from my usual fare. A month or two ago, I read an essay written by Richard P. Gabriel and published at Onward! 2012 called “The Structure of a Programming Language Revolution”. The essay itself is available here to those interested

Re: [racket-users] Parametric composition?

2018-05-04 Thread Alexis King
Your composex macro is very similar to the various forms from the (as far as I can tell) fairly well-known threading package: http://docs.racket-lang.org/threading/index.html Disclaimer: I am the author of the threading package. In any case, there are some differences, but it has the same gene

Re: [racket-users] what do people use for number formatting?

2018-05-07 Thread Alexis King
I second ~r. It will round when given a precision. > On May 7, 2018, at 18:56, Stephen Chang wrote: > > Oops, I didnt see the rounding. > > On Mon, May 7, 2018 at 7:53 PM, Ben Greenman > wrote: >> I use this: >> http://docs.racket-lang.org/gtp-util/index.html#%28def._%28%28lib._gtp-util%2Fmain

Re: [racket-users] question on quasisyntax/loc

2018-05-08 Thread Alexis King
This behavior is intentional, though it could perhaps be more clearly documented. The behavior is hinted at in the documentation for syntax/loc: > Like syntax, except that the immediate resulting syntax object takes > its source-location information from the result of stx-expr (which > must produc

Re: [racket-users] Unbound identifier error with syntax transformer that uses syntax-generating helper procedure

2018-05-08 Thread Alexis King
The short answer is that you need a (require (for-template racket/base)) in your utilities submodule: (module utilities racket/base (provide compile-test) (require (for-template racket/base)) (define (compile-test) #`(lambda (i) (displayln `(input: ,i) But this answer pr

Re: [racket-users] How to handle circular 'requires'

2018-05-14 Thread Alexis King
In addition to what Matthias says, you can also sometimes break these kinds of cycles using lazy-require, which defers the requiring the other module until it is first needed. This is simpler than using units and provides stronger guarantees than using callbacks, but it is a bit more ad-hoc than bo

Re: [racket-users] Questions on functional-setter generator macro

2018-05-26 Thread Alexis King
This isn’t a direct answer to your question, but as Matthias notes, my struct-update package already implements a macro that generates functional setters from structure definitions. Here’s a link to the documentation: http://docs.racket-lang.org/struct-update/index.html Of course, that isn’t

Re: Parameters considered often harmful (was: Re: [racket-users] Re: A (long) question regarding parameters and scope)

2018-08-03 Thread Alexis King
Maybe this isn’t really a direct response to the direction this thread has taken, but given the question proposed in the original message, I think it’s relevant to share a particular design pattern for parameters that seems to work well. In a number of different APIs provided by Racket, a function’

Re: [racket-users] Testing & global variables

2018-08-07 Thread Alexis King
I guess I’ll take the bait and give the obvious-but-unhelpful answer, “Don’t use global variables.” :) I’m joking, but only just barely. It seems difficult to give concrete advice without knowing more details about your program and why you felt it was necessary to use global mutable state in the f

Re: [racket-users] What are disappeared-uses?

2018-08-16 Thread Alexis King
> On Aug 16, 2018, at 15:25, David Storrs > wrote: > > I see 'record-disappeared-uses' and 'with-disappeared-uses' in the > docs, but there's nothing that makes clear what you would use them > for. Some digging around on the mailing list suggests that they allow > Dr Racket to draw an arrow to a

Re: [racket-users] all-fields-visible? attribute of struct-id -- What is it?

2018-08-16 Thread Alexis King
> On Aug 16, 2018, at 15:35, David Storrs > wrote: > > struct-id from (require syntax/parse/class/struct-id) has an > all-fields-visible? attribute. I've looked around and can't figure > out what would cause a field to not be visible. Can someone point me > to the relevant part of the FM? Un

Re: [racket-users] How to handle define forms in a scribble-like language

2018-08-16 Thread Alexis King
You might find make-wrapping-module-begin from syntax/modbeg useful here: http://docs.racket-lang.org/syntax/module-helpers.html#%28def._%28%28lib._syntax%2Fwrap-modbeg..rkt%29._make-wrapping-module-begin%29%29 Alexis > On Aug 16, 2018, at 18:58, Vityou wrote: > > I'm attempting to make a l

Re: [racket-users] How do I get negative blame information?

2018-09-10 Thread Alexis King
I think the answer here really is “don’t use `contract` directly”. The actual implementation of the contract system does some fancy rebinding of my-func when you use define/contract, turning this: (define/contract x ctc rhs) into this: (define x-awaiting-neg (let ([tmp rhs]) (l

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-17 Thread Alexis King
> On Sep 17, 2018, at 12:21, Kevin Forchione wrote: > > That seems to be the nature of macros, and I’m not sure what the solution to > that paradox is, apart from perhaps building a symbol/function hash table as > part of a define. Presumably Racke does something like that for eva & > namespac

Re: [racket-users] colon keywords

2018-09-19 Thread Alexis King
I’m surprised this hasn’t been discussed yet: Alex Knauth has a set of meta-languages that add support for :kw or kw: syntax for keywords to arbitrary #langs (assuming they use readtables). http://docs.racket-lang.org/colon-kw/index.html Whether or not actually using these meta-languages is

Re: [racket-users] Compilation/Embedding leaves syntax traces

2018-09-25 Thread Alexis King
(Sorry, Paulo, for the duplicate message; I forgot to Reply All the first time.) This is sort of subtle. When we consider a macro-enabled language, we often imagine that `expand` takes a program with some phase ≥1 code, expands all the macros in the program by running the phase ≥1 code, and produc

Re: [racket-users] Racket-on-Chez snapshots

2018-10-02 Thread Alexis King
> On Oct 1, 2018, at 13:07, Brett Gilio wrote: > > Hey, could you provide a resource with more information on Chez possibly > replacing the Racket VM? I haven't been keeping up to date on this. >From an interaction between Greg Trzeciak and Matthew Flatt on the slack >channel: > Greg: is there

Re: [racket-users] Scribble xref links in frog

2018-10-08 Thread Alexis King
IIRC, --redirect-main only applies to packages installed in installation scope, not packages installed in user scope. I don’t know why this is the case, and I don’t know if it’s a bug or a (mis)feature, I just vaguely remember running into that problem before when using --redirect-main. You migh

[racket-users] Higher-order units

2018-10-17 Thread Alexis King
Imagine I have the following signature: (define-signature collector^ [(contracted [item/c contract?] [collect (-> item/c ... item/c)])]) Writing a unit that exports this signature is easy. For example, here’s one that sums its arguments: (define-unit sum-collector@

[racket-users] Creating truly unique instances of structure types?

2018-11-05 Thread Alexis King
To my knowledge, there are two main techniques for creating unique values in Racket: `gensym` and structure type generativity. The former seems to be bulletproof — a value created with `gensym` will never be `equal?` to anything except itself – but the latter isn’t. Using reflective operations,

Re: [racket-users] Creating truly unique instances of structure types?

2018-11-06 Thread Alexis King
> On Nov 5, 2018, at 20:01, Ryan Culpepper wrote: > > You could use a chaperone to prohibit `struct-info` Good point! I had forgotten that `struct-info` is a chaperoneable operation. This isn’t ideal, though, since I don’t think `struct-info` is ever actually supposed to raise an error, it’s j

Re: [racket-users] Destructuring a list in (for ...)

2018-11-23 Thread Alexis King
The trouble, sadly, is that this grammar is ambiguous. In (for ([(x y) s]) ) should (x y) be parsed as a single match pattern or as two binders for a two-valued sequence (such as one produced by in-hash, for example)? You could make it unambiguous in various ways, such as by requiring

Re: [racket-users] cons-specific optimizations?

2018-11-28 Thread Alexis King
> On Nov 28, 2018, at 07:15, Matthew Flatt wrote: > > Yes, that's special handling for pairs in the sense that the > traditional Racket implementation takes advantage of leftover bits in a > pair object, and it uses two of them for "is a list" and "not a list". > > Racket-on-Chez doesn't have th

Re: [racket-users] How do I launch a REPL in the context of a file?

2018-11-30 Thread Alexis King
> On Nov 30, 2018, at 08:23, Sam Tobin-Hochstadt wrote: > > I'm not sure why `-e` doesn't evaluate in the same namespace as the > REPL, but if you put `(enter! "my-file.rkt")` in `enter.rktl` then: I’m curious about this, too. At first I thought it was just a misfeature, not necessarily a bug,

Re: [racket-users] How to disallow certain characters in identifiers?

2018-12-10 Thread Alexis King
I think your initial instinct was right: if you want to change the lexical structure of your language, the right place to start is in the reader. The reader is the part of Racket’s language facilities that interprets the structure of sequences of characters, and your notion of dotted identifiers

Re: [racket-users] Communicating the purpose of Racket (was: hackernews)

2018-12-29 Thread Alexis King
> On Dec 29, 2018, at 21:32, Philip McGrath wrote: > >> Respectfully, I would also concentrate on Rackets web presence. If I was to >> google any of the popular languages, I would find the answer to these >> questions in spades, with real life applications, and examples. You can >> also comp

Re: [racket-users] Are the terms "function" and "procedure" synonymous in Racket?

2019-01-13 Thread Alexis King
Disclaimer: this answer is extremely non-authoritative. I think that, in Racket, the terms are used more or less interchangeably. The technical term is “procedure”, but as you point out, the term “function” is also used to mean the same thing. I don’t believe there is any distinction there that

Re: [racket-users] Why ChezScheme?

2019-02-09 Thread Alexis King
> On Feb 9, 2019, at 16:49, Hendrik Boom wrote: > > Just wndering -- What was the original purpose in moving Racket to Chez? You probably want to read Matthew’s original email on the subject, from about two years ago: https://groups.google.com/d/msg/racket-dev/2BV3ElyfF8Y/4RSd3XbECAAJ Alexis

Re: [racket-users] [macro help] How can I render a parenthesized set of elements optional?

2019-02-15 Thread Alexis King
Jon is right. Here’s an explanation why. Think of `...` as a postfix operator. It repeats what comes before it a certain number of times. In order for `...` to know how many times to repeat the previous head template, it looks inside the head template for any attributes bound at the appropriate

Re: [racket-users] Re: catch and bind an unbound id in a macro

2019-04-20 Thread Alexis King
The third argument to identifier-binding, top-level-symbol?, controls the result of identifier-binding when the identifier is bound to a top-level binding (and both the REPL and sandboxed evaluators are kinds of top-level evaluation). The docs elaborate this way: > The result is (list source-id)

[racket-users] Defeating Racket’s separate compilation guarantee

2019-04-21 Thread Alexis King
Hello all, I just published a blog post on defeating Racket’s separate compilation guarantee. While I don’t imagine such a thing is actually a good idea, I think the path to getting there is interesting anyway, and it touches lots of different parts of the Racket system. For those who are inter

Re: [racket-users] How would you implement autoquoted atoms?

2019-04-23 Thread Alexis King
I find this email fascinating, as about three weeks ago, Spencer Florence and I discussed something almost identical, from the module path + symbol protocol all the way down to the trouble with `quote`. I had been intending to experiment with implementing the idea at some point, but I already ha

Re: [racket-users] What is the difference between foo/c and foo? when creating contracts?

2019-05-22 Thread Alexis King
Your intuition is right, but let me make it more precise: foo? is used when something is a flat contract, and foo/c is used otherwise. Flat contracts only check first order properties of values, which is a technical term that captures what you mean by “general nature.” The important distinction

Re: [racket-users] What is the difference between foo/c and foo? when creating contracts?

2019-05-22 Thread Alexis King
Your intuition is right, but let me make it more precise: foo? is used when something is a flat contract, and foo/c is used otherwise. Flat contracts only check first order properties of values, which is a technical term that captures what you mean by “general nature.” The important distinction

<    1   2   3   4   >