FEATURE_INHERITED_PARENTSCRIPTS

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, LCMark

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

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by mwieder » Tue Aug 06, 2013 7:28 pm

Code: Select all

-- context
switch me
  case this me
    break
  case some other me
    break
  case not me
    break
  case knock knock
    answer "who's there?" with banana
    break
end switch

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 » Wed Aug 07, 2013 12:14 am

I like how we are gradually implementing multiple personality disorder with behaviors and now this me... Maybe we need a personality property so we can work out the current list of behaviors an object has? ;-)
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by mwieder » Wed Aug 07, 2013 4:57 am

I'd like to propse an ES_BAD_BEHAVIOR return code in parsedefs.h... :-)

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 » Wed Aug 07, 2013 6:29 am

Yes and the message should say "That behavior is unnaceptable, go to your room." ;-)
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1033
Joined: Thu Apr 11, 2013 11:27 am

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by LCMark » Wed Aug 07, 2013 9:42 am

:)

On a more serious note, would 'this script' be better? It would help reinforce the idea that behaviors are just scripts and perhaps fit better with contexts where the script of an object is being used rather than the object itself (e.g. frontscripts, backscripts).

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 » Wed Aug 07, 2013 12:31 pm

The problem with this script is that the whole point is to get an object reference... That's why I originally suggested scriptObject.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1033
Joined: Thu Apr 11, 2013 11:27 am

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by LCMark » Wed Aug 07, 2013 12:44 pm

The problem with this script is that the whole point is to get an object reference... That's why I originally suggested scriptObject.
Well, 'this script' would return an object reference - although I guess it might cause confusion as (at first glance) it might look like it returns the script that is executing (as in the text of the script), rather than a reference to the 'script object'. Perhaps 'the scriptObject' would be better - but it just seems a little clunky.

I must confess I did think 'this me' was a serious suggestion - it does actually seem to work quite well cognitively (for me at least - or should that be 'this me' - I'm not sure which behavior I'm running at the moment)... It also adds a little bit of 'quirk' and perhaps humour. Do you think it's worth pulling in 'this me' into 6.1.1 and seeing what people on the lists say? It might shake loose a few suggestions, comments and such if the syntax is actually there and works.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1033
Joined: Thu Apr 11, 2013 11:27 am

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by LCMark » Wed Aug 07, 2013 1:26 pm

Decided to merge 'this me' into release-6.1.1 so it will be in 6.1.1-rc-2... Let's see what people say :)

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 237
Joined: Sun May 27, 2007 8:19 pm

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by Martin Koob » Wed Aug 07, 2013 2:11 pm

Regarding 'this me'

As I understand it from the thread 'this me' is supposed to refer to the button that owns the behaviour but without reading the thread I am not sure I would understand it as that. It actually makes me think of the movie Multiplicity. There are several me's which me are we talking about.

I don't know if this is feasible or not but if you wanted to refer to the owner of an object's behaviour could you use a syntax like 'the owner of my behavior''?

my behavior -> would refer to the behavior script of an object

the owner of my behavior -> would return the button containing the behaviour script if it is a behavior, or the object itself if the control does not have a behavior.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5113
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by jacque » Wed Aug 07, 2013 6:55 pm

I have the same reservations as Martin. In all other respects, "me" refers to the script currently executing. I would interpret "this me" to mean the object that triggered the behavior, not the owner of the behavior. "Owner" is more in line with how I'd interpret things. Or maybe we could use "this control" and avoid the word "me" entirely:

put the long name of this control

I chose "control" rather than "button" in case eventually we can assign behavior scripts to any object. But to be consistent, "this button" should probably resolve correctly too.

I'm not married to this suggestion, but I'm pretty sure "this me" is going to cause confusion because "me" always means the object running the script, and making a single exception for it will throw a lot of people.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 960
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by trevordevore » Wed Aug 07, 2013 7:52 pm

Martin Koob wrote:the owner of my behavior -> would return the button containing the behaviour script if it is a behavior, or the object itself if the control does not have a behavior.
I don't think 'the owner of my behavior' makes sense given the property we are trying to access. Here is why - the purpose of 'this me' is to get a reference to the actual object containing the script that is executing from within that script itself. 'the owner of my behavior' implies the following:

A) You have a control with a behavior assigned to it.
B) You want the owner of the behavior assigned to the control.

I read this as a property you would use from the script that has a behavior assigned to it, rather than within the behavior script itself.

Perhaps another recap of how the property would be used will be useful. Image this scenario - I am distributing a stack that contains all of the behavior for my custom control as well as some supporting behaviors and/or controls that my custom control will need access to while being used. Given the new chained behavior feature a developer might use my custom control in the following way. Tthis is an actual scenario I am using in a project, not theoretical.

Custom Control (a group) [Control 1]
'Developers Extension of Custom Control' button [Control 2] is assigned as a behavior to 'Control 1'. (A behavior implementing some additional behavior developer wants to add.)
'Actual Custom Control Behavior' button [Control 3] is assigned as a behavior to 'Control 2'. (Behavior containing actual custom control implementation.)

When the 'Actual Custom Control Behavior' script is executing 'this me' returns a reference to 'Control 3', while 'me' returns a reference to 'Control 1'. As a custom control developer I can then use the 'this me' reference to determine the card that 'Control 3' is on and reference any other controls or buttons my custom control needs that reside on that card.

Note that there is not (currently) a way to determine the existence of 'Control 2' while executing the script of 'Control 3'. This doesn't bother me as I don't have a scenario where you would need to know that.

Now, I am not arguing that 'this me' is the best syntax. I'm merely pointing out why I don't think 'the owner of my behavior' (or something similar) doesn't make sense to me given the purpose of the property.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

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

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by mwieder » Wed Aug 07, 2013 9:50 pm

@trevor- good points, but
I read this as a property you would use from the script that has a behavior assigned to it, rather than within the behavior script itself.
I've been thinking that the <whatever> property would be used from within the behavior script.
Maybe there are two different situations in which we need to identify the parent object?

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 237
Joined: Sun May 27, 2007 8:19 pm

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by Martin Koob » Wed Aug 07, 2013 10:24 pm

Thanks Trevor for the explanation. Still trying to get my head around linked behaviors and it feels like "Who's on first? I don't know. Third base!" Your example helps to clarify it.

How about this? Me refers to the control's context. Mine would refer to the context of the behavior.

on mouseUp
--return control's context
put the short name of the owner of me into tControlCard --get the card the control is on
put the cLevel of me into tThisProperty --get the property of the control

--return behavior's context
put the short name of the owner of mine into tBehaviorCard --get the card the behavior is on
put the cLevel of mine into tBehaviorProperty --get the property of the behavior
end mouseUp

There would still be a need to explain to users the difference between 'me' and 'mine' but the sentences with 'of mine' are more english like than 'of this me'

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 » Thu Aug 08, 2013 3:45 am

Re-reading the thread and the different options that have been proposed I think I like this behavior the most. It doesn't work outside the behavior script context but then again it probably doesn't need to. I just realised that the scriptObject could get confusing if we ever get OOP...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by mwieder » Thu Aug 08, 2013 5:34 am

Jim Lambert proposed "the effective me",

but how about "myself"?

Post Reply

Return to “Engine Contributors”