String vs Symbol use cases
Are there some best practices regarding using strings and symbols? For example I am processing XML and I might query it via xpath... myDocument xPath: 'entity/@name', or myDocument xPath: #'entity/@name' or myDocument / 'entity' @ 'name' or myDocument / #entity @ #name. So does it make sense to prefer one over the other here? Any opinion/advice appreciated, Peter
I prefer the last one. Doru On Thu, Sep 17, 2015 at 4:10 PM, Peter Uhnák <i.uhnak@gmail.com> wrote:
Are there some best practices regarding using strings and symbols?
For example I am processing XML and I might query it via xpath...
myDocument xPath: 'entity/@name',
or
myDocument xPath: #'entity/@name'
or
myDocument / 'entity' @ 'name'
or
myDocument / #entity @ #name.
So does it make sense to prefer one over the other here?
Any opinion/advice appreciated,
Peter
-- www.tudorgirba.com "Every thing has its own flow"
Ideally, both:
myDocument / 'entity' @ 'name'
or
myDocument / #entity @ #name.
should work. You are here defining a small api to formulate xpath queries, which is great. However, I am not sure that your api will cover all features offered by xpath. The syntax "myDocument xPath: 'entity/@nameââ may also be supported. Alexandre
On Sep 17, 2015, at 11:10 AM, Peter Uhnák <i.uhnak@gmail.com> wrote:
Are there some best practices regarding using strings and symbols?
For example I am processing XML and I might query it via xpath...
myDocument xPath: 'entity/@name',
or
myDocument xPath: #'entity/@name'
or
myDocument / 'entity' @ 'name'
or
myDocument / #entity @ #name.
So does it make sense to prefer one over the other here?
Any opinion/advice appreciated,
Peter
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Ah okay! Alexandre
On Sep 17, 2015, at 2:55 PM, Peter Uhnák <i.uhnak@gmail.com> wrote:
You are here defining a small api to formulate xpath queries, which is great.
Nono, this is XPath library by Hernan (available from Catalog Browser), I'm just using it.
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Hernan maintained the old lib. The PharoExtras/XPath lib you get from the catalog or config browsers was rewritten and questions/bugs should be sent to me. Note it is incompatible with Pastell, so you can't have both in the same image.
Sent: Thursday, September 17, 2015 at 4:07 PM From: "Alexandre Bergel" <alexandre.bergel@me.com> To: "Any question about pharo is welcome" <pharo-users@lists.pharo.org> Subject: Re: [Pharo-users] String vs Symbol use cases
Ah okay!
Alexandre
On Sep 17, 2015, at 2:55 PM, Peter Uhnák <i.uhnak@gmail.com> wrote:
You are here defining a small api to formulate xpath queries, which is great.
Nono, this is XPath library by Hernan (available from Catalog Browser), I'm just using it.
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
participants (4)
-
Alexandre Bergel -
monty -
Peter Uhnák -
Tudor Girba