Idea

Mischa Spelt avatar image
1 Like"
Mischa Spelt suggested Phil BoBo edited

unshift() autocomplete bug

Bug: The code completion for Object.inObjects, centerObjects and outObjects shows an unshift method. It does not really make sense, I guess this is a copy/paste error from the Array interface.

Suggestion: Since the InObjectArray and friends seem to be derived from Array anyway, I was thinking it would be cool to have an indexOf function so we can get rid of the confusing ipopno and opipno:

Object source = model.find( "Source1" );
Object queue = model.find( "Queue34" );
int ipopno = source.outObjects.indexOf( queue );
_ASSERT( ipopno > 0 && source.outObjects[ ipopno ] == queue );

int opipno = queue.inObjects.indexOf( source );
_ASSERT( opipno > 0 && queue.inObjects[ opipno ] == source );
bug reportarrayfeature requestdot syntax
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Comment

Phil BoBo avatar image
3 Likes"
Phil BoBo commented Phil BoBo edited

Yes, the unshift() method in the autocomplete looks like a bug.

As for your ipopno() suggestion: adding an indexOf() is a good suggestion that we will add to the dev list, but ipopno() and opipno() don't do what your suggestion does.

ipopno() tells you the output port number that is connected to the input port of the object. Your suggestion gets you the opposite: it tells you about what port number is connected to another object (the return value is a port number on your object instead of the other object). Your example code also has different inputs (two objects) than ipopno() and opipno() (one object and a port number).

The following image shows how ipopno() works in 4 script windows:

The upper-left script shows ipopno()'s usage. It tells you that Queue3 is connected to the third output port of Source4 (the queue's 4th input object).

The bottom-left script shows essentially what the command does, which is calling all O(1) lookup operations. No loops are necessary.

The upper-right script shows what the replacement for ipopno() would look like using the proposed indexOf() command, which actually shows why the command is named ipopno() as shown in the annotations. This is definitely more readable and less confusing than ipopno().

The bottom-right script shows what that replacement would essentially be, which includes a lookup that requires a loop. Thus, it isn't a perfect replacement for ipopno(), but it still could be a useful command none-the-less.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Your Opinion Counts

Share your great idea, or help out by voting for other people's ideas.