Wednesday, May 22, 2019

Digest for comp.lang.c++@googlegroups.com - 22 updates in 4 topics

"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: May 22 03:05PM -0700

Have you ever wondered how our societies have gotten so far away
from basic moral goodness, from men and women seeking to do what's
right rather than what's pleasurable or self-gratifying/self-serv-
ing?
 
The founding fathers of America, those men who were intimately in-
volved with the establishment of the United States and its U.S.
Contitution and Bill of Rights, provide insight into our common,
now world-wide fate.
 
They cite a departure from the values which they indicate are an
absolute necessity to maintain civil society. And it's true.
 
When you take God out of the various areas of your life, another
inhabitant is all too willing to take up and fill that void, and
that inhabitant is literally the enemy of God, and the enemy of
you.
 
https://wallbuilders.com/founding-fathers-jesus-christianity-bible/
 
--
Rick C. Hodgin
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: May 22 11:24PM +0100

On 22/05/2019 23:05, Rick C. Hodgin wrote:
> that inhabitant is literally the enemy of God, and the enemy of
> you.
 
> https://wallbuilders.com/founding-fathers-jesus-christianity-bible/
 
Nonsense.
A) Your bible is false.
B) Your god the existence of which is predicated on your bible being true
is, given (A), also false.
 
/Flibble
 
--
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who
doesn't believe in any God the most. Oh, no..wait.. that never happens." –
Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are
confronted by God," Bryne asked on his show The Meaning of Life. "What
will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery
that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a
world that is so full of injustice and pain. That's what I would say."
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: May 22 08:43PM +0100

Hi!
 
It took me just five minutes to add support for escape sequences in an
example programming language's string literal concept:
 
string_literal: {
is: string.utf8
tokens: {
'\"': {
'\"': done
escape: continue
'\\': error
character: continue
}
}
escape: {
tokens: {
'\\': {
'n': character.LF
character.LF: done
'r': character.CR
character.CR: done
't': character.tab
character.tab: done
'\\': character.backslash
character.backslash: done
}
}
}
}
 
Designing new programming languages will be quick and easy with neos the
universal compiler that can compile any programming language! :D
 
/Flibble
 
--
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who
doesn't believe in any God the most. Oh, no..wait.. that never happens." –
Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are
confronted by God," Bryne asked on his show The Meaning of Life. "What
will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery
that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a
world that is so full of injustice and pain. That's what I would say."
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: May 22 09:32PM +0100

On 22/05/2019 20:43, Mr Flibble wrote:
>     }
 
> Designing new programming languages will be quick and easy with neos the
> universal compiler that can compile any programming language! :D
 
The obvious question from those who regurgitate the received wisdom of
"established" compiler theory is most likely "Why aren't you using
Backus–Naur form?"
 
The answer of course is that BNF is all about a programming language's
SYNTAX which is only half of the story: the other half is of course
SEMANTICS! The above schema fragment references two built-in neos
semantic concepts: "string.utf8" and "string.utf8.character" (as
"character").
 
Another reason is that neos is a cleanroom project so I will not be
referencing any established compiler theory during its design so hopefully
the end result will be unique, interesting and perhaps even a game changer.
 
/Flibble
 
--
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who
doesn't believe in any God the most. Oh, no..wait.. that never happens." –
Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are
confronted by God," Bryne asked on his show The Meaning of Life. "What
will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery
that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a
world that is so full of injustice and pain. That's what I would say."
Christian Gollwitzer <auriocus@gmx.de>: May 22 10:45PM +0200

Am 22.05.19 um 21:43 schrieb Mr Flibble:
> [...]
 
> Designing new programming languages will be quick and easy with neos the
> universal compiler that can compile any programming language! :D
 
Now please add algebraic data types, like those found in Haskell:
 
data Tree a = Leaf a | Branch (Tree a) (Tree a)
 
so that you can write a simple recursive function like counting the
leafs in a tree:
 
count (Leaf x) = 1
count (Branch x y) = (count x) + (count y)
 
 
Simple concept, should be easy to do with your universal compiler.
 
Christian
Ben Bacarisse <ben.usenet@bsb.me.uk>: May 22 09:56PM +0100

> }
 
> Designing new programming languages will be quick and easy with neos
> the universal compiler that can compile any programming language! :D
 
Do you have any real-world examples? For example, what do C11's strings
look like in neos? And in languages that can use either ' or " does the
work need to be duplicated? What about languages with arbitrary (and
sometimes non-identical) delimiters like Perl's q(x)? What about
Fortran's counted Hollerith string constants? Python has "..." as well
as """...""" complicated by the fact that adjacent strings are
syntactically possible. How would neos handle "" " """ being three
strings and """ """ being one? (This might be simple in that there
could be a higher-level of tokens that is not shown in your example.)
 
--
Ben.
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: May 22 10:03PM +0100

On 22/05/2019 21:45, Christian Gollwitzer wrote:
 
>     count (Leaf x) = 1
>     count (Branch x y) = (count x) + (count y)
 
> Simple concept, should be easy to do with your universal compiler.
 
Don't worry Christian, Haskell will be one of the languages I will be
shipping neos 1.0 with!
 
/Flibble
 
--
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who
doesn't believe in any God the most. Oh, no..wait.. that never happens." –
Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are
confronted by God," Bryne asked on his show The Meaning of Life. "What
will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery
that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a
world that is so full of injustice and pain. That's what I would say."
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: May 22 10:06PM +0100

On 22/05/2019 21:56, Ben Bacarisse wrote:
> syntactically possible. How would neos handle "" " """ being three
> strings and """ """ being one? (This might be simple in that there
> could be a higher-level of tokens that is not shown in your example.)
 
Hi Ben,
 
The process is to introduce new semantic concepts as and when required as
I implement each language in turn with a view to share as many concepts as
possible across different languages; so to answer your question I will
cross the C11, Fortran, Perl and Python bridges as I come to them.
 
/Flibble
 
--
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who
doesn't believe in any God the most. Oh, no..wait.. that never happens." –
Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are
confronted by God," Bryne asked on his show The Meaning of Life. "What
will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery
that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a
world that is so full of injustice and pain. That's what I would say."
Ben Bacarisse <ben.usenet@bsb.me.uk>: May 22 10:57PM +0100

> concepts as possible across different languages; so to answer your
> question I will cross the C11, Fortran, Perl and Python bridges as I
> come to them.
 
What language are you starting with then? The above does not even cover
old K&R C strings. But I think you would be better off giving at least
two very different real-world examples. Otherwise how can anyone know
that the notation generalises? I suppose more to the point, how can you
know (if you don't try very disparate languages early on) that you have
not boxed yourself into a corner?
 
--
Ben.
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: May 22 11:12PM +0100

On 22/05/2019 22:57, Ben Bacarisse wrote:
> that the notation generalises? I suppose more to the point, how can you
> know (if you don't try very disparate languages early on) that you have
> not boxed yourself into a corner?
 
The schema fragment above is from "neoscript" the neos reference language
of my own design. neoscript aside the first two languages I currently plan
to implement are Java and Haskell which couldn't be any more different.
 
/Flibble
 
--
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who
doesn't believe in any God the most. Oh, no..wait.. that never happens." –
Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are
confronted by God," Bryne asked on his show The Meaning of Life. "What
will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery
that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a
world that is so full of injustice and pain. That's what I would say."
Bart <bc@freeuk.com>: May 22 10:50PM +0100

On 21/05/2019 23:46, Mr Flibble wrote:
> neoscript]
 
> I am quite happy with a compilation speed of 30ms for this but there are
> no doubt further optimizations I can make.
 
This program is too small to accurately measure compilation speed (and
most of it is likely to be all that verbose output if that is part of
the process).
 
I have a simple test which can give an idea of how a compiler copes with
lots of lines containing the same thing:
 
https://github.com/sal55/qx/blob/master/compilertest.txt
 
You need to provide your own input, which at minimum will be 20,000
lines of 'a=b+c+d;' within a suitable framework, eg. a function with
declarations for a,b,c,d.
 
That's if you wish to compare with my own figures for other compilers,
although those are specific to my machine. But you'll have to disable
that logging output.
 
If 20K lines is too much, then start much smaller. (One highly recursive
'parser-combinator' someone posted on c.l.c, just about managed 5 lines;
with 6, it exhausted the 8GB memory in my machine.)
 
With some compilers, this test is unsuitable because having that much
code in one function gives problems, because of the way it's implemented.
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: May 22 10:56PM +0100

On 22/05/2019 22:50, Bart wrote:
 
> This program is too small to accurately measure compilation speed (and
> most of it is likely to be all that verbose output if that is part of the
> process).
 
The 326 ms is the time to compile the same program but with displaying all
those emit lines; the 30 ms is without.
 
> with 6, it exhausted the 8GB memory in my machine.)
 
> With some compilers, this test is unsuitable because having that much code
> in one function gives problems, because of the way it's implemented.
 
Thanks for the info but I will be putting neos through several
optimization rounds and will include a proper test suite with test
programs are various sizes/complexities.
 
You might be interested to know that neos parses using backtracking with
memoization.
 
/Flibble
 
--
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who
doesn't believe in any God the most. Oh, no..wait.. that never happens." –
Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are
confronted by God," Bryne asked on his show The Meaning of Life. "What
will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery
that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a
world that is so full of injustice and pain. That's what I would say."
scott@slp53.sl.home (Scott Lurndal): May 22 06:19PM


>> Actually at least one major processor vendor has been thinking about
>> changing this in the future.....
 
>Details, please?
 
Unfortunately they're not public.
 
However, there are public projects that propose new pointer
formats, for example:
 
https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/cheri-faq.html
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: May 22 08:16PM +0100

On Wed, 22 May 2019 15:46:03 +0000 (UTC)
 
> >You will find many similar examples in articles on the internet about
> >strict aliasing.
 
> How about finding one that acually proves your point.
 
What a fine display. Even capital letters and exclamation marks!!
You display all your ignorance, without even testing the strict
aliasing effects it produces and presumably therefore without actually
running it at all. You have, in fact, completely missed the point
about aliasing.
 
When put in a file aliasing.cpp and compiled with 'g++ aliasing.cpp' or
'clang++ aliasing.cpp' and run it produces this output:
 
0
0
 
When compiled with 'g++ -O2 aliasing.cpp' or 'clang++ -O aliasing.cpp'
it produces:
 
0
1
 
Clang (which you think is better than gcc) optimizes to emit what you
would call the "wrong" code with -O. gcc requires -O2 to do so.
Ian Collins <ian-news@hotmail.com>: May 23 07:40AM +1200

On 23/05/2019 01:10, Bart wrote:
 
> Here's one very basic example: if A is signed, and B unsigned, then my
> language says that A+B is performed as signed, with overflow
> well-defined, and at at least 64 bits.
 
So use specialised C++ number classes. There are many things that can't
easily be expressed in C that are simple to do in C++.
 
--
Ian.
jameskuyper@alumni.caltech.edu: May 22 01:55PM -0700

On Wednesday, May 22, 2019 at 1:24:54 PM UTC-4, Hans Bos wrote:
 
> But there is no guarantee that the radix is 2.
> Suppose my system has doubles with radix 10.
> What, in that case, is the rhex representation of 0.1?
 
The behavior of hexfloat is to set the iosbase::fixed and
iosbase::scientific flags. Table 76 defines the behavior when those
flags are set in terms of the "%a" or "%A" format specifiers for
std::printf(). The C++ standard does not, itself, give a detailed
description of printf(), cross-referencing the C standard. Here's what
the C standard says about that issue:
 
"... if the precision is missing and FLT_RADIX is a power of 2, then the
precision is sufficient for an exact representation of the value; if the
precision is missing and FLT_RADIX is not a power of 2, then the
precision is sufficient to distinguish 279) values of type double,
except that trailing zeros may be omitted; ..." (C standard,
7.21.6.1p8).
 
"279)" refers to the following footnote:
 
"The precision p is sufficient to distinguish values of the source type
if 16^(p−1) > b^n where b is FLT_RADIX and n is the number of base-b
digits in the significand of the source type. A smaller p might suffice
depending on the implementation's scheme for determining the digit to
the left of the decimal-point character."
 
Therefore, on a hypothetical system with FLT_RADIX of 10, 0.1 would be
printed with sufficiently many hexadecimal digits to clearly distinguish
it from both std::nexafter(0.1,0.0) and std::nextafter(0.1,0.2).
However, that hexadecimal floating point string will NOT be an exact representation of 0.1. Neither is it guaranteed that the floating point
value of the constant 0.1 exactly represents the value 1/10, even though
that value would be exactly representible on such a system. Such a
guarantee is only available for hexadecimal floating point constants on
systems where FLT_RADIX is a power of 2.
jameskuyper@alumni.caltech.edu: May 22 01:58PM -0700

