On Thu, Jul 23, 2009 at 10:21 AM, Jed Brown <span dir="ltr"><<a href="mailto:jed@59a2.org">jed@59a2.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Matthew Knepley wrote:<br>
> It would be impossible for me to disagree more strongly. A user cannot<br>
> get information that is not setup in the current model. I really do not<br>
> understand your objection, and the Haskell discussion is bizarre. All I am<br>
> suggestion is that we use a better model for remembering what to do.<br>
<br>
</div>If I call MatGetXXX(), I expect to either get a meaningful and usable<br>
result, or get an error.  As I understand your suggestion, I wouldn't<br>
get that unless SetUp had been called.  But I wanted to do something<br>
with that result which means that I will either get a request object (I<br>
keep control of when I do that thing with the result, this will be a<br>
PITA) or I give you a continuation for whatever I wanted to do with it</blockquote><div><br>There is no way we would be doing conintuations. Why even bring this up?<br>This just complicates the discussion and distracts from the main issues.<br>
 <br>The answer is incredibly easy and straightforward. Just like MANY  functions<br>in PETSc, you will not get the correct answer until things have been initialized.<br>This just sounds like arguing for the sake of argument.<br>
<br>  Matt<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
(but then I don't know when it will be executed which is confusing<br>
because the continuation will have side-effects, and it's a PITA to do<br>
continuations in C/C++/etc).  In Haskell, it's possible to maintain<br>
control of side-effects and have sane syntax for all these<br>
continuations, but we don't have (or want to be using) Haskell for this.<br>
<br>
To be concrete, someone is going to do:<br>
<br>
  TSGetSNES<br>
  SNESGetKSP<br>
  KSPGetPC<br>
  PCGetOperators<br>
  MatGetVecs<br>
  /* do something with the matrices and vectors */<br>
<br>
If the objects are not sufficiently set up when this is called, the<br>
current model will give an error which is easy to understand.  With your<br>
model, if we haven't called SetUp(), none of these objects will be<br>
available, so instead we'll pass a continuation for everything to do<br>
with them.  In pseudo-Haskell and skipping the obvious sugar, we'd have<br>
something like<br>
<br>
  TSGetSNES ts (\snes -><br>
    SNESGetKSP snes (\ksp -><br>
      KSPGetPC ksp (\pc -><br>
        PCGetOperators pc (\(a,p) -><br>
          MatGetVecs p (\(x,y) -><br>
            -- do something with a,x,y<br>
          )))))<br>
<br>
The monad that this runs under would be able to control side-effects.<br>
That is, we have a type signature like<br>
<br>
  XXXGetYYY :: x -> (y -> M a) -> M a<br>
<br>
where the monad M controls the side-effects.  Doing this in C would be<br>
insane which means that I must be misunderstanding what you want to do.<br>
<font color="#888888"><br>
Jed<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>