Re: [Python-Dev] Memory management in the AST parser & compiler

2005-11-15 Thread Baczek
2005/11/15, Nick Coghlan <[EMAIL PROTECTED]>:
> Specifically, the body of the entire function is written inside a switch
> statement, with 'break' then used as the equivalent of "raise Exception". For
> example:
>
>PyObject* switchAsTry()
>{
>  switch(0) {
>default:
>  /* Real function body goes here */
>  return result;
>  }
>  /* Error cleanup code goes here */
>  return NULL;
>}
>
> It avoids the potential for labelling problems that arises when goto's are
> used for resource cleanup. It's a far cry from real exception handling, but
> it's the best solution I've seen within the limits of C.


do {


} while (0);


Same benefit and saves some typing :)

Now back to my usual hiding place.


--
{ Marek Baczyński :: UIN 57114871 :: GG 161671 :: JID [EMAIL PROTECTED]  }
{ http://www.vlo.ids.gda.pl/ | imbaczek at poczta fm | http://www.promode.org }
.. .. .. .. ... ... .. evolve or face extinction .. ... ... .. .. .. ..
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] math.areclose ...?

2006-02-06 Thread Baczek
2006/2/6, Raymond Hettinger <[EMAIL PROTECTED]>:
> The original Numeric definition is likely to be better for people who know
> what they're doing; however, I still question whether it is an appropriate
> remedy for the beginner issue
>  of why 1.1 + 1.1 + 1.1 doesn't equal 3.3.

Beginners won't know about math.areclose anyway (and if they will,
they won't use it, thinking "why bother?"), and having a standard,
well-behaved and *correct* version of a useful function can't hurt.

--
{ Marek Baczyński :: UIN 57114871 :: GG 161671 :: JID [EMAIL PROTECTED]  }
{ http://www.vlo.ids.gda.pl/ | imbaczek at poczta fm | http://www.promode.org }
.. .. .. .. ... ... .. evolve or face extinction .. ... ... .. .. .. ..
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Marek \&quot;Baczek\" Baczyński
2007/2/12, Benji York <[EMAIL PROTECTED]>:
> Collin Winter wrote:
> > There's a connection, but I'd say it's the wrong one. In C, "x->y"
> > dereferences x, while in Python, "x->y" would dereference y. That's
> > just begging for trouble.
>
> Then the syntax should obviously be "x<-y".


Someone with OCaml background could confuse that with an assignment 


-- 
Marek Baczyński
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Re: Re: 2.4 news reaches interesting places

2004-12-13 Thread Marek &quot;Baczek" BaczyÅski
On Mon, 13 Dec 2004 12:57:07 PST, Bill Janssen <[EMAIL PROTECTED]> wrote:
> Apparently the Python program, which applies the same re substitutions
> in the same order as the Perl program, takes 3 times as long to run.
> He thinks it's because of mutable strings in Perl -- that is, he
> thinks the string being modified (which is long, a whole file full of
> text) is modified in place in Perl, but has to be re-consed in Python.

Did he use re.compile?

-- 
{ Marek BaczyÅski :: UIN 57114871 :: GG 161671 :: JID [EMAIL PROTECTED]  }
{ http://www.vlo.ids.gda.pl/ | imbaczek at poczta fm | http://www.promode.org }
.. .. .. .. ... ... .. evolve or face extinction .. ... ... .. .. .. ..
___
Python-Dev mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Explicit Lexical Scoping (pre-PEP?)

2006-07-05 Thread Marek \&quot;Baczek\" Baczyński
2006/7/5, Just van Rossum <[EMAIL PROTECTED]>:
> Guido van Rossum wrote:
>
> > On 7/5/06, Phillip J. Eby <[EMAIL PROTECTED]> wrote:
> > > Did you also consider and reject:
> > >
> > > * Alternate binding operators (e.g. ":=", ".=", etc.)
> >
> > Brr.
>
> That's too bad :(
>
> I still find a rebinding operator (":=" being my favorite) much, *much*
> more appealing than any of the alternative proposals. It's beautifully
> symmetrical with "assignment means local". It also pretty much makes the
> global statement redundant.
>
> The only downside I see is that it may cause a fairly big shift in
> style: I for one would use := for rebinding local names. While I think
> that would be an improvement (eg. by catching typo's earlier), it's
> *different*.



I suggest <- as an assignment operator instead of := - it's used in
OCaml and it looks *very* different, yet still makes sense.

  x = 0
  print x
  def f():
x =  1 # bind locally
print x
  def g():
x <- 42 # assign "lexically"
print x
  f()
  print x
  g()
  print x

prints

0
1
0
42
42


___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com