Go to advanced search

by jahboater
Thu Oct 15, 2020 9:11 am
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 373
Views: 14756

Re: A Birthday Present for Fido

So GCC's nested functions are a neat way to contain the scope of things and organize code, as you say. But they are extremely limited when compared to the world of first class functions. The thing is, C is a procedural or imperative language, not a functional language. If I wanted the functional pa...
by jahboater
Thu Oct 15, 2020 12:20 am
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 373
Views: 14756

Re: A Birthday Present for Fido

Not much to be said about that particular cave generator other than it's severely broken, failing to generate a viable cave most of the time. If I had to guess the author's intent it would be this. Generates first time every time and Hamiltonian to boot. Nice! I had to declare exchange() void befor...
by jahboater
Wed Oct 14, 2020 7:14 pm
Forum: General programming discussion
Topic: Missing half the skill?
Replies: 54
Views: 2093

Re: Missing half the skill?

unlike arm however, you can freely mix 16bit and 32bit opcodes, so the compiler can generate denser code by just prefering the lower 16 regs Yes, I was just mentioning a couple of obvious similarities between 32-bit ARM and the S/370 mainframe. In 32-bit ARM mode you can mix 16-bit and 32-bit opcod...
by jahboater
Wed Oct 14, 2020 6:33 pm
Forum: General programming discussion
Topic: Missing half the skill?
Replies: 54
Views: 2093

Re: Missing half the skill?

thagrol wrote:
Wed Oct 14, 2020 6:24 pm
Don't know about the S/370 comparision. I never worked on mainframes.
R14 for the return address, 4 bit register fields that read easily in hex.
Aarch64 now has 5 bit register fields ........
by jahboater
Wed Oct 14, 2020 5:22 pm
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 373
Views: 14756

Re: A Birthday Present for Fido

ejolson wrote:
Wed Oct 14, 2020 4:17 pm
However, to emphasise what I stated above, rather than { and } I still find do, begin and end easier to type--
#define begin {
#define end }

:)
by jahboater
Wed Oct 14, 2020 1:30 pm
Forum: Beginners
Topic: Time keeping on Ras-pi
Replies: 18
Views: 499

Re: Time keeping on Ras-pi

Does raspi have a low power mode? As Dougie says, no. But, you can down clock it and reduce the voltage to some minimal values to reduce the power consumption. It might go as low as 200MHz (arm_freq=200) and perhaps over_voltage=-4 You would have to experiment (edit /boot/config.txt) Turn off the H...
by jahboater
Wed Oct 14, 2020 1:23 pm
Forum: General programming discussion
Topic: Missing half the skill?
Replies: 54
Views: 2093

Re: Missing half the skill?

And I added that the best approach IMO is to give them the answer they immediately want and how to find the answers for themselves in future. That creates a good enough foundation to withdraw or limit support later. I once did a morning a week on a help desk. Sometimes I would pretend that I didn't...
by jahboater
Wed Oct 14, 2020 8:09 am
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 373
Views: 14756

Re: A Birthday Present for Fido

"entry" is not a keyword or reserved word in C. It was a reserved word, but was dropped later on... Not suprising since, Ritchie worked on Multics operating system early on. Old C reference manual . Lots on interesting stuff in that document, thanks for posting. I see that 01289 was a valid octal l...
by jahboater
Tue Oct 13, 2020 11:07 pm
Forum: General programming discussion
Topic: Missing half the skill?
Replies: 54
Views: 2093

Re: Missing half the skill?

There is also code review:-
https://codereview.stackexchange.com/
where code that's posted must be working, and people ask for help improving it.
by jahboater
Tue Oct 13, 2020 11:00 pm
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 373
Views: 14756

Re: A Birthday Present for Fido

I think it might be just ancient history. There were other odd quirks in the past, like:
=+ which they changed to += at some point.
In B, I remember that functions were not recognized as such if there was a gap between the name and the open bracket!
by jahboater
Tue Oct 13, 2020 10:29 pm
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 373
Views: 14756

Re: A Birthday Present for Fido

lurk101 wrote:
Tue Oct 13, 2020 9:05 pm
BTW, return is not a function! It irks when you see something like this: return(0).
Neither are if() while() switch() functions, but they require the brackets.
I have vague memories from B that return() was the same. Maybe a first cut of C did too, I don't know.
by jahboater
Tue Oct 13, 2020 9:01 pm
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 373
Views: 14756

Re: A Birthday Present for Fido

