Any #commonlisp wizards out there?

I'm on a journey to explore the Common Lisp ecosystem and so far so good.

While figuring out which SQL/MySQL system to use, I stumbled across the testsuite for `cl-dbi` where it uses `:|some_string|` to retrieve the value from a result row.

I have run out of ideas on what to search for to find the meaning of `:|somestring|`.

`:a-keyword` is a keyword.
`|a-symbol` is a symbol.

In list `'(id 1 name :name)`, `(getf list 'name)` returns `:NAME`.

In list `'(:id 1 :name :foo)` I can get the value for `:id` using `(getf list :id)`.

But I can't figure out how to do or represent the `:|abc|`-symbol.

@johanmynhardt You can write it exactly like that. It is a way of escaping the characters in a symbol name. A keyword is just a symbol in the keyword package (which happens to have some special behaviour, but that's not relevant here).

There is another way to do the same, escaping each character with a backslash:
:\a\b\c

:\a\b\c and :|abc| are the same keyword. You could also produce it with (intern "abc" "KEYWORD").

Thank you to each participant! That's a lot more participation than I expected... it feels a bit like a lonely road πŸ˜…

Every response was helpful and gave me a better picture. I appreciate it. _tips hat_

@Ardubal @jackdaniel @samebchase @carlozancanaro @cage @sigue @lispm

@Ardubal @jackdaniel @samebchase @carlozancanaro @cage @sigue @lispm

After all the input, it lead me to https://www.lispworks.com/documentation/HyperSpec/Body/26_glo_p.htm#property_list

---
property list n. 1. a list containing an even number of elements that are alternating names (sometimes called indicators or keys) and values (sometimes called properties).
---

`describe` didn't work on a list (or rather a result row) so I used `type-of` and it could only tell me it's a `CONS`. That didn't lead me anywhere at the time.

;; cont'd ...

CLHS: Glossary-Section P

@Ardubal @jackdaniel @samebchase @carlozancanaro @cage @sigue @lispm

;; continue ...

First tried an `ALIST` and that didn't do what I expected. Tried what the description says (list of even number of elements) and voila! Happy days πŸ€“

@johanmynhardt
>
> Thank you to each participant!

You're welcome! :)

Happy hacking!
C.

@johanmynhardt https://www.cliki.net/Case%20sensitivity the pipe syntax allows you to have things like spaces in the symbol name.
CLiki: Case sensitivity

@johanmynhardt The pipes are like string delimiters, but for symbols. They make it so the symbol name is the literal characters between the pipes, with no extra interpretation. This also applies to keywords.

> (symbol-name :hello)
"HELLO" ; note: upper-case
> (symbol-name :|hello|)
"hello" ; note: lower-case
> (symbol-name :|i'm a symbol with spaces|)
"i'm a symbol with spaces"

I wouldn't usually use them for database stuff, though, because SQL is case-insensitive. A table named articles can be referenced as ARTICLES in a query (as long as it's not in quotes), so it's not a problem for (symbol-name :articles) to be "ARTICLES".

@johanmynhardt

> I have run out of ideas on what to search for to find the meaning of `:|somestring|`.

The reader (the part of the software that breaks the code in tokens) when find a ':' run some code that, by default, reads the string until a white space is met, converts to uppercase and interns the string into the package "keyword".

But when the reader find ':|' it reads until the next '|' and intern the string into the package "keyword" without changing case, so for example:

(eq :foo :FOO); β†’ T
(eq :foo :|FOO|); β†’ T
(eq :foo :|foo|); β†’ NIL

Bye!
C.

@johanmynhardt (Tongue firmly in cheek...) :|Abc| is a way to type a string using one extra character.
@johanmynhardt Alternative answer: :|Abc| is a way to use a constant without any of the good compiler warnings that you'd get from mistyping the constant name or the cross references to source locations of the constant. \o/

@johanmynhardt one can ask Lisp about it. DESCRIBE prints a short description of a data object.

CL-USER > (describe :|I woke up early this morning.|)

:|I woke up early this morning.| is a KEYWORD
NAME "I woke up early this morning."
VALUE :|I woke up early this morning.|
FUNCTION #<unbound function>
PLIST NIL
PACKAGE #<The KEYWORD package, 0/4 internal, 7626/8192 external>

Thus it is a symbol in the KEYWORD package.

I thought it was a way to force lower case in common-lisp which is
typically case-insensitive.

Usually keywords are displayed in caps so you don't need to do :|CAPS-KW|

But you need it for :|Lower-case-kw|:

So in cl-cbi it is used to force the case of the table name or
column name.