Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #13930

Re: freeze and forget it :-)

From 88888 Dihedral <dihedral88888@googlemail.com>
Newsgroups comp.lang.c++
Subject Re: freeze and forget it :-)
Date 2012-02-11 20:21 -0800
Organization http://groups.google.com
Message-ID <2712874.524.1329020478754.JavaMail.geo-discussion-forums@pbqv10> (permalink)
References <jh7d83$j8k$1@news.albasani.net>

Show all headers | View raw


在 2012年2月12日星期日UTC+8上午11时55分42秒,U.Mutlu写道:
> What I miss in the language, for ages now, is a keyword
> that lets forget/undefine a defined variable:
> 
> void f()
> {
>    int x;
>    ...
>    forget x;
>    ...
> }
> 
> Such a construct would be useful when analysing/debugging/hand-optimizing
> lenghty functions written by others. It helps make code more robust
> by undefining the variable as soon as it's not needed anymore.
> It also would aid the compiler for optimization.
> (Of course one could create the variable in its own scope block,
> but that's "cumbersome"/impractical to do for code of others.)
>
Local variables in confined scopes on a dedicated  stack frame was 
the old way long tim ago. This trick can be traced back to the 
German computer used in world war II. 

Allocations  of objects in the heap space are not new, too. 

But the computing of the reference count and garbage collector to track every object in the heap space  passing around in different modules is not standardized in different comupter languages and directly supported by hardware instructions. 
 
> Another construct I miss is: making a variable const sometime later after definition,
> ie. promoting it to const by using a keyword "freeze" or such (of course the reverse,
> promoting from const to non-const, shall not be possible):
> 
> void f()
> {
>    int x;
>    ...
>    freeze x;
>    ...
> }
> 
> IMHO it would be very easy and simple to implement these into the language.
> OTOH I'm not update with the recent developments of the language,
> maybe they already added them? Or is it just wishful thinking? :-)

The muti-threading management adds overheads in all objects, too. 

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

freeze and forget it :-) "U.Mutlu" <for-usenet@mutluit.com> - 2012-02-12 04:55 +0100
  Re: freeze and forget it :-) 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-11 20:21 -0800
  Re: freeze and forget it :-) Goran <goran.pusic@gmail.com> - 2012-02-11 22:25 -0800
  Re: freeze and forget it :-) "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-02-12 08:50 +0100
  Re: freeze and forget it :-) Paavo Helde <myfirstname@osa.pri.ee> - 2012-02-12 02:55 -0600
    Re: freeze and forget it :-) Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-02-12 12:55 +0000

csiph-web