473,854 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Boost process and C

Hi,

Is there any group in the manner of the C++ Boost group that works on
the evolution of the C language? Or is there any group that performs an
equivalent function?

Thanks,
-vs

Apr 29 '06
335 11957
we******@gmail. com wrote:
Flash Gordon wrote:
jacob navia wrote:
Flash Gordon a écrit :
Is an extra byte (or word, or double word) for a flags field really
that big an overhead?
Well, I have that extra "Flags" field in the string library of
lcc-win32. I have the size as a size_t as you propose, and I need 32
bits for the flags.

The problem is that 32 bits is quite a lot for a few bits info... For
programs that use extensively strings, 32 bits multiplied by several
thousand small strings can make a big difference in RAM used, specially
for the more common short strings.

I see the point of Bstrlib, and it is a very valid design decision. I've yet to see software where short strings made up a significant
portion of the memory footprint and saving the memory that avoiding the
flags would be of real use. Of course, such applications might exist.


Any program that reads words from any language dictionary. Like a
spell checker, or a word puzzle solver/creator, or a spam filter. For
dictionaries the size of the english language dictionary, these kinds
of applications can typically push the L2 cache of your CPU pretty
hard.


I never said they didn't exist. However, a typical dictionary + the
structures is not going to fit in my L2 cache anyway. However, the
subset of it that is likely to be actually in use is probably an order
of magnitude smaller and so could easily fit in with the extra overhead.
Alternatively, one could go to conventional C strings and have a bigger
chance of it fitting since they only have a 1 byte overhead compared to
probably an 8 byte overhead (4 byte int for lenght, 4 byte int for
memory block size) that it sounds like your library has. Even if your
library only has a 4 byte overhead it is still larger!
Personally I would say that using negative lengths was asking for
problems because at some point a negative length will be checked without
first changing it to positive.


I think you miss the point. If the string length is negative then it
is erroneous. That's the point of it. But the amount of memory
allocated being negative, I use to indicate that the memory is not
legally modifiable at the moment, and being 0 meaning that its not
modifiable ever. The point being that the library blocks erroneous
action due to intentionally or unintentionally having bad header values
in the same test. So it reduces overhead, while increasing safety and
functionality at the same time.


If you are trying to detect corruption then you should also be checking
that the length is not longer than the memory block, so you should be
doing more than one comparison anyway. Then you can easily check if any
unused flag bits are non-0.
You know, you can actually read the explanation of all this in the
documentation if you care to do so.


Probably true.

It may well be that the performance gain is worth it for the
applications people use your library for. If so then fine, but the
limitation means it is not worth me migrating to it.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc

Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
May 4 '06 #221
>>> In "higher-level" languages
which are further abstracted from the implementation, it's attractive to
remove this distinction-- Python for example achieves this well. But I'm
not convinced of the wisdom of the hybrid, C with operator overloading.

I am certain that the conservative option just puts brakes to the
development of the language


I agree. You need brakes.

Having said that I'm all for trying these things out in projects like
lcc-win32.


I've been playing around with extending C to be more "high-level" using the
TinyCC compiler. The license of TinyCC is GPL and it runs on win32 and linux
so I think it makes a better base for experiments that one wants to
distribute. TinyCC is located at http://www.tinycc.org and, for those
curious, my experiments are at http://www.tinycx.org.

-Ben Hinkle
May 4 '06 #222
jacob navia wrote:
Jordan Abel a écrit :
On 2006-05-04, jacob navia <ja***@jacob.re mcomp.fr> wrote:
It just makes NO SENSE. The same thing when you apply the addition
operator to dates: it makes NO SENSE to ADD dates. Only subtraction
makes sense. And yes, multiplying dates is left "as an exercise" for
the fools!

The addition operator on dates would work _exactly_ the same way as
the addition operator on pointers - you can subtract two of them, or
add one to a number (representing an interval)

Presumably, the number would be taken as seconds [so that the
subtraction operator would call difftime, and addition, on systems
where it's not trivial, could call localtime, modify tm_secs, and then
call mktime]


Yes adding a number to a date makes sense, but I was speaking about
adding two dates!


What will the date be in 4 years, 2 months and 5 days from today?

Adding something other than a number can make a lot of sense. Adding to
real dates doesn't I agree.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
May 4 '06 #223
On 2006-05-04, Flash Gordon <sp**@flash-gordon.me.uk> wrote:
jacob navia wrote:
Jordan Abel a écrit :
On 2006-05-04, jacob navia <ja***@jacob.re mcomp.fr> wrote:

It just makes NO SENSE. The same thing when you apply the addition
operator to dates: it makes NO SENSE to ADD dates. Only subtraction
makes sense. And yes, multiplying dates is left "as an exercise" for
the fools!
The addition operator on dates would work _exactly_ the same way as
the addition operator on pointers - you can subtract two of them, or
add one to a number (representing an interval)

Presumably, the number would be taken as seconds [so that the
subtraction operator would call difftime, and addition, on systems
where it's not trivial, could call localtime, modify tm_secs, and then
call mktime]


Yes adding a number to a date makes sense, but I was speaking about
adding two dates!


What will the date be in 4 years, 2 months and 5 days from today?

Adding something other than a number can make a lot of sense. Adding to
real dates doesn't I agree.


My first thought was "represent it as a number of seconds", but then
I realized - how many seconds in two months? Or in any number of years
not a multiple of four?

Should there be another type to represent intervals of time in such
a way? Or use struct tm? 0 for the year would mean either no years or
1900 depending on the context
May 4 '06 #224

jacob navia wrote:
Ben C a écrit (regarding operator overloading)

But you can't easily use it efficiently as it stands for matrices or
strings (which are two other common uses for operator overloading).

Why not?

Suppose Matrix A,B,C;

C = A+B;


<snip>
Besides, I think that using the addition operator to "add" strings is an
ABOMINATION because:

a+b != b+a
"Hello" + "World" != "World" + "Hello"


Do you also propose to avoid using '*' to represent
matrix multiplication on the basis that matrix multiplication is not
commutative?

May 4 '06 #225
>Ben C wrote:
[much snippage]
The programmer also might implement things like shallow-copy and
copy-on-write.

Somehow all of these things need to happen when an expression like this
is evaluated:

string a = b + c;
Or, comparably (but considerably more complicated):

String a = ((b + c) - "zog") * " ";

where string "addition" means "concatenat e" (the usual definition
for string addition), "subtractio n" means "remove the first copy
of the target string, if there is one", and string "multiplication "
means "repeatedly insert this string". Hence if b and c hold "xyz"
and "ogle" respectively, the "sum" is "xyzogle", subtracting "zog"
yields "xyle", and multiplying by " " yields "x y l e " (including
the final space).
In C++ the basic mechanism you use for this is constructors. For example
the string copy constructor might set up a shallow copy-on-write copy.
Indeed. Suppose the String data structure is much like Paul Hsieh's
favorite, but perhaps with a few more bells and whistles (I have not
looked at his implementation) :

struct StringBuffer;

struct String {
char *bytes; /* the bytes (if any) in the string */
size_t slen; /* the length of the string */
struct StringBuffer *buf; /* the underlying buffer (may be shared) */
struct String *next; /* linked list in case of shared references */
};

struct StringBuffer {
char *base; /* base address of buffer */
size_t bufsize; /* size of buffer */
size_t refcnt; /* number of references to this buffer */
struct String *firstref; /* head of reference chain */
};

This gives us functions that, in C, might look like:

/* "Copy" a string: return a new reference to an existing string */
struct String *String_copy(st ruct String *old) {
struct String *new = xmalloc(sizeof *new);
/* xmalloc is just malloc plus panic-if-out-of-space */

/* copy the underlying string's info */
new->bytes = old->bytes;
new->slen = old->slen;
new->buf = old->buf;

/* insert into list, remembering new ref */
new->next = old;
new->buf->refcnt++;
new->buf->firstref = new;
}

In this case, making a second copy of a very long string is
quite cheap. So is making a sub-string out of an existing
string:

/*
* Shrink a string by removing "frontoff" charcters from the
* front, and "backoff" characters from the back. The frontoff
* may be negative to extend the string back to its original length
* although typically exactly one will be zero (remove head or
* tail part of string). The backoff must be nonnegative
* (because tail parts of buffers are not necessarily valid).
*/
void String_shrink(s truct String *s, int frontoff, int backoff) {
if (frontoff) {
if (frontoff < 0) {
size_t maxshrink = s->bytes - s->buf->base;

/* NB: this can be optimized to fall into the "else" */
frontoff = -frontoff;
if (frontoff > maxshrink)
frontoff = maxshrink;
s->len += frontoff;
s->bytes -= frontoff;
} else {
if (s->slen < frontoff)
frontoff = s->len;
s->len -= frontoff;
s->bytes += frontoff;
}
}
if (backoff) {
if (backoff < 0)
panic("bad call to String_shrink") ;
if (s->len < backoff)
backoff = s->len;
s->len -= backoff;
}
}

Now, of course, in order to *modify* the *contents* of a string,
we have to check whether the string is shared, and if so, "break"
the sharing:

/* inline */ struct String *String_preptom od(struct String *s) {
return (s->buf->refcnt == 1) ? s : String_private_ copy(s);
}

[without complicated C++ style mechanisms,] this is quite limited. You can use it for complex numbers, numbers
longer than the largest machine type, and as has been suggested perhaps
to wrap assembler intrinsics for multimedia instructions.

But you can't easily use it efficiently as it stands for matrices or
strings (which are two other common uses for operator overloading).

On its own it's not enough; with the extra workarounds you need, you end
up with C++ (or some other kind of "octopus made by nailing four extra
legs onto a dog").

In article <11************ **********@i40g 2000cwc.googleg roups.com>
REH <sp******@stny. rr.com> wrote:I still don't get your point.


OK: so write the "operator" functions for +, -, and * above and
tell us what happens to any intermediate copies of the String
structures that are created by each addition, subtraction, and
multiply.

Show us the code, and "we" (Ben C and I, perhaps) will show you
where you have re-invented the (detailed and hairy) C++ mechanisms
(or, contrariwise, have assumed that your underlying language has
garbage collection, so that temporary objects can be created and
then thrown away without calling "constructo r" and "destructor "
functions on references, reference-copies, etc.; if you do have
constructors and destructors, you also have to decide whether such
functions can or must be "virtual" or not, and so on).
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
May 4 '06 #226
Bill Pursell a écrit :
jacob navia wrote:
Ben C a écrit (regarding operator overloading)
But you can't easily use it efficiently as it stands for matrices or
strings (which are two other common uses for operator overloading).


Why not?

Suppose Matrix A,B,C;

C = A+B;

<snip>
Besides, I think that using the addition operator to "add" strings is an
ABOMINATION because:

a+b != b+a
"Hello" + "World" != "World" + "Hello"

Do you also propose to avoid using '*' to represent
matrix multiplication on the basis that matrix multiplication is not
commutative?


Matrix multiplication is a multiplication. Granted, not commutative but
a multiplication. In other languages, for instance APL that has an
operator for matrix multiplication, there are TWO signs: one ('*') for
normal multiplication, and another (a box enclosing another sign) to
denote matrix multiplication to clearly distinguish both operations.

Of course this is a matter more of taste but in the case of strings
there isn't any mathematical operation performed in those strings. Not
even a set operation. Take for instance

"Hello World" - "World"

Is the result "Hello " ???

Are we adding or subtracting things?

Surely not.

I want to introduce operator overloading into C but I am not for ANY
application of operator overloading. It has been pointed out that
overloading could lead to excessive temporaries construction, that would
be far more efficiently handled in a normal C syntax with careful code.

This is not a problem for small structures, but it could be a show
stopper for large structures like matrices for instance, where
efficiency would be more important that syntactic sugar.
Another problem that bothers me (and is so far unsolved) is the problem
of taking the address of an operator function. What should be the syntax
in that case?

For instance:

int128 operator+(int12 8 a,int128 b);

typedef int128 (*i128add)(int1 28 a, int128 b);

i128add = operator+(i128 a,i128 b); /// This ?

jacob
May 4 '06 #227
CBFalconer <cb********@yah oo.com> wrote:
And, if you write the library in truly portable C, without any
silly extensions and/or entanglements, you just compile the library
module. All the compiler vendor need to do is meet the
specifications of the C standard.

Simple, huh?


That all depends on the license under which the source code was
released. Linking a bunch of C libraries under various licenses can
involve non-trivial amounts of legal hassle to ensure compliance.

Also, there's something to be said for having features built into the
standard library. Besides making things easier from a legal point of
view, it means you can spend that much less time evaluating multiple
solutions, since most of the time, you'll just use the implementation
already available in the standard library.

I know it's unpopular around these parts to utter such heresy, but I,
for one, would love it if the standard C library included support for
smarter strings, hash tables, and linked lists.

Then again, I'm certainly NOT advocating these things should be added
to the standard C library. I recognize C for what it is, and use it
where it's appropriate. There are other languages that offer those
features. But that doesn't stop me from wanting those features in C.
May 4 '06 #228
jacob navia <ja***@jacob.re mcomp.fr> writes:
[...]
Besides, I think that using the addition operator to "add" strings is
an ABOMINATION because:

a+b != b+a
"Hello" + "World" != "World" + "Hello"

It just makes NO SENSE.


<OT>
Assuming the existence of operator overloading (which, once again,
standard C, the topic of this newsgroup, does not have), using "+" for
string concatenation makes at least sense as much as using "<<" and
">>" for I/O. (I know you haven't advocated that either, but it's
established practice in C++.) And I really don't have much problem
with the idea of a "+" operator being non-commutative -- just as a "*"
operator for matrices would be non-commutative. If you don't like it,
by all means don't use it -- but if you provide operator overloading
in your compiler, users *will* use it in ways that you don't like.

The point of operator overloading is to provide a notational shorthand
for something that could be expressed equivalently but more verbosely
using function calls. It isn't to provide something that absolutely
must follow the rules of mathematics. What would a mathematician
unfamiliar with computer programming think of "x = x + 1"?
</OT>

<WAY_OT>
Ada has a separate operator, "&", for array concatenation.
</WAY_OT>

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 4 '06 #229
Chris Torek a écrit :
[horrible string "math" snipped]

OK: so write the "operator" functions for +, -, and * above and
tell us what happens to any intermediate copies of the String
structures that are created by each addition, subtraction, and
multiply.

Show us the code, and "we" (Ben C and I, perhaps) will show you
where you have re-invented the (detailed and hairy) C++ mechanisms
(or, contrariwise, have assumed that your underlying language has
garbage collection, so that temporary objects can be created and
then thrown away without calling "constructo r" and "destructor "
functions on references, reference-copies, etc.; if you do have
constructors and destructors, you also have to decide whether such
functions can or must be "virtual" or not, and so on).


Chris:

1) Operator overloading is NOT a good application for strings, as I have
argued in another thread in this same discussion. lcc-win32 does NOT
support addition of strings nor any math operation with them.

a+b != b+a
"Hello" + "World != "World" + "Hello"

2) Operator overloading does NOT need any constructors, nor destructors
nor the GC if we use small objects:

int128 a,b,c,d;

a = (b+c)/(b-d);

This will be translated by lcc-win32 to

tmp1 = operator+(b,c);
tmp2 = operator-(b,d);
tmp3 = operator/(tmp1,tmp2);
a = tmp3;

The temporary values are automatically allocated in the stack.

Of course if you have interior pointers those intermediate structures
must be registered so that the storage can be freed. This is solved, as
you say, with a GC. lcc-win32 offers a GC in the standard distribution,
and allows to have the best of both worlds: the easy of C++ destructors
that take care of memory managemnt WITHOUT PAYING THE PRICE of C++
complexity.

If you do not want the GC, just make a linked list with all the
allocations you make in the "constructo r" (say in the new_string()
function) and periodically clean them up.
May 4 '06 #230

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

65
5408
by: perseus | last post by:
I think that everyone who told me that my question is irrelevant, in particular Mr. David White, is being absolutely ridiculous. Obviously, most of you up here behave like the owners of the C++ language. A C++ interface installation IS ABOUT THE C++ LANGUAGE! The language does not possess the ability to handle even simple file directory manipulation. Those wise people that created it did not take care of it. So, BOOST is a portable...
205
10771
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
17
1906
by: Howard Gardner | last post by:
/* If I am using boost, then how should I write this program? As it sits, this program is using SFINAE to determine whether or not a type supports particular syntax. I suspect that there is functionality in boost to do this. I have found mpl::has_xxx, which I suspect of being part of the solution. I've also found type_traits::has_nothrow_constructor
2
6636
by: smith4894 | last post by:
{ not sure you're aware of that but there are the newsgroups for all major operating systems. you might want to try asking in the forum 'comp.os.linux.development.apps', since memory-mapped files are not a language-supported structure, they are platform-specific. -mod } I'm trying to use boost serialization to serialize/deserialize data to and from a mmap'd file. I have my own ostream/istream classes that essentially read/write bytes...
5
2400
by: linyanhung | last post by:
I used a boost multi thread in VS 2005 on a Duo Core PC, and made a two thread process. The code is something like this: #include <boost/thread/thread.hpp> void fun1() { //do something
8
6216
by: Matt England | last post by:
My team currently using Boost Threads, but we are considering switching to ZThreads. (We seek cross-platform, C++ multithreading capabilities in an external library.) ZThread(s): http://zthread.sourceforge.net/ http://www.inf.uni-konstanz.de/dbis/members/vinnik/zsim/doc/ Can anyone share their ZThreads experience, either good, bad, or
2
2417
by: ironpingwin | last post by:
Hi! I'd like to make few threads which will run in the same time in C++. I try to use boost library v 1.34.1 (it can't be newest, because I compile on remote machine, which is not administrated by me). In this version there isn't detach() function. How to run functions from two different class in the same time?
13
4542
by: brad | last post by:
Still learning C++. I'm writing some regex using boost. It works great. Only thing is... this code seems slow to me compared to equivelent Perl and Python. I'm sure I'm doing something incorrect. Any tips? #include <boost/regex.hpp> #include <iostream> // g++ numbers.cpp -o numbers -I/usr/local/include/boost-1_35 /usr/local/lib/libboost_regex-gcc41-mt-s.a // g++ numbers.cpp -o numbers.exe
5
3596
by: ameyav | last post by:
Hi All, I am converting some C code into C++ code. The objective is to improve throughput. I have some code written in C which serially parses through a list of files, opens each one of them, processes the data and closes the file. All the files are processed one by one. The obvious performance bottleneck that i could think of is the wasted cpu cycles for file i/o. *My solution* was to spawn multiple threads to do the file i/o. For...
0
9901
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10684
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10763
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9517
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4563
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4159
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3188
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.