- Awesome compile-time evaluation proposal - 1 Update
- "The Curious Case of the Longevity of C" - 7 Updates
- Subclass construction - 1 Update
- a linked list with element different types in C++ - 1 Update
- Subclass construction - 1 Update
- std::char_traits and custom character set - 1 Update
Ben Bacarisse <ben.usenet@bsb.me.uk>: Oct 07 12:29AM +0100 David Brown <david.brown@hesbynett.no> writes: <snip> > I did not manage to get gcc to complain about pi and pi2 not being > constexpr, no matter which options I tried. Curious. It turns out to be -fsanitize=undefined that causes this: $ g++ -std=c++14 -fsanitize=undefined -c t.cc t.cc: In function 'constexpr Table makeTable()': t.cc:34:1: error: the value of 'pi2' is not usable in a constant expression } ^ t.cc:10:12: note: 'pi2' was not declared 'constexpr' const auto pi2 = 2 * pi; (And it's an error, not just a warning.) If you make pi2 constexpr, you get the same message about pi. I was not aware that -fsanitize=undefined altered the language that g++ compiles, but it seems to. Maybe g++ detecting and complaining about undefined behaviour in code that is "run" at compile time? <snip> -- Ben. |
Ian Collins <ian-news@hotmail.com>: Oct 07 09:01AM +1300 On 10/ 7/17 06:38 AM, Richard wrote: > $ learn C > at the command prompt to get an interactive tutorial on the language > syntax and writing programs in it. Are you my doppelganger? I spent many an evening on the Uni VAX with K&R on my knee running through "learn C" :) I guess the combination of K&R and "learn" were one of the first forms of interactive learning. -- Ian |
red floyd <dont.bother@its.invalid>: Oct 06 01:50PM -0700 On 10/6/2017 10:38 AM, Richard wrote: > the difference between the address and the data at that address, for > some reason the * syntax threw me off on that first attempt to learn > C. It took me a while, too.... then it hit me... the declaration int *p says that *p is an int. Simple and obvious, but so unclear for quite a while. |
legalize+jeeves@mail.xmission.com (Richard): Oct 06 08:53PM [Please do not mail me a copy of your followup] Ian Collins <ian-news@hotmail.com> spake the secret code >> at the command prompt to get an interactive tutorial on the language >> syntax and writing programs in it. >Are you my doppelganger? Heh :) >I spent many an evening on the Uni VAX with K&R on my knee running >through "learn C" :) For me it was one of UDel's PDP-11/70 running umm.... Sixth Edition, I think? I seem to recall it was a big deal when we got Version 7. <https://en.wikipedia.org/wiki/Version_6_Unix> Their other PDP-11/70 was running RSTS/E which was where I started out programming in BASIC-PLUS. >I guess the combination of K&R and "learn" were one of the first forms >of interactive learning. I bought the book several years later when I got into college as an EE at UDel. I think it was the same year that I learned FORTRAN 77 :). -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://computergraphicsmuseum.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
Ian Collins <ian-news@hotmail.com>: Oct 07 10:25AM +1300 On 10/ 7/17 09:53 AM, Richard wrote: > <https://en.wikipedia.org/wiki/Version_6_Unix> > Their other PDP-11/70 was running RSTS/E which was where I started out > programming in BASIC-PLUS. Bloody hell, you are my doppelganger! That combination was my first exposure to programming (a sixth form diploma) while still at school... I wrote a console text editor with what would now be called intellisense in BASIC-PLUS :) -- Ian |
Keith Thompson <kst-u@mib.org>: Oct 06 03:10PM -0700 > It took me a while, too.... then it hit me... the declaration int *p > says that *p is an int. Simple and obvious, but so unclear for quite > a while. The principle is "declaration follows use". Be aware that the rule should sometimes be taken more figuratively than literally. For example: int arr[10]; says that arr[10] is an int, but in fact arr[10] doesn't exist. Less literally, arr[i] is an int for appropriate values of i. -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister" |
legalize+jeeves@mail.xmission.com (Richard): Oct 06 10:20PM [Please do not mail me a copy of your followup] Ian Collins <ian-news@hotmail.com> spake the secret code >exposure to programming (a sixth form diploma) while still at school... > I wrote a console text editor with what would now be called >intellisense in BASIC-PLUS :) My first major project in BASIC-PLUS was a program that would allow users to submit print jobs into a queue that was processed once a week into a magtape that was walked over to a Xerox laser printer so you could get fancy printouts (with or without UDel seal watermark!). It did a fancy cover sheet ASCII banner and had other options. I really wish I had kept a printout of that program as it was my first real accomplishment. The closest I ever got to writing anything to do with editors was playing around with TECO macros :). -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://computergraphicsmuseum.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
Ben Bacarisse <ben.usenet@bsb.me.uk>: Oct 07 12:17AM +0100 > "The Curious Case of the Longevity of C" > https://www.ahl.com/ahl-tech-the-curious-case-of-the-longevity-of-c Talking of some code from 1987: "Today I can compile and run the code by making only minor changes; register i; is no longer a thing so that piece of nostalgia had to go." There's no need for register declarations to go to compile old code. Implicit int has gone, but then a program from 1987 is likely to be riddled with implicit int so you'd have to use a compiler that supports pre-ANSI C anyway. Anyway, details aside, I don't think there is anything curious about the longevity of C. It was originally a reasonable solution to a particular set of problems and it then hitched a ride on the success of Unix in universities just as university courses in computing were starting out. It got a second wind by being the right size of language (and already designed) when the micro-processor boom occurred. The third wind came with Linux. It's hard to see what other language could reasonably have been chosen for Linux. Very often it's social and economic forces (like the skills of your potential workforce knows) that determine the destiny of computer languages. C# does not exist because it's good, it exists because it's not Java, and it's used because Microsoft promotes it. That does not means it's bad (I have no idea) but the technical merits are very much secondary. The underlying stance of the article is that C is terrible so why is it still around, but that simply misses the point. Internal combustion engines are terrible, so why are /they/ still around? At every point in their history they made sense, often for non-technical reasons. Alternatives programming languages stand a better chance because they don't require vastly expensive global infrastructure to support their use but the basic point remains -- what were the socially and economically viable alternatives for the core tasks that C was used for? > Yup, that is when I started looking at C. I bought TurboC in 1987 ??? > and I was in love. My K&R is inscribed '81, so I was still at university. C was not used at that university so I must have had an eye on my future employment even then. My first job did indeed use C. -- Ben. |
"James R. Kuyper" <jameskuyper@verizon.net>: Oct 06 05:07PM -0400 On 2017-10-06 16:30, Stefan Ram wrote: > |changing the type of the object from the superclass type to > |the subclass type during construction. > What is he talking about? A google search for "circular instance initialization" (the double quotes are important) gives 5 hits, three of which are different copies of the same Java puzzle. I'll let you read that puzzle rather than trying to summarize it. 12.6.2p10 describes the precise order in which parts of an object are initialized. A key provision is that base class constructors get executed before derived class constructors. 12.7p4 says "When a virtual function is called directly or indirectly from a constructor or from a destructor, including during the construction or destruction of the class's non-static data members, and the object to which the call applies is the object (call it x) under construction or destruction, the function called is the final overrider in the constructor's or destructor's class and not one overriding it in a more-derived class." One way to describe this is to say that a object of a derived type only becomes an object of the derived type after all of it's base class constructors have completed. Those two rules combined prevent the problem described in that puzzle from being a problem in C++. At least, that's my understanding. Being used to those rules, and not being particularly familiar with Java, I found the description of that puzzle somewhat confusing. |
Cholo Lennon <chololennon@hotmail.com>: Oct 06 05:55PM -0300 On 06/10/17 05:12, Juha Nieminen wrote: > This may be a bit more cumbersome in C++ because if you want to > store, for example, an int, you'll have to create your own class, > derived from SomeBaseClass, that behaves like an int. I agree with you, that's why (in C++) I tend to use a list of any (or variant). In other languages like Java or Python it's easy to have an heterogenous collection due to a (default) common base class. Regards -- Cholo Lennon Bs.As. ARG |
ram@zedat.fu-berlin.de (Stefan Ram): Oct 06 08:30PM I saw this in a Java book: |The circular instance initialization problem is a can of |worms for language designers. C++ addresses the problem by |changing the type of the object from the superclass type to |the subclass type during construction. What is he talking about? |
bitrex <bitrex@de.lete.earthlink.net>: Oct 06 03:51PM -0400 On 10/06/2017 11:02 AM, James R. Kuyper wrote: > shouldn't try to figure out a way to make std::basic_string do this > implicitly - you should create code that explicitly performs the > conversion your talking about. Thanks for clearing up the stuff in your last paragraph, that makes sense. So say my data type could use char as the fundamental type but had some peculiarities like certain characters should be considered materially equivalent to each other, like capital letters and lowercase for example. Then as I understand it I could public inherit std::char_traits<char> for my own type and just override the methods that do comparison leaving the functions for copying, etc. as is as they would be for a standard ASCII char set. If I then need some custom mapping between what the .data() method of std::basic_string returns and what I need I guess I could just add another static method to my char_traits implementation and call that explicitly? It looks like every method in the class is static and it isn't actually instantiated anywhere. The mapping function could certainly be a free function or a member of something else but it seems logical from an organizational perspective to put it with the rest of the custom implementation. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment