Alex--
On Dec 1, 2008, at 7:32 PM, Alex Neth wrote:
> This is factually challenged.
>
> irb(main):028:0> f.readline
> EOFError: end of file reached
> from (irb):28:in `readline'
> from (irb):28
>
> irb(main):001:0> f = File.open("testfile", "w")
> Errno::EACCES: Permission denied - testfile
> from (irb):1:in `initialize'
> from (irb):1:in `open'
> from (irb):1
>
> The reason C uses return codes is because exceptions were not a
> language feature when those libraries were developed, not because they
> are good thing.
I think we need to agree to disagree on this one. I'm not as up to
speed on Ruby's exception structure as C-like languages, but it stands
to reason that there would be similarities. Every time an exception
context is established, a set of unwindable frames need to be created
so your program can basically perform a non-local jump outside its
current execution context while at the same time cleaning up objects
left lying around unfinished all the way up the call stack until the
exception is finally handled. Garbage collection simplifies this
immensely, but doesn't make the overhead go away completely. You are,
therefore, suggesting an implementation decision at the ORM level that
is more memory-intensive and cpu-intensive strategy than simply
returning values.
In many ways, merb *is* a good model because they have tried to make
implementation decisions (down to what ORM if any should be used) that
could sensibly be decoupled from the framework easy to decouple. That
might be a good way to look at error propagation strategies. I think
DataMapper is currently at a point where it is not tied to Ruby's
exception handling. If that's part of your implementation strategy,
wrapping save! (as was previously suggested) is one option. You could
also fork the project and implement save in your preferred style.
You'd probably get most of the goodness of the project in merges. And,
you might be right. Exceptions might be superior in all ways to simple
error returns. That's what's great about Open Source: You can have it
your way and if your was is a better one, people will recognize that.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---