472,789 Members | 1,103 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,789 software developers and data experts.

already used in a 'child' scope to denote something else

{
int i = 2;
}
int i = 1;

There is no 'i' defined in the 'parent' context from the moment of
declaration on. So what is the problem? They tell us they pursue language
simplicity. The rule "do not define a variable more than once in the same
context" is natural, and simplest therefore. All normal languages obey it
therefore. Overcomplicating a grammar by injecting more barrieres is a path
right away from simplicity. Another obstacle at the plain place introduced
in C# for no reason is blocking "fall throughs" in switch -- the feature
wich can be very useful sometimes. C# designers demonstrate some excessive
zeal on 'protecting' us from doing things naturally, going strightforward
ways.

"Give a fool rope enough and he'll hang himself."
Jun 8 '07
56 5541
Now 1 and 3 are essentially the same length and complexity. In fact, 3
eliminates a preposition. Is 3 therefore preferred?
Ok, I will not tell which of 1 and 3 is better/more beautiful. The issues is
not the numer of letters. The issue is that you should repeat the same
pattern over and over again. And duspute reduction. Which is stupid.
Jun 12 '07 #51
valentin tihomirov wrote:
1. He went to home.
2. A gived individual of man sex consciously performed a process of foot
transportation with normal speed in past time towards an object, which
represents a place of permanent resedence of given subject.
The first sentence doesn't specify the means of transportation, it can
just as well mean that he went by car. Neither does it specify the speed
of the transportation.

Also, "to home" doesn't even specify that it was his own home. It could
be anybodys home.

I am aware that you probably meant "He walked home", but this
demonstrates how redundancy makes a sentence clearer. Eventhough the
second sentence contains more errors than the first, it's still clear
what it means.

The same happens if a programming language is too terse. The compiler
can't help you spot faulty code, as the code may still be valid but
means something completely different.

(Isn't it funny when you can use someones example to argue the opposite
of the point he was trying to make? ;)

--
Göran Andersson
_____
http://www.guffa.com
Jun 12 '07 #52

"valentin tihomirov" <V_*********@best.eewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>This is the foundation of RAII. You will become a much better programmer
if you study some examples, before telling us about all the things C++
can't do, when in reality RAII provides them perfectly.

I fahve seen tons of C++ examples in MSDN. Do not remember if if they ever
use any exceptions. They do everything in C style (besides object
instantiation). Macros just collapse the pattern, which constituates all
the win32 code:
MSDN doesn't use C++ for examples, because Win32 API is pure C.
>
handle = Create...
if (handle == invalid) {
printf(last error)
return
}
handle2 = Create ...

to mimic exceptions.

And tell me how your RAII perfectly handles these cases and how we do not
need finally. We do not need finally for the reason nobody uses exceptions
in C++.
C++ destructors are called during exception stack unwinding. No finally
block is ever needed.

I don't understand what makes you incapable of researching RAII so that I
have to tell you about it. Try http://en.wikipedia.org/wiki/RAII
>
The case of "100% automatic destruction" on explicit (manual) destructor
call is especially funny.
That was when the _parent_ object is explicitly destructed, the child
objects are automatically destroyed.
Jun 19 '07 #53
C++ destructors are called during exception stack unwinding. No finally
block is ever needed.
I speak about dynamically created objects. Your RAII does not apply to
heap-allocation.

byte* buf = allocatemesomedata(size); // will this be freed in case of
exception?
AbstractClass o = new Subclass(); // will the destructor of 'o' be called
automatically?

Anyway, RAII dow not address the problem of partially created objects.
Jun 20 '07 #54
valentin tihomirov wrote:
>C++ destructors are called during exception stack unwinding. No finally
block is ever needed.

I speak about dynamically created objects. Your RAII does not apply to
heap-allocation.
Don't think so.

Smart pointers are for example used for heap allocated objects.
E.g.: boosts shared_ptr (AFAIK will be part of the next C++ standard)

shared_ptr<byteheapAllocated = allocatemesomedata(size);
byte* buf = allocatemesomedata(size); // will this be freed in case of
exception?
AbstractClass o = new Subclass(); // will the destructor of 'o' be called
automatically?
Yes if you use boosts smart pointers or auto_ptr of the C++ library:

std::auto_ptr<AbstractClasso (new SubClass());

Anyway, RAII dow not address the problem of partially created objects.
Why ? Partially constructed objects will be destroyed partially - if you
are using RAII and not plain pointers.

RAII is very powerfull. One of the (only) reasons I still use C++.

Andre
Jun 20 '07 #55
>Anyway, RAII dow not address the problem of partially created objects.

Why ? Partially constructed objects will be destroyed partially - if you
are using RAII and not plain pointers.

RAII is very powerfull. One of the (only) reasons I still use C++.

How does RAII knows how far the resourse allocation has reached? How does it
jump to the point in the destructor to free only the allocated objects? The
case switch is ideal to jump to that point.

That was the origin of this discussion branch. BTW, those who thing that the
'switch' is an n-ary variation of bivalent 'if', it would be more
reasonable embrace the conditional code into {} as it matches in Pascal
rather than using 'break's, which are loop-breaking statements. The code in
loops is normally "falls through" from one instruction to the following.
Jun 21 '07 #56
valentin tihomirov wrote:
>>Anyway, RAII dow not address the problem of partially created objects.
Why ? Partially constructed objects will be destroyed partially - if you
are using RAII and not plain pointers.

RAII is very powerfull. One of the (only) reasons I still use C++.


How does RAII knows how far the resourse allocation has reached? How does it
jump to the point in the destructor to free only the allocated
objects? The
Well I'm not that experienced in compiler technology.
Simplified I would describe it this way:

The compiler holds a list with pointers to the destructors of the
created objects and simply calls them in reverse order, if anything goes
wrong (exception) or the object is destroyed.

Andre
Jun 21 '07 #57

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

Similar topics

2
by: Juan Romero | last post by:
Hey guys, I am working on a web custom control that basically draws a table (ASP Table) with a few child controls in the cells. I have a command button inside one of these cells. The problem I...
1
by: Bill Borg | last post by:
Hello all, Simple chat app, where the site owner has a master window with all requests for chat, status of each room, etc., and child windows for each separate chat in which the owner is...
9
by: Simon | last post by:
Hi, I have written an ActiveX object to resize images and upload them to a database, this all works fine but when I close internet explorer the process iexporer.exe is still running in my task...
11
by: John Fly | last post by:
I'm working on a large project(from scratch). The program is essentially a data file processor, the overall view is this: A data file is read in, validated and stored in a memory structure...
9
by: RichG | last post by:
In VB 5 I could have a form named frmTest and open it with frmTest.Show Now in VB.net I have to Dim frm as New frmTest frm.show The problem is I only want one instance of frmTest open, not a...
1
by: adamredwards | last post by:
I have a page with some form elements that are dynamically generated. They are inserted into the dom by first cloning a node, changing the values like name, and then inserted with insertBefore(). ...
83
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
10
by: Tammy | last post by:
Hello all, I am wondering what is the best way to declare a struct to be used in other c and c++ files. Such as for a C API that will be used by others. 1. Declaring the typedef and the...
3
by: Jim Carr | last post by:
As someone brand-new to MySQL, I am having a basic conceptual problem. I am having a hard time visualizing exactly what MySQL is, even after reading definitions. My experience with databases has been...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.