Gauche Devlog

< Almost there? | 0.9.4 is out! >


Keyword-symbol integration

Aargh, Already May? Unbelievable. Final stretch turned out to be a long marathon.

If you monitor github repo you know it's actively developed, though most changes are minor fixes. I cleared the items on the table I listed last time for 0.9.4 release, but I realized I left out one major item: Keywords.

Gauche has a keyword type, disjoint from other types. I think I inherited it from STk. I also speak Common Lisp and having :keyword is so natural that I tend to forget that treating keywords specially actually conflicts RnRS spec. In RnRS, they must be symbols.

In fact, it became an issue when we adopted srfi:42, in which symbols beginning with : is used. Alex Shinn employed a clever trick during macro expansion to work around the issue.

Now, with more R7RS libraries coming out, I expect this design would be a bigger obstacle.

Some implementations that have keywords avoid this conflict by adopting a syntax different from symbols, e.g. #:keyword. In fact, my original plan was to make the keyword syntax customizable, :keyword, #:keyword or even keyword: (DSSSL style; anybody remember?). That's why we don't have the colon in keyword's name slot. However, mixing these syntax is just confusing, and I strongly prefer :keyword anyway. #:keyword has a merit of not conflicting with symbols, but they are visually too intrusive, and it has been used as uninterned symbols in CL and Gauche.

Technically we don't need to make keywords separate from symbols; indeed, in CL, keywords are just symbols in the keyword package. We can just do the same:

  • We can make <keyword> a subtype of <symbol>. Identifiers beginning with ':' are read as an instance of <keyword>, but they're also symbols. So keyword? still works, but keywords also return #t for symbol?.
  • We can have gauche.keyword module, that acts as if it has constant bindings of every possible keywords, bound to itself. In reality, we create such bindings on the fly as keywords are read.
  • Then the gauche module can inherit gauche.keyword, so that existing usage of Gauche keywords will be preserved. They are symbols, but evaluate to themselves. It also allows programmers to rebind keywords (locally or at the toplevel of their modules) but the effect stays local, and those who conduct such an act should know what they are doing.
  • The r7rs module does not inherit gauche.keyword, hence symbols starting with : are just ordinary symbols. All portable R7RS code should run.
  • If one wish to use Gauche features and import gauche.core, the bindings of those keywords come with it, so you can call Gauche procedures with keyword arguments just like you're using Gauche.

This looks reasonable to me. There are a couple of catches, but I think they are minor and easily worked around:

  • If you import some of Gauche's procedures into R7RS code by (import (only (gauche core) foo ...)), keywords are not imported, so you should call it something like (foo ':bar b ...) i.e. quoting keywords.
  • If you import both an R7RS library that exports bindings of symbols that begins with : and gauche.core into R7RS code, whichever comes later would shadow the former. Generally you need to import gauche.core first.

However, this change needs to break the backward compatibility of certain cases, and it turned out it's a bit complicated. I'll describe it later.

Tags: r7rs, keyword

Past comment(s)

Moises (2019/07/24 11:23:49):

Recorded Delivery porn tube If the jobs data is strong, speculation over whether the Fed can curb its $85 billion-per-month bond-buying program this year is likely to return, injecting some volatility into the currency market.


Harry (2019/07/26 18:47:58):

I'm a trainee japan xnxx His son Albert, known to the family as Bertie, became king after the abdication of Edward VIII in 1936. He didn&rsquo;t feel up to the job, as portrayed in the film the King&rsquo;s Speech, but became a much-admired leader during the Second World War. He chose to be George VI in honour of his father.


Terence (2019/07/27 01:36:47):

Free medical insurance Negotiations have revolved around reunifying the country under a federal roof, but significant disagreements between the two sides remain on power-sharing, military intervention rights for Turkey and arrangements regarding private property lost during the invasion.


Eva (2019/07/29 16:22:17):

Just over two years x hamster Chief Executive Curt Culver said he was encouraged by MGIC'srecent credit performance, given that the number of delinquentloans fell 24 percent in the second quarter to their lowest inthe last five years.


Rudolf (2019/07/30 06:41:36):

How much notice do you have to give? xnxx tamil That&#039;s just a typical day in the fictional city of Los Santos. There’s no better way to describe Rockstar North&#039;s latest release of Grand Theft Auto V other than as a fantastic masterpiece filled with a cast of colorful characters, an array of vehicles and weapons and a landscape said to be bigger than GTA San Andreas, GTA IV and Red Dead Redemption combined.


Gaylord (2019/07/30 06:41:38):

I saw your advert in the paper amp land ...overpaying for an acquisition. Bidding wars for houses are becoming the norm again, as inventories are still low. Once sellers step off the sidelines, though, more homes will be available, so you may not have to go above asking price.


Diego (2019/07/30 06:41:40):

What qualifications have you got? myvidster gay

  Three sources at banks and brokerages who declined to be identified said trading desks were advising Nasdaq not to rush to reopen, fearing that further technical errors could sap even more confidence from rattled markets.

Napoleon (2019/07/30 08:59:29):

I wanted to live abroad streamate login

  As chief of CME, Donohue had little interaction with marketregulators at the Securities and Exchange Commission, which isOCC's main regulator. CME's main regulator is the CommodityFutures Trading Commission.

Gustavo (2019/08/10 17:51:47):

Have you seen any good films recently? Regarding the related job cuts, ESPN said: "Changes of this nature require difficult decisions, including the elimination of some roles. Under the two-event model ESPN will require a smaller workforce to stage and support the events."


Fredric (2019/08/17 12:34:43):

How do you spell that? hdreporn All this, rather stunningly, has failed to stoke inflation or cause the US government&rsquo;s own borrowing rate to rise &mdash; the two fears trumpeted by the right since the start. The economy&rsquo;s seeming immunity to QE is the vast, unappreciated benefit of the US dollar being the &ldquo;global reserve currency,&rdquo; and the country&rsquo;s (so far) spotless record for honoring its debts, Tea Party brinkmanship and drunken sailor pork barrel spending aside.


Edwin (2019/08/18 04:13:19):

I've only just arrived japan xnxx Both Miller and Howard say one of their greatest regrets is that younger blacks, who might have pursued work as financial advisers, chose other career because a reputation for discrimination in the industry.


Post a comment