Clojure Destructuring Gotcha!

Posted:

Given the following function definition, what would you expect to happen if you ran (hello :person nil)?

(defn hello
      [& {:keys [person]
          :or {person "Rich"}}]
      (str "Hello, " person))

(hello) => "Hello, Rich"
(hello :person "Hickey") => "Hello, Hickey"
(hello :person nil) => "Hello, "

I’d have expected (hello :person nil) to have the same result as calling (hello), but as it turns out, Clojure seems to make a distinction between nothing and nil when it comes to destructuring.

A real world situation where this might occur would be where you, for instance, rely on the result of a destructuring operation to provide parameters for a function similar to hello. e.g.

(defn spam
      [& {:keys [person]}]
      (str (hello :person person)
            "Give me all your money."))

Calling (spam) would result in (hello :person nil) being called, which would have the - probably - unintended effect of returning "Hello, ". You may choose to add an :or when destructuring the argument to spam, but then you’ll have the same code appearing twice. A more localised solution would be changing the hello definition to be something like this.

(defn hello
      [& {:keys [person]}]
      (str "Hello, " (or person "Rich")))

This worked for my case, but I’d love to hear about more idiomatic approaches.


A New Client for Smartphones: Ona Collect

Posted:

Ona Collect

Today we are announcing the launch of Ona Collect, a tweaked version of ODK Collect created especially for Ona users. This new mobile client is a baby step into building a seamless experience for our users, starting with a few small improvements.

 Continue reading A New Client for Smartphones: Ona Collect...


Take Our Survey!

Posted:

Projects

Ona is conducting an online survey to better understand challenges faced by our users. If you use Ona now — or have in the past — we’d like to hear from you. Click here to take the survey.

How it works:

Please take a few minutes to complete the survey. It’s your chance to help us define our roadmap! Responses to this survey will be used internally only — and all individual responses will be kept strictly confidential.

Following the survey, you will be entered into a drawing to win a $50 Amazon gift card (or equivalent online retailer in your country). We will randomly draw three (3) winners, to be notified on Friday, December 4, 2015.

Thank you for your participation.

  • The Ona Team


The Ona unlimited free trial is ending tomorrow!

Posted:

The 3 week free trial for Ona is ending tomorrow and we’ll be enabling usage limits for users who have not signed up for a paid plan.

Starting tomorrow, users with personal accounts that are not on a paid plan will be transitioned to the free Community plan. This plan has a limit of 500 submissions total to private forms per month, 15 private forms, and 1 private project. Public project and forms, and submissions to public forms are unlimited.

Organization accounts that are not on a paid plan will be transitioned to the free Public Organization account. This plan allows unlimited public projects and forms, unlimited submissions to public forms, and no private projects or forms.

If you have existing forms on Ona that put you over your account limits, you will have limited access to your forms and account. For more information on what to do if you are over limit, read the over usage limit FAQ on our help page.

If you haven’t signed up yet and are interested in upgrading to a paid plan, please visit the Ona Plans page and contact us using the form. We’ll work with you to determine a pricing level for your use. If you aren’t grant-funded, you can also apply for the Impact Grant Program , which gives free Ona access and support to organizations who are making a difference and might have difficulty paying.


Projects

Posted:

Projects

This post will tell you everything you need to know about creating, sharing, managing, and getting the most out of your projects in Ona.

What is a project?

In Ona, a project is where your related forms and data are stored. Projects can hold as many forms and data as your plan allows. When you first log in to Ona, your home page displays a list of all of your projects as well as any projects that have been shared with you (more on that later). If you used the old version of Ona, then you probably noticed that when you first logged in to the new Ona site, all of your existing forms and data were automatically placed into your first project, which was called [Your username]’s Project. Don’t worry! You can always move your forms and data into other projects later on.

 Continue reading Projects...