octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #51586] Creating method handle fails using str


From: Kai Torben Ohlhus
Subject: [Octave-bug-tracker] [bug #51586] Creating method handle fails using str2func
Date: Sat, 29 Jul 2017 11:22:47 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36

Follow-up Comment #4, bug #51586 (project octave):

I see, the lazy evaluation was already discussed in bug #31821 and discussed
on the mailing list in 2009.  So this behavior will not be added to Octave, I
guess.

Regarding your patch.  I find your patch useful in the scenario, that you want
to control to use an class overloaded method:


>> noclass = [1 0 -1]
noclass =

   1   0  -1

>> class_p = polynomial (noclass)
class_p =

 1 - X ^ 2

>> fh = str2func ("@polynomial/roots")
fh = @@polynomial/roots
>> roots (class_p)
ans =

  -1
   1

>> roots (noclass)
ans =

  -1
   1

>> fh (class_p)
ans =

  -1
   1

>> fh (noclass)
error: matrix cannot be indexed with .
error: called from
    roots at line 2 column 5


On the other hand, I find this example kind of constructed and is there really
a use case for it, instead of calling the class method directly?  Or does
Octave encourage programmers to adopt "ugly" indirection patterns? ^^

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51586>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]