I meant compilers like ICC. Clang copies nearly all of the GCC extensions except nested functions. Surprisingly clang supports the complex extended inline assembler stuff from GCC. I don't know why they don't support nested functions, but its enough reason for me not to use it. (and the messy instal...
by jahboater
Tue Oct 13, 2020 8:57 pm
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 373
Views: 14756

Re: A Birthday Present for Fido

They seem very limited seeing as one cannot return them from where they were created. Why on earth would you want to do that? I have never tried to, nor wanted to, nor see the point of, passing pointers to them outside of their scope. Why have block structure and scope rules if you just want to cir...
by jahboater
Tue Oct 13, 2020 8:45 pm
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 373
Views: 14756

Re: A Birthday Present for Fido

Heater wrote:
Tue Oct 13, 2020 7:53 pm
Clang does not support nested functions in C.
I said tier 1 compilers.
by jahboater
Tue Oct 13, 2020 7:12 pm
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 373
Views: 14756

Re: A Birthday Present for Fido

That is a GCC extension. Not C. GCC is ubiquitous ... and other tier 1 compilers copy GCC. Anyway here is a Python example I found showing the inner function using an outer functions argument. def outer(num1): def inner_increment(num1): # Hidden from outer code return num1 + 1 num2 = inner_incremen...
by jahboater
Tue Oct 13, 2020 6:58 pm
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 373
Views: 14756

Re: A Birthday Present for Fido

A closure/lambda captures variables outside of itself but within it's scope. A function does not. Consider: I thought the normal scope rules apply for nested functions, at least they do in C. Maybe its different in Rust. There are no nested functions in C. I use them all the time in C. That's missi...
by jahboater
Tue Oct 13, 2020 6:14 pm
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 373
Views: 14756

Re: A Birthday Present for Fido

Heater wrote:
Tue Oct 13, 2020 6:06 pm
A closure/lambda captures variables outside of itself but within it's scope. A function does not. Consider:
I thought the normal scope rules apply for nested functions, at least they do in C. Maybe its different in Rust.
by jahboater
Tue Oct 13, 2020 5:13 pm
Forum: C/C++
Topic: questions to libs having a .h file and a .c file
Replies: 48
Views: 1656

Re: questions to libs having a .h file and a .c file

Alas, there are some inconveniences to this approach. For instance, I read that if your code is in single compilation unit, GCC can optimize your code better by 10-15% (CITATION NEEDED, but still conceivable). Do you mean this? -fwhole-program Assume that the current compilation unit represents the...
by jahboater
Tue Oct 13, 2020 5:05 pm
Forum: Troubleshooting
Topic: Pi0W reaching 140°F
Replies: 4
Views: 148

Re: Pi0W reaching 140°F

Also use:

Code: Select all

vcgencmd get_throttled
if it returns anything other than 0x0 its likely throttled (now, or since the last boot) due to over temperature or under voltage.
As JamesH said, very unlikely on a Pi Zero.
by jahboater
Tue Oct 13, 2020 1:30 pm
Forum: Beginners
Topic: In DOS you can use the ESC to clear the command line.
Replies: 7
Views: 253

Re: In DOS you can use the ESC to clear the command line.

This is all GNU readline stuff (the library used for reading text lines from the keyboard) It is very powerful and can do vi or emac's style editing. There is a file ~/.inputrc (or /etc/inputrc) that can configure it. see: man readline for all the details. Near the end of the man page is a full list...
by jahboater
Tue Oct 13, 2020 1:02 pm
Forum: Beginners
Topic: How to download AND extract a .img.xz file?
Replies: 15
Views: 446

Re: How to download AND extract a .img.xz file?

I'm pretty sure that a simple '>' would do it one bit at a time. Its writes with a block size of 8KB (probably BUFSIZ). But likely the speed is limited by the decompress time, as the writes will go straight into memory (the disk cache). Sync must be used afterwards. You can see the I/O reads and wr...
by jahboater
Tue Oct 13, 2020 9:49 am
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 373
Views: 14756

Re: A Birthday Present for Fido

Compilers can do all kind of "evil hackery" under the hood. That's rather a different thing to the surface syntax and semantics that is the language itself. Yes of course. Language defined multiple entry points always count as evil in my book. Imagine the problems the linker has. There is also the ...
by jahboater
Tue Oct 13, 2020 8:39 am
Forum: Other projects
Topic: A Birthday Present for Fido
Replies: 373
Views: 14756

Re: A Birthday Present for Fido

coroutines were always implemented in languages like B and C by using longjmp(). A decent compiler might be said to should implement multiple entry points (sort of!) by "partial inlining". That is, it will inline only that part of the function which is actually used. It only works when it can deduce...
by jahboater
Tue Oct 13, 2020 8:16 am
Forum: Beginners
Topic: Terminal v shell from Python RESOLVED
Replies: 3
Views: 163

Re: Terminal v shell from Python

Shelling out from Python via os.system takes me to a screen much like terminal. What is/are the difference(s) if any? What did you give as the argument to os.system() ??? For example, if I give bash, I just get a normal bash shell:- pi@raspberrypi:~ $ pi@raspberrypi:~ $ pi@raspberrypi:~ $ python3 P...
by jahboater
Mon Oct 12, 2020 10:36 pm
Forum: Beginners
Topic: Is there any executable file that is 100% going to be in /bin?
Replies: 14
Views: 365

Re: Is there any executable file that is 100% going to be in /bin?

kerry_s wrote:
Mon Oct 12, 2020 10:04 pm
why not just do /bin/bash
i figure if it's a bash script & there's no bash your screwed anyways. i've never come across a linux without a bash shell or i don't remember. :D
POSIX mandates that /bin/sh must exist.

Go to advanced search