![]() | |
![]() |
| | Thread Tools | Display Modes |
#21
| ||||
| ||||
|
|
Csaba Gabor wrote: Let's consider this same question in the PHP world, where it is easier to handle. In PHP land, all statements except the last one must end with ; or }. It doesn't matter because Rice's Theorem doesn't depend on a formal language syntax. The only thing that matters is if it's a general purpose higher level programming language (skipping for now on exact formal definitions of these terms). snip |
|
For a general case finding the right place for the return statement means to algorithmically decide for an arbitrary program with an arbitrary input if it has a return point and then to find that intended return point of it, so, unlike Harris claimed, it is necessary to prove that the halting problem is decidable |
|
and consecutively to resolve the Entscheidungsproblem. |
|
Another option is to write a program that successfully passes the Turing test so having all qualities of a free-will human identity. I guess that either of these three tasks from above is way beyond the humble frames of clj. The future Nobel laureate should post such solution in a serious scientific preprint journals right away ![]() |
#22
| |||
| |||
|
|
Suppose you have some javascript statements in a string. Can you determine whether the entire string is syntactically valid, and if so, the starting position of the last statement? In other words, function lastStatementPos(code) { * // returns the starting position within code of the last * // javascript statement, and -1 if code is not syntactiaclly * // valid. This came up in a different context today, and I thought it would make an interesting exercise. *Csaba Gabor from Vienna |
#23
| |||
| |||
|
|
On Nov 3, 4:21 pm, Csaba Gabor <dans... (AT) gmail (DOT) com> wrote: Suppose you have some javascript statements in a string. Can you determine whether the entire string is syntactically valid, and if so, the starting position of the last statement? In other words, function lastStatementPos(code) { // returns the starting position within code of the last // javascript statement, and -1 if code is not syntactiaclly // valid. This came up in a different context today, and I thought it would make an interesting exercise. Csaba Gabor from Vienna My solution for determining the (position of) the last javascript statement runs along the lines outlined in my Nov. 5 response to Lasse's first post at http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/91262ad01ca356bc/ and also in my response to VK within this thread: http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/2aa9a60623eb5883/ In the below, the term inject will mean to insert code at a given point within a larger block of code and to have it be syntactically valid. Unless I'm forgetting some cases, javascript statements end with either ; or } or a newline. The idea will |
![]() |
| Thread Tools | |
| Display Modes | |
| |