New block idea (detect blocks)

I have a idea for new blocks

Custom Blocks script pic

Custom Blocks script pic 2

Useful if a custom block doesn’t reverse properly and needs a little modification when it’s in a NOT block

If it’s already possible can you show me the Script/JavaScript?

I don't understand this. By the reference to NOT I gather you're talking about predicate blocks? But a Boolean value is either True or False; there's no middle ground. Could you give an example?

untitled script pic 7

It’s the best example I can probably do

I'm so confused!

Why would anyone put that block in the input of a NOT block? That wouldn't make sense. And if it is in a NOT block, how does it help to report all but the first letter of the input? That won't be True or False; it'll be a string.

I think this is a solution in search of a problem.

I think that @r4x has come up with an idea but needs an implementation of it to test if the idea has any merit

E.g - a custom reporter that knows whether its inside a not block or not and changes it behaviour depending on whether it is or not.

There's two main issue with this in Snap!

  1. The fact that the no matter what the custom block reports - the not block will turn it into true or false.

But, maybe if the custom reporter has an upvar variable then that variable could be changed and that variable can be used further down the script (maybe??)

  1. It needs a mechanism for a block to know what it is inside of

Obviously, this isn't available at moment and it might not even be possible at the JS level without a major rewrite.

Alternatively, instead of trying to work out whether your block is inside a not, maybe add an explicit input

image

It doesn’t it just does a additional things but it goes over the report of the block(s) it’s inside of (that is if the custom block even has a report in the script)

Ok but how do I tell people what it does when off? (Also it’s a example, the real block detects if it’s positive or not)

Don't understand what you mean by "when off"

Fully understand - I'm just repeating your example - I know its not real

I meant like whenever it’s false

Do you mean how do you change it from true to false?

The boolean block looks like its fixed but is a real input slot that can be controlled by a variable

image

No not at all

I think I'm running out of ideas as to what it is your after :slight_smile:

It’s so simple I ran out of things to say

:slight_smile:
Sometimes, that is the way with ideas that seem obvious to ourselves - its very hard to explain them to others

So do you mean whenever you see <not (b)> you want to remove the not and just get (b)? To do that you just do <not <not (b)>> since the two NOTs cancel each other out.

@r4x what do you mean by detect blocks though

By whenver it's false do you mean?

[scratchblocks]
if <not (b)> then
...
end
[/scratchblocks]

So if b is false, it results in true so it does it. And if it is true, it results in false so it doesn't do it.

(Or you could do untitled script pic (1) )

And this is not the wise thing to say to moderator if you wanna stay unbanned. :thinking: that's the way to get banned

Okay, this is getting way off topic. Let me try to bring us back...

In functional programming, it's really important that whenever you call the same function with the same input values, you get the same result. That's why we say that RANDOM isn't a function; each time you call it with the same inputs, you get a different value.

So we'd need a really good reason to implement something that breaks that, in which a block decides to give different answers depending on who's calling it. And so far I haven't seen a real example of a good reason. That's why I said your proposal is a solution looking for a problem.