python style triple-double-quotes

291 views
Skip to first unread message

Dan Larkin

unread,
Dec 13, 2008, 4:34:34 PM12/13/08
to clo...@googlegroups.com
Fellow clojurecrats,

I'm here to ask for python style triple-double-quotes syntax in clojure.

For those unfamiliar they're documented here: http://docs.python.org/reference/lexical_analysis.html#strings

This is also a nice summary: http://diveintopython.org/getting_to_know_python/documenting_functions.html

Rich, you said you were considering it in March (http://groups.google.com/group/clojure/browse_thread/thread/8690a80c263d3b52/e8d73aebf11c2698
), did anything ever come of that?


Dan

James Reeves

unread,
Dec 13, 2008, 7:58:12 PM12/13/08
to Clojure
On Dec 13, 9:34 pm, Dan Larkin <d...@danlarkin.org> wrote:
> I'm here to ask for python style triple-double-quotes syntax in clojure.

I'm not completely sure they're needed, to be honest. In Python,
triple quotes have 2 benefits: multi-line quotes and you don't have to
escape quotation marks. In Clojure, normal quotes can already be multi-
line, so the only benefit of this syntax in Clojure would be to save
on backslashes. That might be a worthy goal, I guess, but I've never
found myself using quotes in string literals that often. Maybe I'm an
exception, though.

- James

Dan Larkin

unread,
Dec 13, 2008, 8:06:42 PM12/13/08
to clo...@googlegroups.com
Yes, I'd like the feature because it's a pain in the neck to go
through and escape strings when I know there's a better way.

Also sometimes it doesn't feel right to escape strings... for instance
in function doc strings I'd like to give an example return value. But
if the value has to be escaped to play nice with the docstring it can
get confusing confusing... for me at least. I'd like to put *exactly*
what will be returned.

Dan

Cosmin Stejerean

unread,
Dec 13, 2008, 9:35:29 PM12/13/08
to clo...@googlegroups.com
On Sat, Dec 13, 2008 at 7:06 PM, Dan Larkin <d...@danlarkin.org> wrote:

Yes, I'd like the feature because it's a pain in the neck to go
through and escape strings when I know there's a better way.

Also sometimes it doesn't feel right to escape strings... for instance
in function doc strings I'd like to give an example return value.  But
if the value has to be escaped to play nice with the docstring it can
get confusing confusing... for me at least.  I'd like to put *exactly*
what will be returned.

Docstrings are definitely a perfect use-case for triple quoted strings. +1 on including something similar in Clojure. 

--
Cosmin Stejerean
http://www.offbytwo.com

Martin DeMello

unread,
Dec 14, 2008, 1:29:41 AM12/14/08
to Clojure
On Dec 14, 6:06 am, Dan Larkin <d...@danlarkin.org> wrote:
> Yes, I'd like the feature because it's a pain in the neck to go  
> through and escape strings when I know there's a better way.

For escaping strings, I prefer ruby's solution, which is to have
reader support for arbitrary delimiters, either matched pairs of
brackets - %() %<> %{} %[] - or matched nonalphanumeric characters
like %|| . Could be done in clojure by having a specific reader macro
like #<string indicator><delimiter><string><delimiter>

martin
Reply all
Reply to author
Forward
0 new messages