<jhass>
btw so far community standard, if you can call it that, is foo : Type, with a space before the :
<jhass>
your variant trips but the Rubyist in me because it looks like 1.9 style hash syntax or keyword arguments :)
<BlaXpirit_>
" : " is too much to ask
<jhass>
wanted to try at least :P
<BlaXpirit_>
of course, overloading on argument name doesn't work
<BlaXpirit_>
there is only one language i know that has this
<BlaXpirit_>
so i don't know what to do here
<jhass>
how about: def self.from_files(vs_filename, fs_filename); new(load_file(vs_filename), load_file(fs_filename); end;
<jhass>
(var names for brevity here)
<BlaXpirit_>
I have a convention in my lib
<BlaXpirit_>
of course, neither SFML nor CSFML use constructors for this kind of stuff.
<BlaXpirit_>
but i do
<BlaXpirit_>
i should just change everything to class methods...
<BlaXpirit_>
so what's the convention on class methods that act like constructors?
<BlaXpirit_>
or i can google "ruby class methods constructors"
<jhass>
I'm not sure what you're asking for by "convention"
<BlaXpirit_>
naming convention
<jhass>
mh, don't think there's any
<jhass>
use something that seems fit to your domain
<BlaXpirit_>
from your example I can assume it doesn't have any prefix like "create" from file
<jhass>
yeah, we tend to leave of prefixes
<jhass>
for example with accessors: get_foo -> foo, set_foo -> foo=, is_foo -> foo?
<BlaXpirit_>
oh while we're at it
<BlaXpirit_>
if there is a setter foo=, should getter still be called foo?
<jhass>
yes
<jhass>
oh, you mean "foo?"
<BlaXpirit_>
oh sorry, wasn't clear there
<BlaXpirit_>
I mean "foo?"
<BlaXpirit_>
basically i have is_foo, set_foo
<jhass>
we haven't standardized that much yet, in Crystal I can see two conventions for question? methods
<jhass>
if it's a flag or the like, name it foo?, a question? method should always return true or false and have no side effect if possible
<BlaXpirit_>
well sure, it's just that a setter should be named "{{getter}}="
<jhass>
and then in crystal we sort of have the "raise for foo, return nil for foo?" convention, though in stdlib it only applies to #[] and #[]? afaik
<jhass>
ah, yeah, don't do foo?= (I think that's not even valid)
<BlaXpirit_>
it's for that reason that I decided to not use `?` in my lib
<BlaXpirit_>
but i'll add itr
<jhass>
in Ruby I see it 50/50 like this: some provide the accessor only as foo? if it makes sense, some alias the regular accessor to foo?, so you have foo and foo? as the same thing
<BlaXpirit_>
alias, huh
<BlaXpirit_>
isn't it clutter?
<jhass>
Ruby stdlib has many aliases
<jhass>
inject/reduce, select/find_all, find/detect to name just a few
<BlaXpirit_>
i don't like that, now that i think about it
<jhass>
I haven't really settled yet as to which variant I prefer
<jhass>
but actually I think foo? only, if it's a flag, makes sense
<asterite1>
BlaXpirit_: what language has overloads based on args names?
<BlaXpirit_>
nim
<asterite1>
So there you are forced to use args names on the call?
<BlaXpirit_>
yes
<asterite1>
I mean, because of the ambiguity
<asterite1>
Interesting
<BlaXpirit_>
discovered it by accident because of this same mishap that i mentioned
<jhass>
asterite1: btw I really like the idea of being able to use keyword args in the caller for required args too, in fact I wanted to suggest it sometime before you mentioned it
c355E3B has joined #crystal-lang
<asterite1>
Yes, I think I'd like that too. The only downside is that it ties the names to every API
<asterite1>
but I guess you'd use that when you have many (3 or more?) arguments, and so you'll be careful to choose good names
c355E3B has quit [Quit: Leaving]
c355E3B has joined #crystal-lang
a5i has quit [Quit: Connection closed for inactivity]
asterite has joined #crystal-lang
asterite1 has quit [Ping timeout: 250 seconds]
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: http://git.io/vfEXT
<crystal-gh>
crystal/master 340389b Ary Borenszweig: Fixed a case of special vars
HakanD__ has quit [Quit: Be back later ...]
<travis-ci>
manastech/crystal#2255 (master - 340389b : Ary Borenszweig): The build is still failing.