Hacker News new | past | comments | ask | show | jobs | submit login

"- I'm also personally a fan of the dollar sign."

May i ask why? i think that this makes the languaje very ugly.




Here's a contrived example to demonstrate the value of sigils:

    /* in version x of SFL (Sigil-Free Language) */

    school = get_school("Saint Fred's School For Girls");
    class = get_class(school, "Agricultural Studies", 12);
    yield = get_agricultural_yield(class, "Turnips", 2011);
    printf("The Year 12 Ag Studies class produced %d turnips in 2011", yield);
Now we try upgrading to version x+1 of SFL, which adds object-orientation and concurrency (it was a BIG upgrade!). Now three of the lines in that four-line program contain errors, because "class" and "yield" are no longer valid variable names, having been turned into keywords.

In a language with sigils, that's no problem. It also makes it easier (therefore faster) for syntax highlighting to spot where variables are used, without needing a full dictionary and an exact version number - that makes a difference for me as an Emacs user especially.


While true, it's a very minor deal because the scenario you've described:

- Happens very rarely - Is trivially solved, even in a large codebase


You could just look at that as an argument against keywords, rather than for sigils, ala Smalltalk and Lisp.


I like it as well, it makes it very clear what is a variable and what is some other sort of identifier.


etfb is on the right path, but for me it just feels right. I guess that's just a personal preference, but the dollar sign is a visual indicator that a particular string is a variable, and not a function call.

For me, it makes a big difference in languages like ruby where you could either be calling a method, a monkey-patched method_missing callable, or a property in some scope.


Well, in PHP you already have a mandatory '()' at the end of function call - so it's pretty hard to confuse the two.

Additionally if your language has first class functions, it would feel kind of strange if names of some functions started with $ and others without it.


Good point. If variables can be functions and functions can be represented by variables, variable naming rules would to apply to functions both declared and assigned. Which is to say all functions. The $sigil would have to melt away or be everywhere.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: