Wednesday, December 28, 2016

Digest for comp.lang.c++@googlegroups.com - 25 updates in 7 topics

Marcel Mueller <news.5.maazl@spamgourmet.org>: Dec 29 12:24AM +0100

On 28.12.16 00.09, Stefan Ram wrote:
> and this might cause the page to be created or loaded or
> something and then subsequent read accesses to x will return
> the actual value in the storage which might not be 0.
 
The basic message is, that uninitialized storage might not even return
/reproducible/ values. Of course, the standard tells nothing about
behavior at UB. In practice it is a academic discussion since it it
almost impossible to find even one existing platform that /does/ return
unreproducible results on uninitialized memory. Only one of the reasons
is that this is always a potential security risk. You might get memory
content that was never intended for your eyes.
 
> includes the possibility that consecutive read accesses
> to the same uninitialized object may return different
> values without any intervening write access to this object.
 
In theory: yes.
 
But in practice on many platforms taking a conditional branch is by far
more expensive than setting a memory address to zero. So the discussion
is even more academic.
Firstly the branch may discard the CPU pipeline. Secondly the saved
write may cause an additional read cycle. While the write access might
end in the write back cache and is immediately available for read back
the read access is synchronous and may block the pipeline.
 
Only if writing to physically slow targets (e.g. flash RAM) writes could
be undesired. But at this point we are talking about platform specific
issues and on a certain platform this is likely to be /defined/ behavior.
 
 
Conclusion: a programmer should /never/ write crap like this in portable
code.
If on a certain platform it is better to go this way then it should be
up to the optimizer to generate the required code.
 
 
Marcel
Jeff-Relf.Me <@.>: Dec 28 07:29AM -0800

woodbrian77@gmail.com: Dec 28 09:45AM -0800

On Wednesday, December 28, 2016 at 4:08:35 AM UTC-6, Öö Tiib wrote:
> of "readable".
 
> If you write code that confuses others then it makes it hard to cooperate
> with you.
 
If you intentionally write code that confuses others ...
is how I would say it.
 
> That is bad since most software is not written alone. What I
> have typically seen are up to 10 teams of 4 to 8 persons per team.
 
I've worked at a number of big companies and so I'm familiar
with what you are talking about. And I believe the 3-tier
architecture of the C++ Middleware Writer would work well
for teams of the size you mention. It took me a few years
to realize that the web interface I had in 2003 wasn't going
to cut it.
 
 
Brian
Ebenezer Enterprises
http://webEbenezer.net
legalize+jeeves@mail.xmission.com (Richard): Dec 28 06:10PM

[Please do not mail me a copy of your followup]
 
Paavo Helde <myfirstname@osa.pri.ee> spake the secret code
 
>I have changed away from C and macro madness and have no plans to go
>back, thank you.
 
Fuckin' A, bubba.
--
"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>
woodbrian77@gmail.com: Dec 28 10:20AM -0800

On Wednesday, December 28, 2016 at 12:10:58 PM UTC-6, Richard wrote:
 
I'm glad these "men" were busted:
 
http://www.twincities.com/2016/12/27/south-st-paul-teacher-partner-allegedly-abused-8-victims/
 
Children deserve better than "teachers" getting them
drunk and high in order to abuse them.
Ian Collins <ian-news@hotmail.com>: Dec 29 08:09AM +1300

On 12/28/16 07:49 PM, Jeff-Relf.Me wrote:
 
> You _say that neither your programmers nor your compilers
> could handle fewer, larger .CPP files but you could be wrong.
 
> Have you tried fewer, larger .CPP files ?
 
No, for the simple reasons stated above.
 
> Would a hardware/software upgrade help ?
 
Faster hardware always helps.... We current have the fastest available.
 
> Are you running legacy hardware/software ?
 
No.
 
--
Ian
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Dec 28 07:36PM

On Tue, 27 Dec 2016 21:24:34 -0800 (PST)
 
> Brian
> Ebenezer Enterprises - In G-d we trust.
> http://webEbenezer.net
 
Brian,
 
You are a nasty piece of work who thinks it is OK to slag off anyone
or any countries that you happen to come across.
 
Why not just fuck off? Then you wouldn't need to worry about the
"swearing". It would also relieve us of seeing your weirdo postings.
legalize+jeeves@mail.xmission.com (Richard): Dec 28 08:01PM

[Please do not mail me a copy of your followup]
 
Ian Collins <ian-news@hotmail.com> spake the secret code
 
>Nope, build times are the bottleneck.
 
I'm looking forward to modules as an improvement here.
--
"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>
woodbrian77@gmail.com: Dec 28 12:41PM -0800

On Wednesday, December 28, 2016 at 1:36:59 PM UTC-6, Chris Vine wrote:
 
> Brian,
 
> You are a nasty piece of work who thinks it is OK to slag off anyone
> or any countries that you happen to come across.
 
I was criticizing "leaders" like Putin.
 
I asked a question about parameter type deduction with constructors:
https://groups.google.com/forum/#!topic/comp.lang.c++/m43-E2_msOw
 
Perhaps you could help sort that out? And over the years
there are many things that I've asked about that I hope
we will revisit.
 
 
Brian
Ebenezer Enterprises - "G-d is our refuge and strength,
a very present help in trouble. Therefore we will not
fear though the earth gives way, though the mountains
be moved into the heart of the sea, though its waters
roar and foam, though the mountains tremble at its
swelling. Selah" Psalms 46:1-3

http://webEbenezer.net
Ian Collins <ian-news@hotmail.com>: Dec 29 10:08AM +1300


>> You are a nasty piece of work who thinks it is OK to slag off anyone
>> or any countries that you happen to come across.
 
> I was criticizing "leaders" like Putin.
 
No you weren't, you were directing nasty baseless insults at a dozen
countries.
 
--
Ian
woodbrian77@gmail.com: Dec 28 01:29PM -0800

On Wednesday, December 28, 2016 at 3:09:02 PM UTC-6, Ian Collins wrote:
 
> > I was criticizing "leaders" like Putin.
 
> No you weren't, you were directing nasty baseless insults at a dozen
> countries.
 
The baseless hatred is toward Israel.
 
"Barack Obama has done his best for nearly eight years
to undermine the state of Israel."
 
Read more at: http://www.nationalreview.com/article/443371/obama-anti-israel-jewish-jerusalem-judeo-christian-western-civilization
 
 
Brian
Ebenezer Enterprises - "The nations rage, the kingdoms totter;
He utters his voice, the earth melts." Psalms 46:6
 
http://webEbenezer.net
Ian Collins <ian-news@hotmail.com>: Dec 29 10:46AM +1300


>> No you weren't, you were directing nasty baseless insults at a dozen
>> countries.
 
> The baseless hatred is toward Israel.
 
Objecting to the Israeli governments illegal actions is not antisemitic.
Get your facts straight before you start lobbing insults around.
 
--
Ian
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Dec 28 09:59PM

On Wed, 28 Dec 2016 12:41:13 -0800 (PST)
 
> Perhaps you could help sort that out? And over the years
> there are many things that I've asked about that I hope
> we will revisit.
 
You seem to show a disregard for the truth. It is enough for you to
pose as right even if you are being malicious, objectionable and (in
this latest posting) evasive. Perhaps those are the Christian virtues
you like to aspire to? Happily I think most people realise that you are
not espousing Christian values but are instead a rather unpleasant nut
job.
 
On disregard for the truth, your comments were not about Putin: the
evidence of your posting is there, right in front of us. You cannot
now remove it by wishing to change the subject. Your comments were
about numerous countries, including my own. Covertly they were about
all those who have opposed the current Israeli government's position on
settlements in the occupied territories, which as it happens are
probably opposed by a plurality of Israeli citizens also.
 
On evasiveness, you are trying to change the subject from your previous
objectionable and off topic remarks to that of type deduction with
constructors. This is your standard ploy with all your off topic
posting. You are incapable of following any logical line of argument
because of it.
 
I would like you to follow the original advice and fuck off. Please
give very serious thought to that. You would be doing both us and
yourself a favour.
woodbrian77@gmail.com: Dec 28 03:14PM -0800

On Wednesday, December 28, 2016 at 3:59:23 PM UTC-6, Chris Vine wrote:
 
Chris, please don't swear here.
 
I've been speaking truth to power ala Yohanan the Immerser
(aka John the Baptist) for years. Criticizing Bill
Clinton, George W. Bush and especially Obama and Putin.
Yohanan the Immerser criticized King Herod and Herod had
him beheaded. Herod sounds like Assad.
 
It's not wise to follow "leaders" who are turning away
from G-d. Obama, Putin, Assad, ... they are corrupt
and foolish men.
 
 
Brian
Ebenezer Enterprises
http://webEbenezer.net
woodbrian77@gmail.com: Dec 28 02:29PM -0800


> ::std::unique_ptr request(::new cmw_request(localbuf));
 
> ?
 
> Those don't compile here either.
 
I think the right answer is probably one of the last
two that I posted, but I've yet to find a compiler that
supports this.
 
 
 
Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net
Mr Flibble <flibble@i42.co.uk>: Dec 28 10:09PM

Please stick to topic which is C++ modulo sausages.
 
/Flibble
Gareth Owen <gwowen@gmail.com>: Dec 28 03:34PM

> all finite ordinals", which is ω, since each ordinal is the set
> containing all previous ordinals. There is the /class/ of all ordinals,
> because there is a way to define ordinals, but it is not a set.
 
On a related note, I am currently attempting to teach my goldfish to
speak Norwegian.
Mr Flibble <flibble@i42.co.uk>: Dec 28 04:40PM

On 28/12/2016 09:03, David Brown wrote:ω.
 
> There is no such thing as "the set of ordinals". There /is/ "the set of
> all finite ordinals", which is ω, since each ordinal is the set
 
Bullshit. There is no such thing as the set of finite ordinals as there
is an infinite number of ordinals; you have also been drinking the
koolaid like that idiot Owen.
 
/Flibble
Daniel <danielaparker@gmail.com>: Dec 28 08:55AM -0800

On Wednesday, December 28, 2016 at 11:41:06 AM UTC-5, Mr Flibble wrote:
 
> There is no such thing as the set of finite ordinals as there
> is an infinite number of ordinals;
 
The set of finite ordinals is infinite.
 
Daniel
Gareth Owen <gwowen@gmail.com>: Dec 28 05:02PM


>> There is no such thing as the set of finite ordinals as there
>> is an infinite number of ordinals;
 
> The set of finite ordinals is infinite.
 
Mr Flibble isn't too bright
Mr Flibble <flibble@i42.co.uk>: Dec 28 05:12PM

On 28/12/2016 16:55, Daniel wrote:
 
>> There is no such thing as the set of finite ordinals as there
>> is an infinite number of ordinals;
 
> The set of finite ordinals is infinite.
 
Bullshit; you cannot have a set of infinite things as infinity is,
unlike a set, unbounded. Countable infinities are unbounded just like
uncountable infinities despite what Wikipedia says.
 
/Flibble
Mr Flibble <flibble@i42.co.uk>: Dec 28 05:21PM

On 28/12/2016 17:12, Mr Flibble wrote:
 
> Bullshit; you cannot have a set of infinite things as infinity is,
> unlike a set, unbounded. Countable infinities are unbounded just like
> uncountable infinities despite what Wikipedia says.
 
Of course what I meant to say was that a countable infinity is unbounded
just like an uncountable one.
 
/Flibble
ram@zedat.fu-berlin.de (Stefan Ram): Dec 28 11:54AM

>Dan Sacks asked (in the context of C and C++), »What's a data
>type?«.
~~~
>o size and alignment
>o set of valid values
>o set of permitted operations
~~
>I might post a followup later with an attempt to give
>an answer to his question.
 
I like Dan's first part because it uses »properties«. The
term »property« is more abstract and therefore might still
apply, even when the more concrete categories given later do
not apply.
 
But then he also uses the vague term »bundle«. We know that
two sets are equal when all their members are equal, but
when are two »bundles« equal? Because of this vagueness,
the sentence possibly cannot be used as a definition.
 
Now, two definitions of »type« for C++ follow:
 
First definition (normative):
 
ISO/IEC 14882 lists »ISO/IEC 2382 (all parts), Information
technology - Vocabulary« as a normative reference in 1.2.
 
ISO/IEC 2382 defines "data type" in 15.04.01: »A defined
set of data objects of a specified data structure and a set
of permissible operations, such that these data objects act
as operands in the execution of any one of these operations.«
 
So this is the normative definition of »data type« in C++.
 
This definition seems to be similar to Dan's one.
 
Second definition (my own invention):
 
A data type is first and foremost a tag.
 
What do I mean by »tag«?
 
First, let's ignore the preprocessor! It is difficult to
say anything when there is a preprocessor, because there
might be a macro like »#define using int« in scope and then
»using x = 0;« is a declaration, but I would like to exclude
such possibilities.
 
So, simplified, a tag is a character string.
(Here, »string« means »character string«
- it does not refer to »char *« or »::std::string«.)
 
For example, in
 
int x;
 
, x has the type »int«. This is a string made out of three
characters, »i«, »n«, and »t«.
 
More precisely: A tag is a member of a set TYPES of
equivalence classes of strings.
 
At each point in the source code and for each scope, there
is a set of all TYPES known at this point or in this scope.
 
Some strings might be equivalent, that is, they may specify
the same type (tag). The language C++ gives us rules for this.
 
void f()
{ { using a = int; } { using a = double; using b = int; }}
 
Here, »a« is equivalent to »int«, and later to »double«.
(The set TYPES of the scope of the outermost block still has
»int«, so we can use this to identify the »b« of the second
inner block with the »a« of the first inner block, even
though their scopes do not overlap.)
 
This also is an example for equivalent
strings: at a point in the above source code,
»a« is equivalent to »int«, that is, these
two strings are in the same equivalence class,
they are the same tag, they denote the same type.
 
Now, that we have established what a type
/is/ (an equivalence class of strings),
we may go on and observe the /meaning/ of a
given type. We can than observe that values
and operations can be attached to a type, but
we do not have to use them to define what a
type /is/. Instead they are »properties«
(Dan's word) of types. Some of these properties
might only apply to certain kinds of types.
 
We can also see that these tags (types) can
be attached to certain things, like variables,
and that there are rules in the language that
take types into account so as to say wether a
program is permissible. But all these complicated
properties do not have to enter into the definition
of what a type /is/.
 
A copper rod is a rod made out of copper (definition),
It can be painted with different colors or
can be used as a cathode - but we do not need to
incorporate all theses details into its definition.
 
This definition of »type« is intended for C++
(and similar languages); for other languages
other definitions might apply. So, I do not
claim that my definition is »general«.
ram@zedat.fu-berlin.de (Stefan Ram): Dec 28 04:19PM

>A data type is first and foremost a tag.
 
And it says, »an object has a type«.
 
Well, one should not try to contradict the standard, but in
this case, I would say that an object, is always represented
by an /expression/ in the source code. And /that/ expression
has a type. This type then doubles as the type of the object.
But the object has no type independent of the type of an
expression for it.
 
As long as casts are avoided, whenever an object is being
passed the type rules guarantee that its type also is being
passed. Insofar the type keeps being attached to the object.
 
But if there would be such a thing as a »pure object«
without an expression for it, we would not be able to
know its type! This is similar to a »void *«. It indicates
an address that might be the start of an object, but
we don't know the type of this object if we only know
the »void *«.
 
Or, one might say that the concept of an object mixes
dynamic (value) and static properties (type) and that
the concept of an object /includes/ an expression used
to express the object in the source code, and the
object gets its type from this expression.
jt@toerring.de (Jens Thoms Toerring): Dec 28 12:39PM

> Either I am doing something very stupid or this is working and the tester
> I am using is wrong:
 
Sounds a bit as if the "tester" (whatever that might be)
is the compiler, at least if the code you posted is for
real;-)
 
> template <class TYPE>
> HashTable<TYPE>::HashTable(const HashTable<TYPE>& other) {
> table_ = new Record*[other.cap];
 
Now you've got an array of 'other.cap' uninitialized pointers.
to me it would look rather useful to set them all to 'nullptr'
to make it sure that none of them points to any random
memory location yet. You could achive that by using
 
table_ = new Record* [other.cap] ();
 
> size_ = other.size_;
 
I'm not sure, but I'd guess that better should be ini-
tialized to 0, at least in case my guess is correct that
this should contain the number of entries in the hash.
But see my comments below.
 
> hash = other.hash;
> cap = other.cap;
 
All of 'table_', 'size_', 'cap' and 'hash' obviousy must be
member variables. One convention is to have their names end
in an underscore. But you only use that for some of them.
Why?
 
> std::cout << cap << size_ << "\n";
> for (int i = 0; i<other.cap_; i++) {
 
And here there suddenly seems to be another member variable,
named 'cap_'. Is that a typo or do you really have two
member variables, one named 'cap' and one named 'cap_'?
If that's the case why and what is 'cap_' then not also
initialized in the new instance?
 
> if (table_[i] == nullptr) {
 
Here you test for random values that the 'table_' array
contains after its allocation above. My guess is that
you should test for 'other.table_[i]' instead.
 
> continue;
> }
> update(other.table_[i]->key_,other.table_[i]->data_);
 
Here comes the next question: as far as one can surmise from
the update() function a 'Record' seems to a linked list of
key-value pairs. So you'll need to iterate over that instead
of copying just the (probably) first element of that linked
list. Something along the lines of
 
Record * cur_rec = other.table_[i];
while (cur_rec) {
update(cur_rec->key_, cur_rec->data_);
cur_rec = cur_rec->getNext();
}
 
> }
 
> //Updates record with the string passed to the new data for the record's data element and returns true if found/updated otherwise false
 
This comment definitely does not describe what the function is
doing (and the name is a bit of a mis-nomer since it will not
only update existing elements but also add new ones). It never
does return 'false' but always 'true', so it having a return
value doesn't make too much sense.
 
> entry->setData(value);
> }
> size_++;
 
This looks strange. The way 'size_' is used here indiceates
that it counts how often the entries were modified (added or
updated). But the name would make more sense if it would
count the total number of entries. In that case it should
only be incremented when a new entry was added, not also
when one was merely changed. (But in that case you'd have
to set it to 0, not copy it from the other table in your
copy constructor above!0
 
> return true;
> }
 
Here's a somewhat condensed form of how I guess your copy
constuctor might look like in the end:
 
template <class TYPE>
HashTable<TYPE>::HashTable(const HashTable<TYPE>& other)
: table_(new Record* [other.cap] ()),
: size_(0),
: hash(other.hash),
: cap(other.cap)
{
for (size_t i = 0; i < other.cap; ++i) {
Record * cur_rec = other.table_[i];
while (cur_rec) {
update(cur_rec->getKey(), cur_rec->getValue());
cur_rec = cur_rec->getNext();
}
}
}
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
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: