Function return in C - Page 1
Forum section: electronics / beginners

author: rakeshm55
author_rank: Regular Contributor
timestamp: August 21, 2017, 03:54:23 am
content: Hi,I have read in some articles that is recommended to have only one return point for a function rather than having return points at multiple locations.Why is it so?? How does it make the debugging simple??

author: glarsson
author_rank: Frequent Contributor
timestamp: August 21, 2017, 04:07:51 am
content: Quote from: rakeshm55 on August 21, 2017, 03:54:23 amIt is just like a religious belief.

author: goethert
author_rank: Contributor
timestamp: August 21, 2017, 04:19:02 am
content: what do you mean "return point“ exactly?

author: rstofer
author_rank: Super Contributor
timestamp: August 21, 2017, 04:20:36 am
content: The mantra is "one way in and one way out" - a true black box. But rules are meant to be broken and we just had a thread about this last week. One thing about multiple returns, when you are debugging, once you hit a return statement, you don't have to read the rest of the code. The other mantra "get in and get out as quick as you can". This is particularly true for interrupt handlers.

author: Ian.M
author_rank: Super Contributor
timestamp: August 21, 2017, 04:35:44 am
content: It becomes important when a function uses resources that have to be cleaned upproperly. If you follow the single return() at the end of the function paradigm, its much much easier to keep the cleanup code consistent with the setup code as there will only be one instance of it.

author: ataradov
author_rank: Super Contributor
timestamp: August 21, 2017, 04:40:30 am
content: Don't write messy code in a first place, you won't have to clean it up afterwards.I see no point in artificially limiting your use of a language because some freaks said so. If you want to see a parade of BS and pure stupidity, read MISRA-C rules. That's some out of this world experience.PS: That one return point thing is also a part of MISRA-C rules, so sometimes you absolutely have to do that, but only because of bureaucracy, it solves no practical issues.

author: glarsson
author_rank: Frequent Contributor
timestamp: August 21, 2017, 05:04:42 am
content: Quote from: Ian.M on August 21, 2017, 04:35:44 amBut then you have to add code and variables to keep track of what you should clean up. Not to speak about all code and variables added to avoid executing the code between the forbidden return point and the permitted return point at the end (can't have any goats you know).Using only one return point just adds a number of other problems.

author: KL27x
author_rank: Super Contributor
timestamp: August 21, 2017, 05:29:02 am
content: Quote^This is exactly opposite of the case in assembly programming.My code can and will jump around anywhere and everywhere, but quite often I direct multiple exit points of a subroutine into one return for the exact reason Ian.M stated. If you leave multiple exit points, you have to redundantly do the cleaning at multiple points in the code. And if you ever change your code in a way that requires modification of this exit cleanup, now you have to track down and modify each exit point. This is not only redundant, but you have higher chance of missing one and creating what could have been an avoidable bug.I think the single exit point is in general a good idea for code portability. In case you are going to reuse this code, it is easier to describe (in notes to even just yourself, for later) and to implement if you follow this guideline.Exit points are extremely significant things to me, in order to even read my own code. I use specific tabbing/indentation on exit points so I can understand what I'm looking at.This probably has nothing to do with C funtions; sorry for the distraction.

author: IanB
author_rank: Super Contributor
timestamp: August 21, 2017, 05:39:54 am
content: Quote from: rakeshm55 on August 21, 2017, 03:54:23 amSuppose you want to put a breakpoint at the return point of a function. Where are you going to put the breakpoint if there are multiple returns? Suppose you want to trace the execution path through the code, so you log the function on entry and on exit. How will you do that if there are multiple exits?It's true, this doesn't matter for everyone, and some people will dismiss these reasons. But you asked, and here are some possible answers.

author: Mechatrommer
author_rank: Super Contributor
timestamp: August 21, 2017, 06:31:22 am
content: Quote from: glarsson on August 21, 2017, 04:07:51 amwith anyone who lack experience, that is the usual conclusion. there are some reasons to it (similar to an advice of not using goto) as people have mentioned here, but practically sometime its difficult to obey, but it can be usefull as general guideline or something that we need to watch out for... we dont want kids to use unwarranted goto and scattering returns where possible... adults may use it because they know when to use it and when is to not...Quote from: ataradov on August 21, 2017, 04:40:30 amand sometime this is also difficult to implement for some program logic. try to strictly obey this general guidelines will make a bloated code with conditional and other unecessary checking. for some program logic, a quick exit or jump is the way to go (if its verified safe to do so)... ymmv..

author: glarsson
author_rank: Frequent Contributor
timestamp: August 21, 2017, 06:38:12 am
content: Quote from: Mechatrommer on August 21, 2017, 06:29:17 amExperience? I've been programming for as long as you have been alive. Seen lots of bugs caused by misguided rules, like having only one return point, over the years.

author: Mechatrommer
author_rank: Super Contributor
timestamp: August 21, 2017, 06:40:06 am
content: so you should be aware of the reason already. yes its also true "its like a religious belief", but religious lessons also have reasons behind it. its just sometime we can understand it sometime we cant, for some obvious reason

author: AlfBaz
author_rank: Super Contributor
timestamp: August 21, 2017, 06:47:59 am
content: Quote from: rstofer on August 21, 2017, 04:20:36 amWhat about my sieve() function?

author: Kjelt
author_rank: Super Contributor
timestamp: August 21, 2017, 07:54:48 am
content: It is definitely not a (religious) belief, it is a programming paradigm:QuoteOne extension of this paradigm is the early exit*1discussed here.Same with MISRA it has its virtues but also overcomplicated rules but they were created for a reason besides hackling the programmer. If you read the code review of the Toyota begin 2000 and the hundreds of software problems they found you would know there could be good reasons for coding guidelines and paradigms to follow on bigger projects. As long as you are programming your own 8 or 32 bits micro for home projects do what you want, are you programming in a team follow the team/company rules or get sacked.*1see next link at early exit:https://en.wikipedia.org/wiki/Structured_programmingBTW already discussed here:https://www.eevblog.com/forum/chat/opinions-on-coding-style-re-error-handling/msg1281901/#msg1281901

author: ataradov
author_rank: Super Contributor
timestamp: August 21, 2017, 08:10:56 am
content: Have they done a follow up review? I see no indication of MISRA making anything better. Good coding style is a must. But a lot of MISRA is junk, like only having simple for loops with counters starting from 0.A lot of problems MISRA detects are avoidable by turning on warnings in modern compilers and actually reading them.Furthermore, some stuff that MISRA suggests is actively harmful and sabotages compiler error detection.It may have been useful 10-15 years ago, but compilers advanced quite a bit since then.

author: MarkF
author_rank: Super Contributor
timestamp: August 21, 2017, 08:18:20 am
content: Back in the day when almost all code was written in assembly, we had a problem where the computer would crash after 4 to 5 hours of running. It took 2 of us working 16 hours a day for almost a week to find out that a function with multiple exits had one of those exits that left an extra byte on the stack. Since the function didn't exit that way very often, it took hours for the stack to fill up a crash the computer.For complex systems and large routines, it's BAD practice to have multiple exits. Frequently it's a sign of poorly designed and laid out logic. Granted, C doesn't have the issues with stack manipulation but there are lots of other reasons not to have multiple exits. Especially with multiple programmers modifying the code over it's life cycle.

author: AndyC_772
author_rank: Super Contributor
timestamp: August 21, 2017, 08:21:32 am
content: Quote from: IanB on August 21, 2017, 05:39:54 amNormally, if I want to set a breakpoint in a function, it's because either:a) something is going wrong in the function, and I want to stop it when it's failing, orb) I don't necessarily know that something is going wrong, but I want to check what it's doing (or has done) when it's following the normal execution path.I find multiple returns more naturally useful in those cases.

author: tggzzz
author_rank: Super Contributor
timestamp: August 21, 2017, 10:57:01 am
content: You should do whatever makes your code readable andeasily understandableby other people reading your code in the context in which it is invoked.As for using a run-time debugger on code with or without multiple exits, people should turn on higher optimisation levels and see how the compiler mutates the code; spaghetti doesn't even begin to describe it! Such transformations are irrelevant provided that the compiler is correct and all programmers on the project fully understand the language. With C/C++, those are unwise presumptions.

author: bd139
author_rank: Super Contributor
timestamp: August 21, 2017, 11:07:46 am
content: Indeed. C has so much undefined behaviour you occasionally get "oh that was surprising". The optimiser, at least GCC's, mangles the shit out of everything. LLVM/clang is slightly less crazy in that respect. Periodically I go "that was clever" and not "oh my fucking eyeballs"valgrind, test, profile, valgrind, test, profile, valgrind, test, profile. That's the only way.I wrote a basic C compiler back in about 1997 that farted out x86 assembly and you don't realise what a turd the code generation side of it is until you try that. You can create very nice normalised code but the x86 instruction set (as any) is so large that there are so many opportunities for peephole optimisation that your compiler will suck instantly unless you try and use the CPU's neat tricks. 6502 was nice. No tricks needed!

author: alank2
author_rank: Super Contributor
timestamp: August 21, 2017, 12:39:10 pm
content: I often have two returns in a function. One at the end that returns a success, and one somewhere along the way that returns fail. Something that can happen in a function is that may need to cleanup things you have done; for example, if you allocated some memory dynamically using new, you might have to delete it. If you opened a file that shouldn't be open if the function fails, you might have to close it. Here is an example:Code:int myfunc(){char *buffer;FILE *file;buffer=new char;if (buffer==NULL){fail1:return 0;}file=fopen("myfile.txt","rt");if (file==NULL){fail2:delete[] buffer; //must cleanup buffergoto fail1;}if (someotherfailure){fclose(file); //must close filegoto fail2;}//file is no longer neededfclose(file);if (someotherfailure2)goto fail2; //we have unrolled where we need to go back to not include closing the file because it is already closed//everything is done and was successful//cleanup bufferdelete[] buffer;return 1; //success}An alternate approach is to use a single group of code for cleanup and return, but you have to set variables ahead of time to NULL in case they never get allocated and then test to see if they need to be cleaned up...Code:int myfunc(){char *buffer;FILE *file;int ret;buffer=NULL;file=NULL;ret=0;buffer=new char;if (buffer==NULL)goto fail;file=fopen("myfile.txt","rt");if (file==NULL)goto fail;if (someotherfailure)goto fail;//file is no longer neededfclose(file);file=NULL; //we have to set it to NULL so it isn't attempted to be closed a second time belowif (someotherfailure2)goto fail;//everything is done and was successfulret=1;fail://cleanupif (buffer!=NULL)delete[] buffer;if (file!=NULL)fclose(file);return ret;}

author: Kjelt
author_rank: Super Contributor
timestamp: August 21, 2017, 12:52:52 pm
content: Quote from: alank2 on August 21, 2017, 12:39:10 pmIn my book using "goto" is a big no-go , it should never be used.Reading your code you are jumping back and although it looks smart since you only clean what has to be done it is only readable since the rest of the code is lean.If between the fails there are 30 lines of code you have a small disaster in readability for any reviewer.Besides if any of the three failures occur, you only get a single 0 returnvalue, the main cause of the error should be conserved in my book for the calling software to log or handle.But as said earlies as many programmers as many taste in programming, that is why companies have coding guidelines so everyone has the same mindset.

author: Howardlong
author_rank: Super Contributor
timestamp: August 21, 2017, 01:24:47 pm
content: Quote from: alank2 on August 21, 2017, 12:39:10 pmAre you sure? While I'm not generally critical of others' code, I draw the line at that I'm afraid, to say I cringed would be an understatement. Perhaps it wasn't the best example?

author: JanJansen
author_rank: Frequent Contributor
timestamp: August 21, 2017, 01:39:21 pm
content: Dont use goto for sure.Why would someone say not to use return ?, non-sense.

author: screwbreaker
author_rank: Regular Contributor
timestamp: August 21, 2017, 02:55:10 pm
content: GOTO sometimes is useful to make the code more clean and readable.Books generally try to discourage the use of GOTO, due to historical reason. In the BASIC era there are no functions, everything was done by GOTO, so the code are mostly very complicated to read.What you have to keep in your mind is that you have to try to make your code most clean and readable as possible. If more return point or a GOTO can help you to do that, than, use them!There are no contraindications to use GOTO.Same thing for ternary operators, some times they are very useful to make the code short and easy to read, some other times they make things more complicated than a simple IF THEN ELSE.

author: Brumby
author_rank: Unknown
timestamp: August 21, 2017, 03:40:46 pm
content: I'm afraid I would not approve of the use of the goto in that code example.While I support the preference to avoid using the goto, I do not exclude it completely. BUT - I have some very simple guidelines for its use. The first and foremost is that it isalwaysused to branch to a forward point down the code. Never backward. The second is that it is not used in normal program logic - only for exception situations.I've never had to break these yet but, mind you, I haven't been in a position where I needed to consider doing so.

author: danadak
author_rank: Super Contributor
timestamp: August 21, 2017, 03:47:12 pm
content: I am a C lightweight, but I found multiple exits allowed me to reduce un-necessary code execution,overall, and give me a little more HP to apply to other stuff, like display processing. In fact I codedthe f() such that most frequent escapes occured early before other tests for exit. Or maybe I am alousy coder and took a non professional way out. But then we are writing books, pamphlets in somecases, and styles vary....Regards, Dana.

author: Kjelt
author_rank: Super Contributor
timestamp: August 21, 2017, 03:48:02 pm
content: QuoteI disagree, a goto can make code unreadable as the above example demonstrates it can reverse the logical program flow by jumping up , so logically back in the code.It is as saying we are going to write from right to left instead of left to right, which some cultures do btw.Code should flow from top to bottom, functions should be relatively short and easy to understand.If something is an indicator for code that will generate errors in the future and is not maintainable it is code that is not easy to comprehend or readable.Allowing a goto in your coding guidelines will have to be accompanied by more "don'ts" than "do's" , making it again harder to remember so best just to strike it completely IMO.I never used it in the last 25 years so it is perfectly possible to live without

author: Brumby
author_rank: Unknown
timestamp: August 21, 2017, 03:56:35 pm
content: Quote from: Kjelt on August 21, 2017, 03:48:02 pmAbsolutely agree with that - which is why I would only ever use a goto in a forward jump.QuoteI have to admit, I cannot remember when the last time I used a goto .....

author: bd139
author_rank: Super Contributor
timestamp: August 21, 2017, 04:04:57 pm
content: Agree with using it as a forward jump only.TBH in the 3 million lines of code in our main C# based project, we have three gotos and they are "goto case" in state machines. If this was C there would be a LOT more. So it depends on the language as much as the application.

author: gnif
author_rank: Unknown
timestamp: August 21, 2017, 04:08:41 pm
content: Quote from: IanB on August 21, 2017, 05:39:54 amIn this instance I normally put the code into a while loop like soCode:int myFunc(void){while(1){if (earlyExit)break;if (someOtherExit)break;return 1;}return 0;}

author: Mechatrommer
author_rank: Super Contributor
timestamp: August 21, 2017, 04:25:34 pm
content: Quote from: Brumby on August 21, 2017, 03:56:35 pmwhen is the last time you use "if"? thats a forward jump... when is the last time you use "while" and "for"? thats the backward jump. except the language has made them a little bit organized for you

author: Kjelt
author_rank: Super Contributor
timestamp: August 21, 2017, 05:11:22 pm
content: Quote from: Mechatrommer on August 21, 2017, 04:25:34 pmNo that is called a "conditional loop", if you were serious I would advise you to pick up your books again

author: glarsson
author_rank: Frequent Contributor
timestamp: August 21, 2017, 05:34:51 pm
content: Quote from: gnif on August 21, 2017, 04:08:41 pmYou tell the code maintainer that you have an infinite while loop, but then only use it once.You have two ways to leave the infinite loop, break or return.You still have more than one return.You use break to implement a goto.The goto-breaks will break (sic) if the code implementing the functionality of the function happens to use a switch, while or for.This obfuscated code would never make it through code inspection where I work.

author: KL27x
author_rank: Super Contributor
timestamp: August 21, 2017, 05:56:43 pm
content: QuoteWhat do you think a backwards jump is used for, 99.99% of the time? Mechatrommer obviously does not need to be corrected.You do not need a book to know how to use a conditional loop or a backwards jump, and picking up a book to read the name is not going to teach you how to code.I think you're joking, because of the smiley, but it is hard to tell.**To make any kind of loop, the PC is jumping back in the machine code. If you want the code to execute only top to bottom, you have to redundantly add the same code over and over until you run out of space. lol.In general, it is better to write code in such a structure that you CAN ignore some of the details and not get into trouble. But if you remove yourself so far from what is actually happening, you can end up in a situation where you CANNOT write code without following specific structure, because you have no clue what is actually happening. This might be the "best" way to write code for certain complicated project, but there are some things which you will not be able to do effectively/practically due to loss of efficiency and not enough speed and memory in the world to compensate. One should maybe try to remember how to ignore the rules without breaking the code, even if one rarely has to do it. And be conscientious to tidy up these potential sources of error where it does not matter one way or the other, even if you ARE 100% aware of how to write efficient and clear "bad/spaghetti" code, esp because one day you might have to support your own code and on this day you might not be as smart. I treat future me as pretty dumb. If you have a section of code with one entry, one exit, and documented with memory/stack usage, it has this advantage: no matter how complicated it is, even if you can't figure out how it works to save your life, because whoever wrote it (including past you) is smarter (or just has totally alien thought process and code style) than (present) you, you can more easily remove and rewrite the entire section without fucking up something else.

