Is there a doc for naming convention?

150 views
Skip to first unread message

sth4nth

unread,
Oct 10, 2012, 11:51:14 PM10/10/12
to juli...@googlegroups.com
Hi, is there a document for naming convention for Julia function names?

Viral Shah

unread,
Oct 11, 2012, 6:32:33 AM10/11/12
to juli...@googlegroups.com
There are informal conventions that we follow, where type names are in camel case, and function names are all lower case, with underscores. 

-viral

Stefan Karpinski

unread,
Oct 11, 2012, 11:36:58 AM10/11/12
to juli...@googlegroups.com
Jeff hates underscores and as a result most things in Base don't use them. But for long variable names, not using underscores gets pretty out of hand. I was considering having a convention that names in Base, as "primitives" in some sense, have no underscores whereas library code would use the underscore convention. Not sure if that's going to fly, but I have a hard time swallowing just smashing all words together everywhere.

--
 
 
 

John Cowan

unread,
Oct 11, 2012, 12:01:01 PM10/11/12
to juli...@googlegroups.com
On Thu, Oct 11, 2012 at 11:36 AM, Stefan Karpinski <ste...@karpinski.org> wrote:
> Jeff hates underscores and as a result most things in Base don't use them.

I'm not a fan either. For one thing, when you have underlined
hyperlinks in documentation, the underscores in names disappear.

> But for long variable names, not using underscores gets pretty out of hand.
> I was considering having a convention that names in Base, as "primitives" in
> some sense, have no underscores whereas library code would use the
> underscore convention.

I'd rather use the lowerCamelCase convention for long method names,
since we are already using UpperCamelCase for types.

> Not sure if that's going to fly, but I have a hard
> time swallowing just smashing all words together everywhere.

Yes, thatisnotgoodeither.

--
GMail doesn't have rotating .sigs, but you can see mine at
http://www.ccil.org/~cowan/signatures

BobC

unread,
Oct 11, 2012, 12:32:42 PM10/11/12
to juli...@googlegroups.com
Well, Julia could use a non-alpha 'word-name-joiner' character other than '_' to avoid the underlining problem.

IIRC, didn't DEC use '$' for that purpose (in VMS filenames)?  Julia could too!  my$Julia$variable$name = value

It's been too many decades since I used UPPERCASE-ONLY FORTRAN, but I have a whiff of a recollection that we used a joiner character there too...


-BobC

Douglas Bates

unread,
Oct 11, 2012, 12:41:34 PM10/11/12
to juli...@googlegroups.com
On Thursday, October 11, 2012 11:32:42 AM UTC-5, BobC wrote:
Well, Julia could use a non-alpha 'word-name-joiner' character other than '_' to avoid the underlining problem.

IIRC, didn't DEC use '$' for that purpose (in VMS filenames)?  Julia could too!  my$Julia$variable$name = value

It's been too many decades since I used UPPERCASE-ONLY FORTRAN, but I have a whiff of a recollection that we used a joiner character there too...

I think we may be wandering a bit off-topic here but wasn't the ancient FORTRAN convention that you could insert blanks in an identifier?  Of course, there was a maximum of 6 non-blank characters in an identifier so you couldn't exactly write "War and Peace" while constructing an identifier. 

BobC

unread,
Oct 11, 2012, 12:46:21 PM10/11/12
to juli...@googlegroups.com
Duh.  Julia is Unicode: There are a gazillion useful 'joiner' characters.  Pick one (perhaps '˽'), and assign it to Meta/Alt-'_' on your keyboard.

-BobC

Patrick O'Leary

unread,
Oct 11, 2012, 1:04:43 PM10/11/12
to juli...@googlegroups.com
You're assuming there's always a sufficiently-featured editor that you control available, and that your whole workflow is UTF-8 safe. Even if that's true, setting up a keyboard shortcut seems like a pretty silly hurdle to just being able to use Julia effectively (assuming we're talking about things in Base or publicly-shared packages , here.)

(Personally, the fact that you can use dashes in identifiers is one of the things I appreciate about Lisps.)

Tim Holy

unread,
Oct 11, 2012, 1:12:30 PM10/11/12
to juli...@googlegroups.com
On Thursday, October 11, 2012 10:04:43 AM Patrick O'Leary wrote:
> (Personally, the fact that you can use dashes in identifiers is one of the
> things I appreciate about Lisps.)

I vote for *. That's what we use for string concatenation, and so it means
concatenate the name.

Oh wait, you don't think that will risk any confusion with multiplication, do
you? Drat...

--Tim

Patrick O'Leary

unread,
Oct 11, 2012, 1:19:27 PM10/11/12
to juli...@googlegroups.com
On Thursday, October 11, 2012 12:12:34 PM UTC-5, Tim wrote:
On Thursday, October 11, 2012 10:04:43 AM Patrick O'Leary wrote:
> (Personally, the fact that you can use dashes in identifiers is one of the
> things I appreciate about Lisps.)

I vote for *. That's what we use for string concatenation, and so it means
concatenate the name.

Brilliant.
 
Oh wait, you don't think that will risk any confusion with multiplication, do
you? Drat...

(*)(a::Symbol, b::Symbol) = symbol(string(a)*string(b))

eval(:this*:is*:a*:long*:variable*:name)

:D

Harlan Harris

unread,
Oct 11, 2012, 1:19:15 PM10/11/12
to juli...@googlegroups.com
Unicode's pretty cumbersome to type, and risky to read. But there are plenty of unused ASCII characters! I vote for Backspace. The words in your identifiers will literally overlap.

 -Harlan

--
 
 
 

Patrick O'Leary

unread,
Oct 11, 2012, 1:23:19 PM10/11/12
to juli...@googlegroups.com
On Thursday, October 11, 2012 12:19:27 PM UTC-5, Patrick O'Leary wrote:
eval(:this*:is*:a*:long*:variable*:name)

:D
(*)(a::Symbol, b::Symbol) = symbol(string(a)*string(b))

 More from the "don't try this at home" dept.

julia> macro v_str(s)
       symbol(s)
       end

julia> v"this is an arbitrary name"
this is an arbitrary name not defined

julia> v"this is an arbitrary name" = 2
2

julia> v"this is an arbitrary name"
2

Jasper

unread,
Oct 12, 2012, 8:27:16 AM10/12/12
to juli...@googlegroups.com
Why dont we use the Julia set as separator. We just need to ask the
Unicode consortium to add it. It would be great publicity!

Jeffrey Sarnoff

unread,
Oct 12, 2012, 8:59:28 AM10/12/12
to juli...@googlegroups.com
there is an open issue about adopting the convention: postfix '!' to mutable function's names 
https://github.com/JuliaLang/julia/issues/907 (discussion at https://groups.google.com/forum/#!topic/julia-dev/W3vqpy0fSMs/discussion)

I am for it.  And I am using the postfix "!!" for dangerous (unchecked, &tc) functions.

Reply all
Reply to author
Forward
0 new messages