FEATURE_INHERITED_PARENTSCRIPTS

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, LCMark

Post Reply
monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1561
Joined: Fri Jan 13, 2012 1:47 am
Contact:

FEATURE_INHERITED_PARENTSCRIPTS

Post by monte » Sat Apr 20, 2013 8:19 am

Reasons not to turn it on? ... er... um... ??? It's a dream come true...

Test 1 - Protocols/Polymorphism
grandparent button:

Code: Select all

on mouseUp
   answer test()
end mouseUp
parent button:

Code: Select all

function test
   return "hello world"
function test
child button... no code... answers "hello world"

Test 2 - Inheritance ... same code but gradparent and parent code reversed... still answers "hello world"

Test 3 - Overriding ... add a second child and implement test function there:

Code: Select all

function test
   return "hello awesome feature"
function test
answers "hello awesome feature"

In the choice between sliced bread and this... sliced bread comes second... let's get this out there
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2846
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by mwieder » Sun Apr 21, 2013 6:40 am

I really, really want this, but...

have you looked at the executioncontexts when it's enabled? I realize that the groundwork was done to allow this from the start, but it may well play havoc with the debugger. I've got some code ready in PowerDebug but it hasn't been enabled because I'm not sure yet of the repercussions.

Not that I want to dissuade you from doing this, but I think it's better to ease into this one.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1561
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by monte » Sun Apr 21, 2013 6:46 am

Well from the comments it looks like it was implemented 4 years ago so I guess it has been eased in ;-)

Given the feature is already implemented but just not turned on ill let Mark explain the reasoning behind that. If he has his reasons no matter how many pull requests I send it won't make the engine...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2846
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by mwieder » Sun Apr 21, 2013 6:56 am

Yeah, when we first got behaviors I realized that the mechanism was designed to allow for true inheritance, but I'm not sure yet if the engine can untangle that past the first layer.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1561
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by monte » Sun Apr 21, 2013 7:13 am

so you're worried about not knowing where the code is when there's an error?
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2846
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by mwieder » Sun Apr 21, 2013 7:20 am

Basically, yes. The format of the executionContexts is different when there's a behavior script involved. There's an extra parameter at the end of a line if it's in a behavior script. I assume that if more inheritance layers are involved then there would be additional lines in the executionContexts, and they'd follow the same format. In that case it would just be a matter of working down the chain of stack frames. But I don't know if the engine is ready to handle this, and I can definitely say that the revdebugger script isn't up to it.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1561
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by monte » Sun Apr 21, 2013 7:57 am

ok... I just ran a test causing an execution error in the grandparent and it worked fine including stepping through code from parent to grandparent...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2846
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by mwieder » Sun Apr 21, 2013 4:22 pm

Great! That was my one concern. I take it that the local variables maintained their scope as well. Can you try causing an error in a parent script and make sure that the handoff to the error stack is also done smoothly?

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1561
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by monte » Sun Apr 21, 2013 9:20 pm

I didn't check variables... I'll do that when I have a chance.

For the second request isn't that what I did? Or is there a difference between causing an error in the grandparent and parent? I also did breakpoint in parent and it stepped into grandparent.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2846
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by mwieder » Mon Apr 22, 2013 1:19 am

Breakpoints are different from runtime errors. They throw different messages (traceBreak vs errorDialog) and the IDE deals with them differently in that runtime errors are handed off to the stack that displays the error rather than to the debugger.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1561
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by monte » Mon Apr 22, 2013 8:37 am

Hmm.. you want me to do something that causes a runtime error when not in debug mode? Is that it. Debug mode seemed to work fine.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1561
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by monte » Mon Apr 22, 2013 12:31 pm

it all appears to work as expected... would be good if you had a play with it though because you would spot issues with error handling I can't see
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2846
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by mwieder » Mon Apr 22, 2013 6:47 pm

OK - now that Ian's got the 6.0.1 thing settled I'm able to build against the latest changes. Do you have a branch/commit for this? I'm ready to start testing it.

And while we're at it, is there any reason for parentscripts to be limited to buttons? I realize it's traditional now :) , and it would make only a minor difference to extend it, but it makes more sense to me with true inheritance to have fields inherit from fields, etc.

...and on thinking more about this... would that be opening the way for "the effective" whatever to be inherited from parent objects as well? We're getting close to css-like abilities in that case.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1561
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by monte » Mon Apr 22, 2013 9:36 pm

I've got a branch but it's probably faster for your to make one yourself. Just define FEATURE_INHERITED_PARENTSCRIPTS at the top of parentscript.h
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2846
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by mwieder » Mon Apr 22, 2013 10:45 pm

Yeah, OK, I'll do that... I just hate having duplicate paths to merge if not necessary.

Post Reply

Return to “Engine Contributors”