3 ms·
> I don't think "say 1.WHAT" is reasonable syntax in the slightest. The syntax is basically the same as Ruby or Python: # Ruby: puts 1.class # Python:
by epidemian 11y ago
> I don't think "say 1.WHAT" is reasonable syntax in the slightest.
The syntax is basically the same as Ruby or Python:
# Ruby:
puts 1.class
# Python:
print 1L.__type__
The names of the methods are different, and Python needs the L suffix, or wrap the integer around parens `(1).__type__` to avoid it confusing the dot with a float literal. But, besides that, the syntax is the same.
- nosnos 11y agoWhy we also don't use Ruby or Python.
- SwellJoe 11y agoWhat do you use and how does that language do what has been demonstrated here?
- logicallee 11y agoyes, class and __type__ seem very reasonable keywords to me, a yelling WHAT does not. the syntax is the same, except the choice of WHAT. I guess I'm the only one who considers it hopelessly odd. if "object1.class == object2.class" seems like something you might think of. But "object1.WHAT == object2.WHAT" is something that wouldn't occur to me in a million years, and makes me laugh even now that I've written it. I suppose you might disagree.
- kbenson 11y ago__type__ I can understand, but .class seems likely to conflict in those cases where you want a method named class. __class__ seems more consistent to me. In Perl 6, special meta method built-ins are always all caps, specifically because it's not a very reasonable name to choose in most cases, similarly to how python surrounds a name with double underscores. They are special and different, and should appear as such. > But "object1.WHAT == object2.WHAT" is something that wouldn't occur to me in a million years Well, that's good,because you aren't really supposed to be doing that. Rather than getting upset at how Perl 6 looks weird when you map operations directly to how you would do them in another language, it might be better to see if that case actually comes up at all. Maybe the language has other features that support different, possibly better, idioms (or at least better for that language)? Just because Perl 6 and Python are both dynamic languages and have some features doesn't mean you should assume it functions or should be programmed in the same way. I doubt you would make that mistake for something that looked obviously different, like racket, so why jump to those conclusions here just because they look similar in certain aspects.
- epidemian 11y agoclass and __type__ are no keywords here. They are just the names chosen for those attributes/methods. I was just pointing out that what you considered unreasonable syntax was actually pretty common syntax. That the function/method names could be better, I agree. But that's an entirely different matter.
- deleted 11y ago[deleted]
- raiph 11y ago> That the function/method names could be better, I agree. Are you referring to python's choices, ruby's, Perl 6's, or all of them? If you think .WHAT could be better, is it the all caps you dislike or is it use of the word 'what' or both? What would you suggest instead?
- logicallee 11y agoto epidemian, yes, it's what I was referring to, sorry I wasn't more clear. raiph: we're talking about perl 6's two choices for the things you've brought up, that it's in all-caps and that it consists of the contextually nonsense word 'what'. The word "what" is one of the most common English words - so the opposite of a better, explicit choice, like type, class, classtype, etc - and doesn't even mean "what-is" if you read it out loud. 3.WHAT doesn't sound like "What 3 is" - it sounds like "3 - I didn't hear you" or if you're being very generous it means "What is 3?" (asking for its value). You asked what I would suggest? If you want to be really cute and grammatical while sounding like a natural language, here is a suggestion. Instead of WHAT my suggestion is the word STYPE, and read it as though the preceding word had an apostrophe at the end: 3.STYPE, thiswindow.STYPE and so forth. (3's type, thiswindow's type, etc). anyway you asked for a suggesiton, there you have it. I woudn't use it myself though.
- kbenson 11y agoI'm sorry, but that seems somewhat arbitrary to me. When I want to know what an object is, it's very obvious to use .WHAT after you've been exposed to it in my opinion. # perl6 -e 'class Person { has $!initials }; my $p = Person.new( :initials<KAB> ); say $p.WHAT' (Person) As for why all capitals, you can just as easily ask Python why double underscores. In the end, it's all language convention (explained here[1]). Denigrating something just because it's different is not a position I think has merit. If down the line we discover that these were bad choices, at least then there will hopefully be some evidence to point to. > The word "what" is one of the most common English words - so the opposite of a better, explicit choice, like type, class, classtype, etc - and doesn't even mean "what-is" if you read it out loud. 3.WHAT doesn't sound like "What 3 is" - it sounds like "3 - I didn't hear you" or if you're being very generous it means "What is 3?" (asking for its value). If you think WHAT in a programming language is likely to be interpreted as "What? I didn't hear you." then I submit that you are using libraries with very poorly named cutesy methods that the author should have really known better than to use if it ends up in in production. Given the context of a programming language, when would you ever need to call a built in metamethod (because it's all caps...) that meant "I didn't hear you" ? Even when "what" is used in the context of "I didn't hear you" it actually is asking for information (to be repeated), and the "I didn't hear you" is the implicit part (otherwise why would you ask for the same thing be said again?). 1: http://doc.perl6.org/language/mop#Metamethods http://doc.perl6.org/language/mop#Metamethods