author: IanB
author_rank: Super Contributor
timestamp: August 21, 2017, 06:05:03 pm
content: Quote from: Brumby on August 21, 2017, 03:40:46 pmA third point would be not to jump inside a block from outside.

author: alank2
author_rank: Super Contributor
timestamp: August 21, 2017, 06:22:11 pm
content: You guys are tough! I remember being taught pascal where goto wasn't an option and it is hard to argue with the program flow that comes out of that. I fully agree with you guys that an entire program written around goto is a disaster. At the same time, I don't think loops are "the end all be all" either. Sometimes loops are very counter intuitive to what you are trying to accomplish. To force oneself to use them when they are not ideal - what good is that when it is just going to be compiled to a JMP anyway...

author: bd139
author_rank: Super Contributor
timestamp: August 21, 2017, 07:50:59 pm
content: Hey I've written something quickly that will make you puke:1. It uses a poor clone of pascal syntax simply because I hate pascal.2. It's written entirely in ANSI C3. It actually compiles and executes.4. It implements goto but doesn't actually use goto therefore making this entire problem a non issue as you can hand over your compiler transcripts5. It's just horrible.Have funCode:#include <stdio.h>#define begin int _u=0;while(1){switch(_u){default:#define end }}#define label(x) case(x):#define goto(x) _u=x;break;#define exitprogram return 0;#define writeln(x) printf(x);#define program int main(int argc, char *argv[]) {#define endprogram }programbegingoto(010101101);label(011101101)writeln("Goto ");goto(001001101)label(011001101)writeln("EEVblog ");goto(011101101)label(001001101)writeln("Rocks!\n");exitprogramlabel(010101101)writeln("Hello ");goto(011001101)endendprogramIncidentally if you want to hire me to not write shit this bad, PM me as I've had enough of my current jobEdit: make it more disgusting.

author: glarsson
author_rank: Frequent Contributor
timestamp: August 21, 2017, 08:22:23 pm
content: Quote from: bd139 on August 21, 2017, 07:50:59 pmNo. The variable _u invades the namespace of the implementations. Any symbol starting with underscore followed by a letter or number is reserved for use by the implementation (compiler, runtime libraries etc).

author: bd139
author_rank: Super Contributor
timestamp: August 21, 2017, 08:27:22 pm
content: Fair point. For ref I compiled with following flags. No warnings:Code:gcc -ansi -Wall -pedantic pisstake.c -o pisstakeviaCode:CFLAGS="-ansi -Wall -pedantic" make pisstake

author: glarsson
author_rank: Frequent Contributor
timestamp: August 21, 2017, 08:35:40 pm
content: Quote from: bd139 on August 21, 2017, 08:27:22 pmNever seen a compiler give warning for that. Probably because the compiler must be able to parse system include files without complaining about it.Same when user code uses symbol names like "strange" and "strut" after including strings.h.

author: bd139
author_rank: Super Contributor
timestamp: August 21, 2017, 08:37:19 pm
content: Yeah I suppose those are pulled in by the preprocessor anyway so there's no context so see whom it belonged to by the time the compiler does it's first pass.

author: Howardlong
author_rank: Super Contributor
timestamp: August 21, 2017, 10:08:54 pm
content: Hmm, interesting, I've used single underscores to identify global variables in my own code since the late 80s. I've always been aware that the compiler uses double underscores. It came from a book I was reading on Windows API programming around 1989, and that, along with a slightly modified and extended Hungarian notation is what I've used in my own C code ever since, although I realise Hungarian notation fell out of popularity a couple or decades ago ;-)Edit: looks like I get away with it as the rule for ANSI C apparently is that two leading underscores are reserved, as is one underscore followed by an upper case letter. In Hungarian notation, the first letter of a variable is always lower case.I'd imagine the example _u therefore is also legal, it being a lower case "u".

author: Mechatrommer
author_rank: Super Contributor
timestamp: August 22, 2017, 12:05:51 am
content: Quote from: Kjelt on August 21, 2017, 05:11:22 pmif it happens that a language inventor in the book want to call it chicken then it will be called "conditional chicken". machine only can do jump and skip... can machine encapsulate?btw if goto and return is so bad, they should have made it unavailable in their language syntax list... just like you cant alloc(), "new" or use pointer in ada/java/phyton/pascal...

author: Kjelt
author_rank: Super Contributor
timestamp: August 22, 2017, 07:04:44 am
content: Quote from: Mechatrommer on August 22, 2017, 12:05:51 amWell if you look at the K&R bible they make explicit difference between Iteration statements (while,do,for) and Jump statements (goto,continue,break,return) where they explicitly mention they don't use goto in their book and only see a valid use case for a goto statement in an exception occurring inside a two or multiple loop statement to break out directly.

author: glarsson
author_rank: Frequent Contributor
timestamp: August 22, 2017, 07:37:10 am
content: Quote from: Mechatrommer on August 22, 2017, 12:05:51 amWhy do you think you can't use pointers in Ada? Look for access types and access attribute.

author: Brumby
author_rank: Unknown
timestamp: August 22, 2017, 12:15:02 pm
content: Quote from: IanB on August 21, 2017, 06:05:03 pmInto or out of (ie past the local proximity).That did cross my mind when writing that post - but it is so fundamentally wrong, I didn't think it necessary to specifically mention.

author: Brumby
author_rank: Unknown
timestamp: August 22, 2017, 12:32:27 pm
content: Quote from: Mechatrommer on August 21, 2017, 04:25:34 pmRidiculous argument. If you really want to get silly - let's just cut to the machine code. Every non sequential transfer of control is a jump.The behind-the-scenes of the higher level language is not the issue. What is being discussed is the humancodinglevel.

author: Mechatrommer
author_rank: Super Contributor
timestamp: August 22, 2017, 06:00:58 pm
content: Quote from: Brumby on August 22, 2017, 12:32:27 pmwanna get safe? program in Adaor any highest level programming you can find that doesnt provide goto and return.well i'm not serious and i dont want this thread into language battle anyway... maybe this is my personal preferences i see all language will be translated to machine language anyway, so all these concepts in programming practises is a theoritical matters on the higher level made by the language architects, in the end, we human as the software dveloper needs to take care of it ourself, no grant, even if you program in Ada... a virus injecting your Ada compiled program, you'll have the blue screen of death, or some malicious act in behind, well...

author: tggzzz
author_rank: Super Contributor
timestamp: August 22, 2017, 06:55:20 pm
content: Quote from: Mechatrommer on August 22, 2017, 06:00:58 pmWhy stop there at an externally visible ISA? Why not continue your proposition to the microcode architecture hidden inside many modern processors (or explicitly available in older ones like the HLH Orion)?Why stop there? Why not continue to a register-transfer-level definition?Why stop there? Why not continue to a transistor-level definition?Answer: raising theabstraction levelallows more complex systems to be designed and implemented.So while on a theoretical level transistors can do everything that OOP/functional/logic/relational/FSM/etc language can do, on a practical level there is a very significant difference - and which type of higher-level abstraction can greatly simplify or hinder a system's implementation

author: Mechatrommer
author_rank: Super Contributor
timestamp: August 22, 2017, 11:38:39 pm
content: Quote from: tggzzz on August 22, 2017, 06:55:20 pmbecause i and most hackers can access machine code easily through the App's binary. trying to hack at the hardware level, we need good bunch of heavy stuffs, only the enemy of the state has them, so seldom case is not interesting... plus i dont consider transistor's logic as "programming" at all, they just "tools" to serve our "programming logic", or "software science". plus a transistor cannot jump or skip another transistor by any physical or theoritical means. the idea of jump and skip starts at programming/software logic flow...

author: tggzzz
author_rank: Super Contributor
timestamp: August 23, 2017, 06:39:33 am
content: You completely miss the point of asking that question: look at the context of your original statement and my paragraph beginning "Answer:".Quote from: Mechatrommer on August 22, 2017, 11:38:39 pmThere is little difference between software and hardware. Software is a tool to implement a solution. Hardware is a tool to implement a solution. Often you could use either, often you use both.QuoteLook at the original embodiment of a Turing machine: no transistors but there is a physical skip and jump.Realise you don't need electronics (or even electricity) to implement some programs, especially FSMs - yes, that iscommercially important.