* [ruby-core:49263] [ruby-trunk - Feature #7339][Open] Version of super that doesn't raise when super undefined
@ 2012-11-12 20:31 prijutme4ty (Ilya Vorontsov)
2012-11-12 20:37 ` [ruby-core:49264] " Nathan Broadbent
2012-11-12 21:31 ` [ruby-core:49266] [ruby-trunk - Feature #7339][Rejected] " marcandre (Marc-Andre Lafortune)
0 siblings, 2 replies; 3+ messages in thread
From: prijutme4ty (Ilya Vorontsov) @ 2012-11-12 20:31 UTC (permalink / raw
To: ruby-core
Issue #7339 has been reported by prijutme4ty (Ilya Vorontsov).
----------------------------------------
Feature #7339: Version of super that doesn't raise when super undefined
https://bugs.ruby-lang.org/issues/7339
Author: prijutme4ty (Ilya Vorontsov)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
=begin
I propose new method try_super (it's possibly bad name, any suggestions) which would work like a super except not raising in case that super method undefined. It can be useful in such a situation - when module makes smth useful even in absence of super class.
I use an example with Module#prepend, but similar example with Module#include can be created with a bit more effort.
module MyLogging
def info(*args)
$stderr.puts "Hello! You've an info message"
super # with super it raises when super undefined
end
end
require 'logger'
class Logger
prepend MyLogging
end
class Foo
prepend MyLogging
end
Logger.new.info 'message'
Foo.new.info 'message'
In an example Foo.new.info raises an exception while really it shouldn't in my opinion. So try_super can be used
If it doesn't broke many libraries (I believe not many of them uses super in cases when it raises), super can be renamed to 'super!' and more mild version can be 'super'.
=end
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:49264] Re: [ruby-trunk - Feature #7339][Open] Version of super that doesn't raise when super undefined
2012-11-12 20:31 [ruby-core:49263] [ruby-trunk - Feature #7339][Open] Version of super that doesn't raise when super undefined prijutme4ty (Ilya Vorontsov)
@ 2012-11-12 20:37 ` Nathan Broadbent
2012-11-12 21:31 ` [ruby-core:49266] [ruby-trunk - Feature #7339][Rejected] " marcandre (Marc-Andre Lafortune)
1 sibling, 0 replies; 3+ messages in thread
From: Nathan Broadbent @ 2012-11-12 20:37 UTC (permalink / raw
To: ruby-core@ruby-lang.org
[-- Attachment #1: Type: text/plain, Size: 1676 bytes --]
We can already write:
super if defined?(super)
I don't think a shortcut would be necessary for that, since it's already
quite short.
Best,
Nathan
On Tuesday, 13 November 2012, prijutme4ty (Ilya Vorontsov) wrote:
>
> Issue #7339 has been reported by prijutme4ty (Ilya Vorontsov).
>
> ----------------------------------------
> Feature #7339: Version of super that doesn't raise when super undefined
> https://bugs.ruby-lang.org/issues/7339
>
> Author: prijutme4ty (Ilya Vorontsov)
> Status: Open
> Priority: Normal
> Assignee:
> Category:
> Target version:
>
>
> =begin
> I propose new method try_super (it's possibly bad name, any suggestions)
> which would work like a super except not raising in case that super method
> undefined. It can be useful in such a situation - when module makes smth
> useful even in absence of super class.
> I use an example with Module#prepend, but similar example with
> Module#include can be created with a bit more effort.
>
> module MyLogging
> def info(*args)
> $stderr.puts "Hello! You've an info message"
> super # with super it raises when super undefined
> end
> end
>
> require 'logger'
> class Logger
> prepend MyLogging
> end
>
>
> class Foo
> prepend MyLogging
> end
>
> Logger.new.info 'message'
> Foo.new.info 'message'
>
>
> In an example Foo.new.info raises an exception while really it shouldn't
> in my opinion. So try_super can be used
>
> If it doesn't broke many libraries (I believe not many of them uses super
> in cases when it raises), super can be renamed to 'super!' and more mild
> version can be 'super'.
>
> =end
>
>
>
> --
> http://bugs.ruby-lang.org/
>
>
[-- Attachment #2: Type: text/html, Size: 2436 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:49266] [ruby-trunk - Feature #7339][Rejected] Version of super that doesn't raise when super undefined
2012-11-12 20:31 [ruby-core:49263] [ruby-trunk - Feature #7339][Open] Version of super that doesn't raise when super undefined prijutme4ty (Ilya Vorontsov)
2012-11-12 20:37 ` [ruby-core:49264] " Nathan Broadbent
@ 2012-11-12 21:31 ` marcandre (Marc-Andre Lafortune)
1 sibling, 0 replies; 3+ messages in thread
From: marcandre (Marc-Andre Lafortune) @ 2012-11-12 21:31 UTC (permalink / raw
To: ruby-core
Issue #7339 has been updated by marcandre (Marc-Andre Lafortune).
Status changed from Open to Rejected
Indeed, `defined?(super)` is probably what you were looking for.
----------------------------------------
Feature #7339: Version of super that doesn't raise when super undefined
https://bugs.ruby-lang.org/issues/7339#change-32823
Author: prijutme4ty (Ilya Vorontsov)
Status: Rejected
Priority: Normal
Assignee:
Category:
Target version:
=begin
I propose new method try_super (it's possibly bad name, any suggestions) which would work like a super except not raising in case that super method undefined. It can be useful in such a situation - when module makes smth useful even in absence of super class.
I use an example with Module#prepend, but similar example with Module#include can be created with a bit more effort.
module MyLogging
def info(*args)
$stderr.puts "Hello! You've an info message"
super # with super it raises when super undefined
end
end
require 'logger'
class Logger
prepend MyLogging
end
class Foo
prepend MyLogging
end
Logger.new.info 'message'
Foo.new.info 'message'
In an example Foo.new.info raises an exception while really it shouldn't in my opinion. So try_super can be used
If it doesn't broke many libraries (I believe not many of them uses super in cases when it raises), super can be renamed to 'super!' and more mild version can be 'super'.
=end
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-11-12 21:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-12 20:31 [ruby-core:49263] [ruby-trunk - Feature #7339][Open] Version of super that doesn't raise when super undefined prijutme4ty (Ilya Vorontsov)
2012-11-12 20:37 ` [ruby-core:49264] " Nathan Broadbent
2012-11-12 21:31 ` [ruby-core:49266] [ruby-trunk - Feature #7339][Rejected] " marcandre (Marc-Andre Lafortune)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).