List Info

Thread: Contexts for If/Loops




Contexts for If/Loops
country flaguser name
Australia
2007-08-22 17:26:46
Is it valid/usable to have separate contexts for the IF /
while/ For/ try 
blocks in Python.?
If its valid enough , then all the current DUChain does
allow is a 
DUContext::Other for those. And we might a new Context Type
for Those.?
-- 
Regards,
Piyush Verma
0091-9811261908
Email:piyush.vermagmail.com
Work: piyushphire.com

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

Re: Contexts for If/Loops
user name
2007-08-23 03:47:24
On 23.08.07 03:56:46, Piyush Verma wrote:
> Is it valid/usable to have separate contexts for the IF
/ while/ For/ try 
> blocks in Python.?

No only Python but also C++, so far I don't think this is
happening for
C++ and I wonder how code-completion works for objects
created inside an
if-block...

> If its valid enough , then all the current DUChain does
allow is a 
> DUContext::Other for those. And we might a new Context
Type for Those.?

Not only a new type, but maybe also a way to store the
if/while/for
conditions and for catch blocks the exception that is being
catched (or
except in the python case). For try-contexts I guess the
Context should
get an identifier of "try", a context with no
identifier is just too
confusing in the duchain viewer.

Andreas

-- 
You will always have good luck in your personal affairs.

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

Re: Contexts for If/Loops
user name
2007-08-23 07:26:17
On 8/23/07, Andreas Pakulat <apakugmx.de> wrote:
> On 23.08.07 03:56:46, Piyush Verma wrote:
> > Is it valid/usable to have separate contexts for
the IF / while/ For/ try
> > blocks in Python.?
>
> No only Python but also C++, so far I don't think this
is happening for
> C++ and I wonder how code-completion works for objects
created inside an
> if-block...

My understanding of contexts was that it is roughly the
"{}" block in
c++ code - the scope where variables are defined. If that's
true then
if/while/for ... should have their own contexts.

But for ruby for example the variable first used inside
if/while/etc.
is still declared/defined after the statement:

if something
   a = 2
end
#here "a" is defined and has either value nil or 2
depending on
whether something false or true
puts a

So I wonder whether python has the same rule.

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

Re: Contexts for If/Loops
country flaguser name
Germany
2007-08-27 14:17:03
On Thursday 23 August 2007 14:26, Alexander Dymo wrote:
> On 8/23/07, Andreas Pakulat <apakugmx.de> wrote:
> > On 23.08.07 03:56:46, Piyush Verma wrote:
> > > Is it valid/usable to have separate contexts
for the IF /
> > > while/ For/ try blocks in Python.?
> >
> > No only Python but also C++, so far I don't think
this is
> > happening for C++ and I wonder how code-completion
works for
> > objects created inside an if-block...
>
> My understanding of contexts was that it is roughly the
"{}" block
> in c++ code - the scope where variables are defined. If
that's true
> then if/while/for ... should have their own contexts.
>
> But for ruby for example the variable first used
inside
> if/while/etc. is still declared/defined after the
statement:
>
> if something
>    a = 2
> end
> #here "a" is defined and has either value nil
or 2 depending on
> whether something false or true
> puts a
>
> So I wonder whether python has the same rule.

Yes, in Python it works exactly the same:

>>> def test1():
...   if True:
...     a=1
...   print a
...
>>> test1()
1
>>>

Regards,
Eike.

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

Re: Contexts for If/Loops
user name
2007-08-28 17:26:41
On 27.08.07 21:17:03, Eike Welk wrote:
> On Thursday 23 August 2007 14:26, Alexander Dymo
wrote:
> > On 8/23/07, Andreas Pakulat <apakugmx.de> wrote:
> > > On 23.08.07 03:56:46, Piyush Verma wrote:
> > > > Is it valid/usable to have separate
contexts for the IF /
> > > > while/ For/ try blocks in Python.?
> > >
> > > No only Python but also C++, so far I don't
think this is
> > > happening for C++ and I wonder how
code-completion works for
> > > objects created inside an if-block...
> >
> > My understanding of contexts was that it is
roughly the "{}" block
> > in c++ code - the scope where variables are
defined. If that's true
> > then if/while/for ... should have their own
contexts.
> >
> > But for ruby for example the variable first used
inside
> > if/while/etc. is still declared/defined after the
statement:
> >
> > if something
> >    a = 2
> > end
> > #here "a" is defined and has either
value nil or 2 depending on
> > whether something false or true
> > puts a
> >
> > So I wonder whether python has the same rule.
> 
> Yes, in Python it works exactly the same:

No, not quite. In Python any variable defined inside the if
block is
visible on the outside, so

def test1():
  if True:
    a=1
    b=2
  print a,b

test1()

works as well. So that could create some problems, unless
duchain
allows to easily and fast search to those contexts,
recursively.

Andreas

-- 
You are the only person to ever get this message.

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )