I code in ruby and c++.
I love {} in c++.
I love “do”, “end” in ruby.
That’s just because I am deeply grateful for what both these languages
let me achieve, each in it’s own field.
Gaspard
I code in ruby and c++.
I love {} in c++.
I love “do”, “end” in ruby.
That’s just because I am deeply grateful for what both these languages
let me achieve, each in it’s own field.
Gaspard
Hi,
At Tue, 7 Oct 2008 04:57:45 +0900,
Brian C. wrote in [ruby-talk:317027]:
I find Ruby’s syntax as-is works remarkably well. The only problem it
causes me is with do-end mismatches where the parser just runs off the
end of the file, with no indication of where the missing do or end might
be. I have on many occasions resorted to chopping a copy of my source
file to find the problem (that is, lopping out a class or a method at a
time until the problem goes away)
Python style indentation also can’t help you alone. How can it
know which did you intend?
if x == “ok”:
print “ok”
print “foo”
if x == “ok”:
print “ok”
print “foo”
Personally, the solution I would love to have is a parser/pretty-printer
tool which can read a Ruby source file and spit it back out with
“standardised” indentation. It would then be obvious where the problem
lies. You’d get the benefit of python-style indentation, without
actually having to use python-style indentation
Recent 1.9 warns when it see a mismatch.
$ ./ruby -ve ‘begin
end’
ruby 1.9.0 (2008-10-07 revision 19704) [i686-linux]
./ruby: warning: mismatched indentations: line 1:‘begin’ and line
2:‘end’
Hi –
On Tue, 7 Oct 2008, Frasier M. wrote:
It’s a good way. It’s just that there’re more typings. If you says
"matching end is no harder than }, then } could be an considered as an
option I assume.
That doesn’t follow.
My first thought to use brace “{…}” to replace “END” since it’s a
popular convention.But then it looks like C/Java.
Liking other languages may not be bad. Ruby’s syntax on my first
impression is that it’s similar to python, thinking about the “class” or
“def”. Ruby has evolved by learning merits from other languages.
Yes, to a large extent. But Ruby also is a language. It’s not an
experiment in how to stick different ideas from other languages
together.
Have you written to any C mailing lists, suggesting that C adopt
features from Ruby?
its syntax, some effort may need to be considered on the improvement.
If it’s determined there’s absolutely no room to improve, then that’s
fine.
It’s been discussed a million times over many years, if that’s what
you mean. If Matz were going to remove the “end” keyword, I think he
would have done it by now.
If no improvement will be made in near future, I can live with “END”,
though in my mind I may still have the thought of it and wondering if it
could be made better.Don’t get my wrong. I hope ruby getting better and can attract more
programmers. With this mind, I pointed what I felt, which is shared by
other new comers.
Please don’t put this in terms of Ruby attracting programmers. Ruby
does about as good a job as any language I’ve ever heard of, when it
comes to having programmers like it. Not everyone does, of course, but
Matz has accomplished something truly great and amazing in exactly
that sense. “end” is not a test of whether or not Ruby is an
attractive language, and curly braces are not Ruby’s ticket to
popularity.
In general, the best thing by far is to spend some time with the
language, and let it speak to you.
David
I have to mention in the first line of each post. I agree the idea of
closing a code block with something like “END”, but suggest to use
something else to replace it such as “{ }”.
Have you written to any C mailing lists, suggesting that C adopt
features from Ruby?
If you felt insulted when some people ask if ruby could make improvement
in future on its syntax, I feel sorry for that and think people could be
better off to have an opener mind. Event if I didn’t write to any C
mailing list asking C to improve its syntax, but there are much chances
that some other people had written to Java mailing list ask java to
adopt some nice feature from ruby or other languages. That might be the
reason in jdk1.5 there were some syntax improvement like the adoption of
Generics. In future release, Python might have considered to remove
“self” as suggested by someone who wrote to python mailing list. It’s a
common scenario that suggestions were brought up to ask the possibility
of syntax improvement,just like the first article in this thread posted
by someone else.
It’s been discussed a million times over many years, if that’s what
you mean.
If the “END” will not be considered to be replaced, then I suggest ruby
forum people be better off to add a FAQ page so that to prevent other
people from asking the same question again and again, since probably I
am not the only person who are concerned with the “END”.
“end” is not a test of whether or not Ruby is an attractive language,
It’s a not test, but I, or other may have noticed cases (could be more
potentially) some ruby users’ concerns about “END”, while relatively
fewer people complaining about the curly braces.
I will take other’s advice and use more and get myself familiar with
it.Thank you for your time.
Hi –
On Tue, 7 Oct 2008, Gaspard B. wrote:
I code in ruby and c++.
I love {} in c++.
I love “do”, “end” in ruby.
That’s just because I am deeply grateful for what both these languages let me
achieve, each in it’s own field.
Absolutely. Very few of these “features” really have any absolute
quality of being good or bad, outside of their context.
David
Hi –
On Tue, 7 Oct 2008, Frasier M. wrote:
If the “END” will not be considered to be replaced, then I suggest ruby
forum people be better off to add a FAQ page so that to prevent other
people from asking the same question again and again, since probably I
am not the only person who are concerned with the “END”.
You can’t have a FAQ entry for every aspect of Ruby syntax that
probably won’t be changed
“end” is not a test of whether or not Ruby is an attractive language,
It’s a not test, but I, or other may have noticed cases (could be more
potentially) some ruby users’ concerns about “END”, while relatively
fewer people complaining about the curly braces.
I think that’s because the curly braces are not used, and ‘end’ is.
People don’t complain about things they don’t like that aren’t in the
language
David
Robert K. wrote:
What about you? How open is your mind?
“Open”, as my understanding, is allowing others to say something and not
forbid them. I won’t feel bad, impatient,or angry if other people brings
up suggestions which I don’t agree, and won’t use sarcastic tones to
reply newbie’s messages.
Well, but well thought out suggestions with a realistic perspective of
realization need good understanding of the matter. And with changes in
programming language syntax matters are always quite complicated - if
only for the thousands or millions of lines of code that might be
affected.
That’s true. Agree. It’s just that Mats mentioned during development of
new releases he expressed the intention of improve the ruby syntax.
You can easily search the archives of this list and find out. Note:
you could have done it /before/ jumping right into the next language
change discussion.
I DID the search /before/ this discussion. I didn’t find other
discussion about the replacement of “END”. Sorry. This thread is one of
the closest. (You can try searching the “END” in the forum.) If you know
easier way, please let me and other newbies know so that they don’t jump
in next time.
Thank you for your time.
2008/10/7 Frasier M. [email protected]:
I am kind of new to ruby and like it after looking python first.
[…]
I have to mention in the first line of each post. I agree the idea of
closing a code block with something like “END”, but suggest to use
something else to replace it such as “{ }”.
How about first learning and using the language instead of suggesting
changes right away?
Have you written to any C mailing lists, suggesting that C adopt
features from Ruby?
If you felt insulted when some people ask if ruby could make improvement
in future on its syntax, I feel sorry for that and think people could be
better off to have an opener mind.
What about you? How open is your mind?
Event if I didn’t write to any C
mailing list asking C to improve its syntax, but there are much chances
that some other people had written to Java mailing list ask java to
adopt some nice feature from ruby or other languages. That might be the
reason in jdk1.5 there were some syntax improvement like the adoption of
Generics. In future release, Python might have considered to remove
“self” as suggested by someone who wrote to python mailing list. It’s a
common scenario that suggestions were brought up to ask the possibility
of syntax improvement,just like the first article in this thread posted
by someone else.
Well, but well thought out suggestions with a realistic perspective of
realization need good understanding of the matter. And with changes in
programming language syntax matters are always quite complicated - if
only for the thousands or millions of lines of code that might be
affected.
It’s been discussed a million times over many years, if that’s what
you mean.
If the “END” will not be considered to be replaced, then I suggest ruby
forum people be better off to add a FAQ page so that to prevent other
people from asking the same question again and again, since probably I
am not the only person who are concerned with the “END”.
You can easily search the archives of this list and find out. Note:
you could have done it /before/ jumping right into the next language
change discussion.
I will take other’s advice and use more and get myself familiar with
it.Thank you for your time.
That’s a good course of action.
Regards
robert
It seems that DSLs in Ruby get some of their power from the optional
nature of parenthesis. I wonder if making ‘end’ more optional too
would make DSLs yet more powerful and expressive. It might be an
interesting experiment to see what Ruby would look like if ‘end’ were
optional in places where indentation made it unambiguous. In that
way, it would be consistent with parenthesis being optional.
BTW, the term “domain-specific language” seems inaccurate. Many of
these languages are really double-entendre languages. Their power of
expression seems to come from having two equally good and correct
interpretations - one domain specific and one in Ruby. The double
entendre doesn’t just eliminate clutter, it also eliminates the
mental gymnastics required to translate from one language to another.
"Or consider to use use:
“/* */”, “|…|”, “<…>”, “[…]” , “(…)”, “((…))”, , “//…//”, "
:…: ", " ‘…’ “, "...
" for blocks.”
I can’t stand with the idea of using other chars than braces {} for a
block,
I think it’s particular to ruby to write:
names.each { |name| puts name }
I think do…end is a little long for a small block like this.
"My first thought to use brace “{…}” to replace “END” since it’s a
popular convention."
Well, if you take the braces, you will have to put one just after the
condition(if, else, …)
and “{” is often useless I think. If you indent your code, where will
you
write the “{” ? after the “if” on the same line ? on a new line ?
That’s why I like the “end”, one end for everything, and only one place
if
you indent.
And the syntax “do(sth) if condition” is fast and logical to write.But I
think we should not use this for long lines for readability reasons.
Regards,
Benoit
Nobuyoshi N. wrote:
Recent 1.9 warns when it see a mismatch.
$ ./ruby -ve ‘begin
end’
ruby 1.9.0 (2008-10-07 revision 19704) [i686-linux]
./ruby: warning: mismatched indentations: line 1:‘begin’ and line
2:‘end’
Ooh, that’s nice. Now I have a reason to install 1.9 alongside a
production ruby (although I’ll be very careful to keep the two separate)
Thanks,
Brian.
Yukihiro M. wrote:
But I sometime want “end”-less single line structure (in normal
order), e.g.if foo then bar # pseudo syntax; you may require delimiters
not
bar if foo
especially when I write very small code chunk. Not knowing what
syntax it should be.
As an observation, I always found ruby’s “then” to be a rather
superfluous non-keyword; that is,
if a == b then
…
end
if a == b
… same
end
if a == b then …; end
if a == b; … same; end
So a possible (but highly incompatible) approach would be for “then” to
introduce a single-line block, e.g.
if a == b then puts “hello”; puts “world” # end implied
if a == b
puts “hello”
puts “world”
end
It could also be used, although less obviously, in other constructs:
while !a.empty? then puts a.shift
I’m not sure what ‘then’ followed immediately by newline should do.
Anyway, this is just an idle thought, as it would break lots of things.
On Tue, Oct 7, 2008 at 3:35 PM, Brian C. [email protected]
wrote:
It could also be used, although less obviously, in other constructs:
while !a.empty? then puts a.shift
“while then”? (kinda sounds funny to my ears
And, in this case, is it really better than:
puts a.shift while !a.empty?
Benoit D. wrote:
I can’t stand with the idea of using other chars than braces {} >for a block,
I think it’s particular to ruby to write:
names.each { |name| puts name }
Does it looks a little better if using square brace? since it LOOKs
more like a “block”:
names.each [ |name| puts name ]
I think do…end is a little long for a small block like this.
Agree. do…end is suitable for multiple lines block.
And can curly brace be used replacing “END” while it is kept as it is to
represent blocks? Any parsing difficulty?
where will you write the “{” ? after the “if” on the same line >? on a new line ?
For simplicity reason, I would say put the “{” on the same line of “if”.
Thanks for your reply.
unknown wrote:
“while then”? (kinda sounds funny to my ears
It does. I was just trying to see what happens if you apply the idea
consistently. I guess taken to extremes you’d also get
def f(x,y) then x+y
which I don’t particularly like, but then one-line method definitions
are pretty unusual.
And, in this case, is it really better than:
puts a.shift while !a.empty?
No, not really.
It might be useful for ‘if’ though. I quite often write code with lots
of backwards lines:
something if foo
raise “Error” unless bar
other if baz
and it would be good to write them the right way round. (Although
“unless…then” doesn’t really read well either)
More importantly,
if (x = some_big_calculation) then x.something
can’t be written in backwards form currently.
I posted a message in this thread under the circumstances of:
So basically I asked if other similar experiment would be made in
future. And I wondered if curly braces “{}” could be considered as an
alternative. For blocks, use “do…end” if multiple lines, use other
chars like “names.each [|name| puts name]” for single line.
|Michael S. wrote:
It helps in wider sense: while getting acquainted with a new OS,
or with a university lab people who were there before you.
Lurking and learning what is valued in this community and what
is frowned upon helps getting into being valued and not frowned.
So being patient to suggestions one wouldn’t agree to is respecting
the other side, but being patient to first learn about something
and then ask why things are this way not the other (and only then
suggesting to fix or improve something) is even more so.
I may not be alone. As I said in 2) above, it seems some
more-experienced ruby users had similar concerns.
It probably could but what you suggest is taking one of the worst
design flaws in Python and planting it into Ruby. It is not an
improvement by any measure.
I appreciate the purpose of “END”. I was not suggesting to use python
style from my first post in this thread. Just wondered if there could be
better syntax as an alternative.
BTW Ruby is a nice language in terms of softly understanding OOP
I am excited about ruby,too.
Have you written to any C mailing lists, suggesting that C adopt
features from Ruby?
To be frankly, I can imagine if I haven’t heard of ruby, and if I can’t
find others asking the same question, there are much chances I will send
an email to python group suggesting them to remove the “self” out of
python method argument list. Syntax improvement requests, in my
imagination, is not that an insult to a language, if one consider it’s a
suggestion with a good wish to make it better. Maybe I underestimated
language lovers’ sensitivities.
There’s also a problem of time available. As one proverb would
put it, “one can ask so many questions that thousand wizards
won’t keep up answering”.
I did the search both in Google and the forum, but didn’t find a lot of
discussion about alternative syntax for “END”. Since as David A. Black
said (thanks for his reply, by the way), if similar question has been
discussed “a million times”, a FAQ page might help for both newbies and
rubist to save everybody’s time. A topic discussed a millions times may
suggest it’s controversial, or suggest if there’s room for improvement.
Apologize for my ignorance if I missed anything.
Thank you for your time.
…me too…
On Tue, Oct 07, 2008 at 02:35:10AM +0900, Frasier M. wrote:
I am kind of new to ruby and like it after looking python first.
It might take some time for that particular taste to fade away…
keep on
It’s designed for be friends of programmers. But I feel the
“END” may have a negative role to ruby’s purpose or attraction.
It’s very subjective, you might want to have a look at a dozen
more languages (e.g. Modula-2 also uses END with no problem).
On 18/05/07, Yukihiro M. wrote:
- tab/space mixture
- templates, e.g. eRuby
- expression with code chunk, e.g lambdas and blocks
- clipboards, email, pastebins, and other places where the
code is not preserved literally
…and teamwork is more nasty since there’s one more choke point.
On Tue, Oct 07, 2008 at 11:47:35PM +0900, Robert K. wrote:
How about first learning and using the language instead of
suggesting changes right away?
It helps in wider sense: while getting acquainted with a new OS,
or with a university lab people who were there before you.
Lurking and learning what is valued in this community and what
is frowned upon helps getting into being valued and not frowned.
Or, well, quitting without much ado – that’s better at times.
If you felt insulted when some people ask if ruby could make
improvement in future on its syntax
It probably could but what you suggest is taking one of the worst
design flaws in Python and planting it into Ruby. It is not an
improvement by any measure.
I feel sorry for that and think people could be better off to
have an opener mind.
What about you? How open is your mind?
…e.g. regarding adopting new syntax and comparing it over
a few weeks
I will take other’s advice and use more and get myself
familiar with it.
Good luck, and don’t get frustrated You’ll understand people
who objected after more code behind… both written and read.
On Wed, Oct 08, 2008 at 01:23:10AM +0900, Frasier M. wrote:
“Open”, as my understanding, is allowing others to say
something and not forbid them.
JFYI: some tend to mix up “openness”, “freedom” and “impunity”.
These are all different things, e.g. I’m not particularly “open”
to badmouthing or brutal wording.
I won’t feel bad, impatient,or angry if other people brings up
suggestions which I don’t agree
Wonder if you’ve already tried that couple hundred times on
the same old matter. [for sufficient N of matters if you had]
and won’t use sarcastic tones to reply newbie’s messages.
There’s also a problem of time available. As one proverb would
put it, “one can ask so many questions that thousand wizards
won’t keep up answering”.
So being patient to suggestions one wouldn’t agree to is respecting
the other side, but being patient to first learn about something
and then ask why things are this way not the other (and only then
suggesting to fix or improve something) is even more so.
On Tue, Oct 07, 2008 at 10:25:42AM +0900, Martin DeMello wrote:
I never liked the indentation of Python probably as a result
Actually, the more I write in scheme, the more I like its
structure. It all just works.
It’s not about structure in the first place, functional languages
differ in approach; syntax is an effect, not the cause. See also
http://mitpress.mit.edu/sicp/
BTW Ruby is a nice language in terms of softly understanding OOP
or FP to those who would do C or shell before. IMO much better
than bare C++ or Java (got headaches), or probably LISP (was too
young when put my nose in it for the first time)…
On Tue, Oct 07, 2008 at 07:01:31PM +0900, David A. Black wrote:
Have you written to any C mailing lists, suggesting that C adopt
features from Ruby?
Fortuned, sir!
Jeremy McAnally wrote:
Then you’re introducing a big chunk of parser ambiguity. For example
if a == b then puts "hello"; puts "world" # end implied
Do you mean if a==b puts “hello” AND puts “world” or should you
output “hello” if it’s true and “world” no matter what.
I meant it would be equivalent to
if a == b; puts “hello”; puts “world”; end
(I thought I wrote that out in full)
That would
put a big load on the parser to figure out the different between the
different line delimiters and how that impacts the code around it.
If the rules are clearly defined, parsers are easy to write. It’s
certainly much clearer than many of the existing Ruby parsing rules
Then you’re introducing a big chunk of parser ambiguity. For example
if a == b then puts "hello"; puts "world" # end implied
Do you mean if a==b puts “hello” AND puts “world” or should you
output “hello” if it’s true and “world” no matter what. That would
put a big load on the parser to figure out the different between the
different line delimiters and how that impacts the code around it.
–Jeremy
On Tue, Oct 7, 2008 at 2:35 PM, Brian C. [email protected]
wrote:
especially when I write very small code chunk. Not knowing what
… sameAnyway, this is just an idle thought, as it would break lots of things.
Posted via http://www.ruby-forum.com/.
–
http://jeremymcanally.com/
http://entp.com/
My books:
http://humblelittlerubybook.com/ (FREE!)
Hi –
On Thu, 9 Oct 2008, Ron F. wrote:
The most important thing to have, when learning a new language, is the
flexibility to adapt, the rules, conventions and idioms of that language. The
thing that stands most in the way of learning a language is the stubborn
requirement that all languages operate in the same way. They don’t won’t and
for good reasons.
You might find this interesting:
Another related matter is the recurrent wish for Ruby to become so
flexible, including in its syntax, that it will support any imaginable
programming paradigm and allow redefinition of every operator, literal
constructor, and keyword. That, too, has never made sense to me. For
one thing, and by definition, the world needs only one
pan-paradigmatic, syntax-agnostic language. Once there’s one, there’s
no need for a second one. So then the question becomes: should Ruby
take on that role? Or, to look at it another way: should the existence
of the pan-paradigmatic language necessitate the death of an existing
language? And if so, should the doomed language be Ruby?
Once you look at it that way, turning Ruby into language soup makes no
sense at all.
Anyway, a slightly different train of thought, but your comments
brought it to mind.
David
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs