http://qs321.pair.com?node_id=645839


in reply to Re^3: Is it ok to mix functional and oo programming in one package?
in thread Is it ok to mix functional and oo programming in one package?

When it works, it is. The problem is that it doesn't always work. new Foo has two barewords, and whenever the Perl parser encounters barewords, it has to guess at what they are. Sometimes it has hints at what those barewords are (if it's encountered declarations of filehandles or subroutines) and it can guess correctly. Sometimes it doesn't have hints, because Perl embraces late binding.

Sometimes it has hints which contradict late binding altogether. There's where you run into problems, because you have to know exactly which hints matter and when the parser knows about them to diagnose and correct the problem.

Alternately, you could use a syntax which isn't ambiguous to the parser and has the benefit of clarifying what exactly happens (new not being a keyword in Perl as it is in some other languages with OO systems).

Replies are listed 'Best First'.
Re^5: Is it ok to mix functional and oo programming in one package?
by ikegami (Patriarch) on Nov 08, 2021 at 17:58 UTC

    I don't think there's any guessing. If there is, let me know so I can fix this.