On Wednesday, May 22, 2019 at 2:16:38 PM UTC-4, Paavo Helde wrote:
 
> Right, the actual requirement is just "Hexadecimal floating-point
> formatting ignores the stream precision specification". I guess it could
> round all numbers to 0 if it wanted.
 
No, the C++ standard cross-references the C standard's description of
the %a format specifier for printf(), and that description imposes
strong requirements on the precision of the output, even when FLT_RADIX
is not a power of 2. See my direct response to Hans Bos for more
details.
Bart <bc@freeuk.com>: May 22 09:58PM +0100

On 22/05/2019 19:09, Scott Lurndal wrote:
>> depending on what C type is stored at the address then?
 
> More often than not, it is function pointers that are a different size than
> pointers to other objects; but it depends entirely on the architecture.
 
What about a pointer to pointer to function - will that be
function-pointer sized, or object-pointer-sized?
 
If the latter, one function pointer implementation could simply add an
extra pointer level behind the scenes, so that, using your Burroughs
example, a function pointer in the user program is actually a 32-bit
pointer to an 80-bit location containing the actual function pointer.
 
More efficient to manipulate too.
 
(This assumes a fairly sane architecture, not one consisting mostly of
code and little RAM, with too many functions to be referenced by a
narrow object pointer.)
jameskuyper@alumni.caltech.edu: May 22 02:02PM -0700

On Wednesday, May 22, 2019 at 4:58:51 PM UTC-4, Bart wrote:
> On 22/05/2019 19:09, Scott Lurndal wrote:
...
> > pointers to other objects; but it depends entirely on the architecture.
 
> What about a pointer to pointer to function - will that be
> function-pointer sized, or object-pointer-sized?
 
It points to a pointer object, so it will be object pointer sized, obviously.
David Brown <david.brown@hesbynett.no>: May 22 11:40PM +0200


>> It is not true at the moment either. There are more processors around
 
> So which architectures have a variable number of memory addressing bits
> depending on what C type is stored at the address then?
 
There are a number of small microcontrollers where data space pointers
are 16-bit, but full function pointers are longer as they support more
than 64K of code flash. There are plenty that have multiple different
kinds of pointers - for example, for the AVR the gcc port has simple
data pointers that are 16-bit, and data pointers that can also cover
flash areas and are 24-bit long. There are smaller microcontrollers
which use 8-bit pointers for "local page" addresses, and bigger pointers
for when paging is used. There are microcontrollers that support "bit
pointers" with larger lengths than byte pointers. There are DSP's with
16-bit and 32-bit "char" that have support for "octet pointers" that are
longer, because they encode the octet number within the C "byte".
David Brown <david.brown@hesbynett.no>: May 22 11:44PM +0200

On 22/05/2019 22:58, Bart wrote:
>> pointers to other objects;  but it depends entirely on the architecture.
 
> What about a pointer to pointer to function - will that be
> function-pointer sized, or object-pointer-sized?
 
The pointer-to-function is an object, so it is obviously
pointer-to-object sized. (Why do you even need to ask that?)
 
> example, a function pointer in the user program is actually a 32-bit
> pointer to an 80-bit location containing the actual function pointer.
 
> More efficient to manipulate too.
 
It is not uncommon to have some kind of indirection, vectors,
trampolines, indexing, compiler/linker generated switch, etc., in cases
where function pointers are quite large or for architectures where
directly using a full function pointer is less efficient than using
indirect approaches.
 
Bart <bc@freeuk.com>: May 22 10:55PM +0100

On 22/05/2019 22:44, David Brown wrote:
>> function-pointer sized, or object-pointer-sized?
 
> The pointer-to-function is an object, so it is obviously
> pointer-to-object sized.  (Why do you even need to ask that?)
 
Because it is such an obvious workaround when function pointers are much
wider than object pointers, that the mismatch ceases to be a real problem.
 
Although it would be better if the workaround was implemented in the
compiler, to give the impression that function pointers were a normal size.
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: