www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - An new example of the Turing's halting problem

reply Don Clugston <dac nospam.com.au> writes:
You may know the famous Computer Science result that in the general 
case, it's not possible to find out if a computer program will run to 
completion, without running it.
You may also know that for C++ templates, it's not even possible to know 
if compilation will ever finish.
Now that static if works at module scope, we can make an example where
it's not possible to know which files are included in the program.

I've omitted the clever part which attempts to solve a famous unsolved 
mathematical problem :-)

---------
// return true if every even number >2
// is the sum of two primes.
template proveGoldbachsConjecture()
{
     const bool proveGoldbachsConjecture = // ????
}

static if (proveGoldbachsConjecture!()) {
  import celebrate;
} else {
  import hewaswrong;
}
---------------
Jan 27 2006
parent reply Sean Kelly <sean f4.ca> writes:
Don Clugston wrote:
 You may know the famous Computer Science result that in the general 
 case, it's not possible to find out if a computer program will run to 
 completion, without running it.
 You may also know that for C++ templates, it's not even possible to know 
 if compilation will ever finish.
 Now that static if works at module scope, we can make an example where
 it's not possible to know which files are included in the program.
 
 I've omitted the clever part which attempts to solve a famous unsolved 
 mathematical problem :-)
Very cool! Someday perhaps computer programming will get to the point where we don't know anything at all about the code we write ;-) Sean
Jan 27 2006
next sibling parent Georg Wrede <georg.wrede nospam.org> writes:
Sean Kelly wrote:
 Don Clugston wrote:
 
 You may know the famous Computer Science result that in the general 
 case, it's not possible to find out if a computer program will run to 
 completion, without running it.
 You may also know that for C++ templates, it's not even possible to 
 know if compilation will ever finish.
 Now that static if works at module scope, we can make an example where
 it's not possible to know which files are included in the program.
8-O <:-| :-)
 Very cool!  Someday perhaps computer programming will get to the point 
 where we don't know anything at all about the code we write ;-)
 
 Sean
LOL!
Jan 27 2006
prev sibling parent reply James Dunne <james.jdunne gmail.com> writes:
Sean Kelly wrote:
 Don Clugston wrote:
 
 You may know the famous Computer Science result that in the general 
 case, it's not possible to find out if a computer program will run to 
 completion, without running it.
 You may also know that for C++ templates, it's not even possible to 
 know if compilation will ever finish.
 Now that static if works at module scope, we can make an example where
 it's not possible to know which files are included in the program.

 I've omitted the clever part which attempts to solve a famous unsolved 
 mathematical problem :-)
Very cool! Someday perhaps computer programming will get to the point where we don't know anything at all about the code we write ;-) Sean
Yes, and we're asymptotically approaching doing everything with nothing :) -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/MU/S d-pu s:+ a-->? C++++$ UL+++ P--- L+++ !E W-- N++ o? K? w--- O M-- V? PS PE Y+ PGP- t+ 5 X+ !R tv-->!tv b- DI++(+) D++ G e++>e h>--->++ r+++ y+++ ------END GEEK CODE BLOCK------ James Dunne
Jan 27 2006
parent reply Sean Kelly <sean f4.ca> writes:
James Dunne wrote:
 
 Yes, and we're asymptotically approaching doing everything with nothing :)
I once heard programmers described as people who are willing to work very hard to solve a problem once so they never have to deal with it again. So we're apparently so lazy that we're willing to to go extreme lengths to make our lives simple. Kind of a weird dichotomy there ;-) Sean
Jan 27 2006
next sibling parent Chris Sauls <ibisbasenji gmail.com> writes:
Sean Kelly wrote:
 I once heard programmers described as people who are willing to work 
 very hard to solve a problem once so they never have to deal with it 
 again.  So we're apparently so lazy that we're willing to to go extreme 
 lengths to make our lives simple.  Kind of a weird dichotomy there ;-)
"Being lazy may look easy, but its actually quite hard to pull off." -- Chris N-Sauls
Jan 27 2006
prev sibling parent reply pragma <pragma_member pathlink.com> writes:
In article <drdrbn$25ka$2 digitaldaemon.com>, Sean Kelly says...
James Dunne wrote:
 
 Yes, and we're asymptotically approaching doing everything with nothing :)
I once heard programmers described as people who are willing to work very hard to solve a problem once so they never have to deal with it again. So we're apparently so lazy that we're willing to to go extreme lengths to make our lives simple. Kind of a weird dichotomy there ;-)
Its so true. To put it another way, I've always told people that I "displace complexity" for a living. ;) - EricAnderton at yahoo
Jan 27 2006
parent reply James Dunne <james.jdunne gmail.com> writes:
pragma wrote:
 In article <drdrbn$25ka$2 digitaldaemon.com>, Sean Kelly says...
 
James Dunne wrote:

Yes, and we're asymptotically approaching doing everything with nothing :)
I once heard programmers described as people who are willing to work very hard to solve a problem once so they never have to deal with it again. So we're apparently so lazy that we're willing to to go extreme lengths to make our lives simple. Kind of a weird dichotomy there ;-)
Its so true. To put it another way, I've always told people that I "displace complexity" for a living. ;) - EricAnderton at yahoo
I like that! :) Yes, I'm always trying to find general solutions to problems so that I never have to 'fix' them again. I'd rather take longer to write a program to do a repetetive task than to suck it up and do it manually. -- Regards, James Dunne
Jan 27 2006
parent reply "Walter Bright" <newshound digitalmars.com> writes:
"James Dunne" <james.jdunne gmail.com> wrote in message 
news:drf1rv$fqb$1 digitaldaemon.com...
 I like that! :)  Yes, I'm always trying to find general solutions to 
 problems so that I never have to 'fix' them again.  I'd rather take longer 
 to write a program to do a repetetive task than to suck it up and do it 
 manually.
It's why I stink at playing chess. Instead of thinking about my next move, I keep thinking about how to write a program to do it for me <g>.
Jan 28 2006
parent reply Dawid =?UTF-8?B?Q2nEmcW8YXJraWV3aWN6?= <dawid.ciezarkiewicz gmail.com> writes:
Walter Bright wrote:

 
 "James Dunne" <james.jdunne gmail.com> wrote in message
 news:drf1rv$fqb$1 digitaldaemon.com...
 I like that! :)  Yes, I'm always trying to find general solutions to
 problems so that I never have to 'fix' them again.  I'd rather take
 longer to write a program to do a repetetive task than to suck it up and
 do it manually.
It's why I stink at playing chess. Instead of thinking about my next move, I keep thinking about how to write a program to do it for me <g>.
I always thought about "bots" for Diablo 1, Diablo 2, Starcraft, Quake, Freeciv etc. That is insane - now I don't play any games except "Go" because it's to hard to write bot for that.
Jan 28 2006
parent Sean Kelly <sean f4.ca> writes:
Dawid Ciężarkiewicz wrote:
 
 I always thought about "bots" for Diablo 1, Diablo 2, Starcraft, Quake,
 Freeciv etc. That is insane - now I don't play any games except "Go"
 because it's to hard to write bot for that.
Go is a great game--so impossibly simple it takes a lifetime to master. Sean
Jan 28 2006