Posts tagged Racket

Using syntax/loc and unit test macros

:: Racket, macros

In my previous post, I wrote about a nuance with syntax/loc, using the example of a macro that both defines and provides a function. But why don’t I back up, and look at a simpler example of why you’d want to use syntax/loc. The example is a simple macro you might often find yourself wanting, to reduce the tedium of writing unit test cases.

Using syntax/loc

:: Racket, macros

There’s a nuance to syntax/loc. The documentation says, emphasis mine:

Like syntax, except that the immediate resulting syntax object takes its source-location information from the result of stx-expr (which must produce a syntax object), unless the template is just a pattern variable, or both the source and position of stx-expr are #f.

What does “immediate” mean here?

Racket package management

:: Racket

Racket’s new package manager is great. It debuted with Racket 5.3.5. Although officially still in beta, it was already good enough to use for real projects. Racket developers wanted people to use it for real projects, to get the experience needed to make it even better.

Over many months, the Git HEAD version of Racket — what would become Racket 6 — gradually introduced a few new and changed features for package management.

However, you might not want to use the newer features, yet. Not if you want your package to be usable by people still using Racket 5.3.5 or 5.3.6 — or usable by other packages that wish to support such people.

Fortunately, the older features are still supported in Racket 6, and it’s not very difficult or inconvenient to use them. You just need to know what they are.

Using call/input-url

:: Racket

When I learned Racket, one of the first things I wanted to try was doing HTTP requests. And Racket’s net/url module is great.

Racket was the first real Lisp/Scheme family language I ever learned. As a result I was focused on building blocks like ports, and assuming I would need to open and close them directly all the time. At that early stage, I also didn’t really appreciate the value of higher-order functions. So I overlooked the value of call/input-url. I sometimes see other folks do the same, and wanted to write this short blog post.

Skim or sink

:: software, Racket

In my experience, the way to become a better programmer is to:

  • write lots of code
  • skim lots of reading material, and
  • defer answers until you have questions.

To learn why you should skim this post, please read it carefully.

Using Travis CI for Racket projects

:: Racket

Travis CI is a continuous integration service for open source projects that has nice integration with GitHub.

Whenever you push a commit to GitHub, a build/test can launch. Notification of the result comes via a variety of methods. Also there’s a “badge” to show the build status, which you can link to in your README.md.

Chromebook Pixel

:: Google, Linux, Racket

I’m writing this blog post on a Chromebook Pixel. In Emacs. On Ubuntu, as a chroot, thanks to crouton.

Why do I have a Chromebook Pixel? Google gave one to every Google I/O 2013 attendee.1

Although I was happy to get such a cool new gadget, I honestly wasn’t sure what I’d do with the thing. I really like my MacBook Pro Retina and wasn’t looking for an alternative. Also, although I love web apps and 45% of my day is in the web browser, another 45% is in Emacs using Racket — what about that?

The ~> Threading Macro

:: Racket, Clojure, macros

Although I prefer Racket, there are a few idioms from Clojure I like. I’m particularly infatuated with the threading macros, -> and ->>.

I was surprised how little documentation I could find for these. So although I’m writing this for Racketeers, it’s possible a few Clojure folks might find it interesting, too.