Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Smarty 3.0 Alpha 1: Proof of Concept
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Mar 02, 2009 8:06 pm    Post subject: Reply with quote

Quote:
I think you should dedicate a forum for smarty3-dev so we can dedicate one thread to each issue making it easier to organize everything.


Done, and I moved this topic into it.
Back to top
View user's profile Send private message Visit poster's website
yankee
Smarty Rookie


Joined: 02 Mar 2009
Posts: 31

PostPosted: Thu Mar 05, 2009 4:51 pm    Post subject: Reply with quote

mohrt wrote:
Autoloaded methods do not get the benefits of a PHP op-code cache, and that is crucial to your application's performance. It's pretty easy to get around anyways.

Why is that? There should not be any difference in how these classes are loaded (both times you probably use include) and thus there should be no difference in how op-code caching performs.

Can you provide a link to somewhere where the mentioned issue is documented?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Mar 05, 2009 5:18 pm    Post subject: Reply with quote

I heard this straight from Andrei Zmievski. Googling did find some (unofficial) links about it:

http://pooteeweet.org/blog/538/

http://forum.lighttpd.net/topic/17500

and a quote from Zend:

Quote:
Rasmus explained that opcode caches - including APC - will replace class and function definitions with no-ops in the cached op_arrays, leaving the resolution to compile time. Things like autoload and conditional includes wreck opcode caching optimization, because they require the runtime context.
Back to top
View user's profile Send private message Visit poster's website
yankee
Smarty Rookie


Joined: 02 Mar 2009
Posts: 31

PostPosted: Thu Mar 05, 2009 6:00 pm    Post subject: Reply with quote

mohrt wrote:
I heard this straight from Andrei Zmievski. Googling did find some (unofficial) links about it:

Very interesting Smile.

I read the linked texts and I searched the web for more information. As far as I understood the documents the issue is as follows:
Given something like this:
Code:
if (getWhichClassToUse() ==1)
{
  class MyClass
  {
// some stuff
  }
}
elseif (getWhichClassToUse() ==2)
{
  class MyClass
  {
// some stuff that may different (for example for another platform)
  }
}

In this code it's not possible to determine which class will be used at compile time. PHP has to decide this at runtime and thus time is spent at runtime to load the appropiate class.

Of course this means, that the class will not be cached if it is in any conditional statement at all. This has nothing todo with the autoload feature shiped with php. This will destroy any type of autoloading, because autoloading is always conditional (otherwise it would not be autoloading, but loading everything you *might* need at once). Thus your own autoloader cannnot be superior to php's autoloader.

It *might* actually speed up your performance a little if you'd just drop your autoloading all together. Unfortunatelly I have not enough knowledge about php's op-code cachers to make a well founded statment about whether this is a good idea (One issue is the memory usage for example. Is the op-code cacher smart enough to keep no more than one copy of the cached code in memory, even if there are multiple requests at the same time?)
Back to top
View user's profile Send private message
douglassdavis
Smarty Junkie


Joined: 21 Jan 2008
Posts: 541

PostPosted: Wed Mar 18, 2009 2:55 pm    Post subject: noprint modifier Reply with quote

I don't know if any one else has run into the same issue as I have. But I will describe. Sometimes I want to do some code such as

{$count++}
or
{$var|@print_r}

But I don't want to output the result of the expression. Perhaps there could be a noprint modifier, to not print out the result of an expression.

Such as described here:

http://www.phpinsider.com/smarty-forum/viewtopic.php?t=15111&start=0&postdays=0&postorder=asc&highlight=


Or, maybe some other language feature that says "don't print"

Just an idea - if it would be useful to others.
Back to top
View user's profile Send private message
webtweakers
Smarty Rookie


Joined: 20 Apr 2009
Posts: 7

PostPosted: Mon Apr 20, 2009 9:03 pm    Post subject: Smarty 3 features Reply with quote

I just read the readme and the plans for Smarty 3 look brilliant! When is it ready? Smile

Not sure it's possible at the moment, but someone already asked for it: better support for objects would be sublime, so something like:

{$car->getSpeed()}

or of course:

{$car.getSpeed()}

While building the whole application in a java-ish way, using objects etc, I'll have to bend this concept and use associative arrays just to support Smarty. It's a shame... Would be great if objects were better supported.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Apr 20, 2009 9:42 pm    Post subject: Reply with quote

Objects and object chaining are supported in Smarty 3


{$foo->bar()}
{$foo->bar->go()}
{$foo->bar()->go()}
etc.
Back to top
View user's profile Send private message
jLix
Smarty Regular


Joined: 01 Apr 2009
Posts: 59
Location: Lowlands, EU

PostPosted: Tue Apr 21, 2009 2:37 pm    Post subject: Reply with quote

I would prefer the dot-notation that webtweakers mentioned in {$car.getSpeed()}. It's slightly shorter and a lot prettier than the ugly PHP->notation and it looks more familiar to front-end/template developers as it's the same as in JavaScript.
_________________
http://jlix.net/extensions/smarty
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Apr 21, 2009 2:37 pm    Post subject: Reply with quote

Smarty already uses dot notation for array access.
Back to top
View user's profile Send private message Visit poster's website
jLix
Smarty Regular


Joined: 01 Apr 2009
Posts: 59
Location: Lowlands, EU

PostPosted: Tue Apr 21, 2009 9:52 pm    Post subject: Reply with quote

Could it not be used for both?
_________________
http://jlix.net/extensions/smarty
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Apr 21, 2009 10:04 pm    Post subject: Reply with quote

jLix wrote:
Could it not be used for both?


Not really. The lexer doesn't know the assigned var type at compile time. It could check at runtime, but this adds another layer of complexity to the runtime logic. This also creates a level of ambiguity that could lend to difficult debugging when problems arise. Just use $foo.bar for arrays and $foo->bar for objects. simple. Smile
Back to top
View user's profile Send private message Visit poster's website
webtweakers
Smarty Rookie


Joined: 20 Apr 2009
Posts: 7

PostPosted: Tue Apr 28, 2009 11:54 am    Post subject: Reply with quote

mohrt wrote:
jLix wrote:
Could it not be used for both?


Not really. The lexer doesn't know the assigned var type at compile time. It could check at runtime, but this adds another layer of complexity to the runtime logic. This also creates a level of ambiguity that could lend to difficult debugging when problems arise. Just use $foo.bar for arrays and $foo->bar for objects. simple. Smile


Hm.. I must say, I'm already happy that objects are being supported - this lifts Smarty up to modern development - so this seemingly minor issue should be something we can live with, right? Or wrong? I mean, I suppose a lot of templates are being designed by designers and not the back-end developers. These designers might not know if something is an object or an array and consequently don't know how to address it. Besides this, it would be nice to have a simple transparent method of addressing properties/methods on a variable without knowing the nitty gritty.

But I do understand your point of view completely (being a back-end developer myself). I'm sure there's an elegant and efficient way to solve this. Smile
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Apr 28, 2009 1:52 pm    Post subject: Reply with quote

The only way feasible around it would create more runtime processing. {$foo.bar} could get compiled into something like $smarty->fetch_value('foo','bar'), and the runtime would check if $foo is an object or array, and get foo from either or. As you can see, this creates an extra method call on each variable iteration. Not good.

I think we can live with $foo.bar and $foo->bar. Although this may not be perfect for the designer, it will keep the developer's debug frustrations to a minimum.
Back to top
View user's profile Send private message Visit poster's website
webtweakers
Smarty Rookie


Joined: 20 Apr 2009
Posts: 7

PostPosted: Tue Apr 28, 2009 1:59 pm    Post subject: Reply with quote

I agree, and definitely for the initial 3.0 release I would recommend to keep things as simple and clean as possible.
Back to top
View user's profile Send private message
douglassdavis
Smarty Junkie


Joined: 21 Jan 2008
Posts: 541

PostPosted: Tue Apr 28, 2009 9:25 pm    Post subject: Reply with quote

it would be nice to be able to get the directory of the current template from within the template.


I ask because i have a template (template A) that can include another template (template B) from another directory, but it's configurable so it could come from ANY directory.

Since template B can't find out what directory it is in, it can't do an include of template C in the same directory. An absolute path is needed, and without knowing the its own directory, I don't know how that's supposed to happen.


See http://www.phpinsider.com/smarty-forum/viewtopic.php?t=15323&highlight=
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3 All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
Page 5 of 7

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP