"with" elsewhere

at 2006-10-08 in Further reading by friebe (0 comments)

You might know the with statement from JavaScript or Pascal (where it saves a few keystrokes by "auto-importing" the object).

  Person.Name= 'Timm';
Person.Id= 1549;

{* equvialent *}
With Person Do Begin
Name= 'Timm';
Id= 1549;
End;

The XP framework also has with, not really as statement, but as a noop function:
  with ($p= &new Person()); {
$p->name= 'Timm';
$p->id= 1549;
}

You could basically omit with () and the brackets, they serve no purpose except making the above bit more readable (especially when you're using lots of assignments or method calls on an object).

Now in Python, with serves a different purpose - in a quite flexible way: What's New in Python 2.5 - The 'with' statement.



Subscribe

You can subscribe to the XP framework's news by using RSS syndication.


Categories

News
General
PHP5
Announcements
RFCs
Further reading
Examples
Editorial
EASC
Experiments
Unittests
Databases
5.8-SERIES
Unicode
Language
5.9-SERIES

Related

Find related articles by a search for «"with"».