This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-10-24 17:56:52

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Is there a way of..?

I was wondering if there was a way in BYOB to detect if a piece of code can run with no errors, as it would help a lot with what I'm trying to do. Is there a block that can help me with this?


I'm back.
Maybe.

Offline

 

#2 2012-10-24 19:24:47

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: Is there a way of..?

DigiTechs wrote:

I was wondering if there was a way in BYOB to detect if a piece of code can run with no errors, as it would help a lot with what I'm trying to do. Is there a block that can help me with this?

No. This is equivalent to solving the Halting problem, as you could make a script have an error if a simulated turing machine halts.


I don't know much about BYOB, so please correct me.


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#3 2012-10-25 06:16:25

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: Is there a way of..?

Molybdenum wrote:

DigiTechs wrote:

I was wondering if there was a way in BYOB to detect if a piece of code can run with no errors, as it would help a lot with what I'm trying to do. Is there a block that can help me with this?

No. This is equivalent to solving the Halting problem, as you could make a script have an error if a simulated turing machine halts.


I don't know much about BYOB, so please correct me.

I was trying to make a block in BYOB that functions similarly to the pcall in Lua. It stands for 'Protected Call', so if the script inside of a pcall errors, the pcall catches it and returns a status code. It doesn't affect the code status outside of it though.


I'm back.
Maybe.

Offline

 

#4 2012-10-25 07:28:53

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Is there a way of..?

DigiTechs wrote:

Molybdenum wrote:

DigiTechs wrote:

I was wondering if there was a way in BYOB to detect if a piece of code can run with no errors, as it would help a lot with what I'm trying to do. Is there a block that can help me with this?

No. This is equivalent to solving the Halting problem, as you could make a script have an error if a simulated turing machine halts.


I don't know much about BYOB, so please correct me.

I was trying to make a block in BYOB that functions similarly to the pcall in Lua. It stands for 'Protected Call', so if the script inside of a pcall errors, the pcall catches it and returns a status code. It doesn't affect the code status outside of it though.

You can implement catch/throw with call/cc.


nXIII

Offline

 

#5 2012-10-25 08:14:43

DigiTechs
Scratcher
Registered: 2011-04-30
Posts: 500+

Re: Is there a way of..?

nXIII wrote:

DigiTechs wrote:

Molybdenum wrote:


No. This is equivalent to solving the Halting problem, as you could make a script have an error if a simulated turing machine halts.


I don't know much about BYOB, so please correct me.

I was trying to make a block in BYOB that functions similarly to the pcall in Lua. It stands for 'Protected Call', so if the script inside of a pcall errors, the pcall catches it and returns a status code. It doesn't affect the code status outside of it though.

You can implement catch/throw with call/cc.

cc? What BYOB block is that? Is it a custom one?


I'm back.
Maybe.

Offline

 

#6 2012-10-25 13:34:16

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Is there a way of..?

Sorry, I forgot call/cc is only in Snap. I would suggest simply checking for specific errors (e.g. division by zero) with an if-else block.

Last edited by nXIII (2012-10-25 13:34:59)


nXIII

Offline

 

Board footer