Re: [Pharo-users] Is a non-break space whitespace?

2017-09-25 Thread Ben Coman
On Sun, Sep 24, 2017 at 7:53 PM, PBKResearch 
wrote:

> Hello All
>
>
>
> I have a little puzzle to disturb your Sunday lunch, maybe. I have been
> scraping text data from web pages, which often comes with redundant space
> before or after. I routinely use ‘trim’ on the final string output, but I
> have found cases where there are still redundant spaces. Inspecting the
> results, I find that the characters are non-break spaces (codepoint 160,
> Unicode U+00A0). Looking at the code, String>>#trim depends on
> Character>>#isSeparator, which does not answer true for a non-break space.
> I can use trimBoth: [:char| char asInteger = 160] to remove the redundant
> spaces if I know where to expect them, so it is not a major problem. But
> the question remains: should non-break space be included in the list of
> separators in Character>>#isSeparator.
>
>
>
> Peter Kenny
>
>
>

Off the cuff.. intuitively "by definition" a Non-Break space seems to be
Not-a-Separator.
If the web pages you are scraping are misusing non-break space to munge
formatting, that is not something to be solved by modifying semantics of
#isSeparator.
Stef's suggestion for a selector that takes a list of separators seems
appropriate.

cheers -ben


Re: [Pharo-users] Is a non-break space whitespace?

2017-09-25 Thread Richard Sargent
Ben Coman wrote
> On Sun, Sep 24, 2017 at 7:53 PM, PBKResearch <

> peter@.co

> >
> wrote:
> 
>> Hello All
>>
>>
>>
>> I have a little puzzle to disturb your Sunday lunch, maybe. I have been
>> scraping text data from web pages, which often comes with redundant space
>> before or after. I routinely use ‘trim’ on the final string output, but I
>> have found cases where there are still redundant spaces. Inspecting the
>> results, I find that the characters are non-break spaces (codepoint 160,
>> Unicode U+00A0). Looking at the code, String>>#trim depends on
>> Character>>#isSeparator, which does not answer true for a non-break
>> space.
>> I can use trimBoth: [:char| char asInteger = 160] to remove the redundant
>> spaces if I know where to expect them, so it is not a major problem. But
>> the question remains: should non-break space be included in the list of
>> separators in Character>>#isSeparator.
>>
>>
>>
>> Peter Kenny
>>
>>
>>
> 
> Off the cuff.. intuitively "by definition" a Non-Break space seems to be
> Not-a-Separator.
> If the web pages you are scraping are misusing non-break space to munge
> formatting, that is not something to be solved by modifying semantics of
> #isSeparator.
> Stef's suggestion for a selector that takes a list of separators seems
> appropriate.


Rather than off-the-cuffing anything, please honour the Unicode Character
Properties. Refer to
https://en.wikipedia.org/wiki/Unicode_character_property#Whitespace, among
others.


> cheers -ben





--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] Is a non-break space whitespace?

2017-09-25 Thread Sven Van Caekenberghe

> On 25 Sep 2017, at 09:53, Richard Sargent 
>  wrote:
> 
> Ben Coman wrote
>> On Sun, Sep 24, 2017 at 7:53 PM, PBKResearch <
> 
>> peter@.co
> 
>> >
>> wrote:
>> 
>>> Hello All
>>> 
>>> 
>>> 
>>> I have a little puzzle to disturb your Sunday lunch, maybe. I have been
>>> scraping text data from web pages, which often comes with redundant space
>>> before or after. I routinely use ‘trim’ on the final string output, but I
>>> have found cases where there are still redundant spaces. Inspecting the
>>> results, I find that the characters are non-break spaces (codepoint 160,
>>> Unicode U+00A0). Looking at the code, String>>#trim depends on
>>> Character>>#isSeparator, which does not answer true for a non-break
>>> space.
>>> I can use trimBoth: [:char| char asInteger = 160] to remove the redundant
>>> spaces if I know where to expect them, so it is not a major problem. But
>>> the question remains: should non-break space be included in the list of
>>> separators in Character>>#isSeparator.
>>> 
>>> 
>>> 
>>> Peter Kenny
>>> 
>>> 
>>> 
>> 
>> Off the cuff.. intuitively "by definition" a Non-Break space seems to be
>> Not-a-Separator.
>> If the web pages you are scraping are misusing non-break space to munge
>> formatting, that is not something to be solved by modifying semantics of
>> #isSeparator.
>> Stef's suggestion for a selector that takes a list of separators seems
>> appropriate.
> 
> 
> Rather than off-the-cuffing anything, please honour the Unicode Character
> Properties. Refer to
> https://en.wikipedia.org/wiki/Unicode_character_property#Whitespace, among
> others.

The Pharo Unicode Project (http://www.smalltalkhub.com/#!/~Pharo/Unicode) 
offers support for these properties.



There is a performance cost though (it is a big database to load/use).

I would not immediately change #isSeparator though.

>> cheers -ben
> 
> 
> 
> 
> 
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] Is a non-break space whitespace?

2017-09-25 Thread PBKResearch
Hello

 

One way of dealing with this in a general way is to introduce a new predicate 
#isWhitespace for Character, maybe following the Wikipedia definition as 
Richard suggests, and then either (a) recode String>>#trim and friends to use 
#isWhitespace rather than #isSeparator or (b) introduce a new operation 
String>>#trimWhitespace which uses #isWhitespace.

@stef. There is already an operation which allows us to specify the characters 
to be trimmed, which I mentioned in my original post. We write trimBoth: 
aBlock, where aBlock value: char answers true if char is to be trimmed. I knew 
I could solve my immediate problem like this; I just wondered if there should 
be something more general.

 

Peter Kenny

 

From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of 
Sven Van Caekenberghe
Sent: 25 September 2017 09:10
To: Any question about pharo is welcome 
Subject: Re: [Pharo-users] Is a non-break space whitespace?

 





On 25 Sep 2017, at 09:53, Richard Sargent mailto:richard.sarg...@gemtalksystems.com> > wrote:

Ben Coman wrote



On Sun, Sep 24, 2017 at 7:53 PM, PBKResearch <





  peter@.co





>
wrote:




Hello All



I have a little puzzle to disturb your Sunday lunch, maybe. I have been
scraping text data from web pages, which often comes with redundant space
before or after. I routinely use ‘trim’ on the final string output, but I
have found cases where there are still redundant spaces. Inspecting the
results, I find that the characters are non-break spaces (codepoint 160,
Unicode U+00A0). Looking at the code, String>>#trim depends on
Character>>#isSeparator, which does not answer true for a non-break
space.
I can use trimBoth: [:char| char asInteger = 160] to remove the redundant
spaces if I know where to expect them, so it is not a major problem. But
the question remains: should non-break space be included in the list of
separators in Character>>#isSeparator.



Peter Kenny





Off the cuff.. intuitively "by definition" a Non-Break space seems to be
Not-a-Separator.
If the web pages you are scraping are misusing non-break space to munge
formatting, that is not something to be solved by modifying semantics of
#isSeparator.
Stef's suggestion for a selector that takes a list of separators seems
appropriate.



Rather than off-the-cuffing anything, please honour the Unicode Character
Properties. Refer to
https://en.wikipedia.org/wiki/Unicode_character_property#Whitespace, among
others.

 

The Pharo Unicode Project (http://www.smalltalkhub.com/#!/~Pharo/Unicode) 
offers support for these properties.

 



 

There is a performance cost though (it is a big database to load/use).

 

I would not immediately change #isSeparator though.





cheers -ben






--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

 



[Pharo-users] How to find if a method is being executed in a given process

2017-09-25 Thread Steven Costiou
Hi, 

how can i know if a given method is being executed ? 

For ex.: 

process := [[mycondition] whileTrue:[ myObject doStuff. myDelay wait]]
fork 

I want to suspend process and find if doStuff is being executed or if
process is waiting. 

How could i do that ? 

Steven. 

Re: [Pharo-users] How to find if a method is being executed in a given process

2017-09-25 Thread jtuc...@objektfabrik.de

Steven


You could add use a semaphore if changing code is an option.
We once used MethodWrappers in VAST to answer a similar question 
regarding whether a body of code can be removed from a system.


Joachim



Am 25.09.17 um 12:06 schrieb Steven Costiou:


Hi,

how can i know if a given method is being executed ?

For ex.:

process := [[mycondition] whileTrue:[ myObject doStuff. myDelay wait]] 
fork


I want to suspend process and find if doStuff is being executed or if 
process is waiting.


How could i do that ?

Steven.



--
---
Objektfabrik Joachim Tuchel  mailto:jtuc...@objektfabrik.de
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1




Re: [Pharo-users] How to find if a method is being executed in a given process

2017-09-25 Thread Marcus Denker

> On 25 Sep 2017, at 12:06, Steven Costiou  wrote:
> 
> Hi,
> 
> how can i know if a given method is being executed ?
> 
> For ex.:
> 
> process := [[mycondition] whileTrue:[ myObject doStuff. myDelay wait]] fork
> 
> I want to suspend process and find if doStuff is being executed or if process 
> is waiting.
> 
> How could i do that ?]
> 
> 
you could iterate all processes, there then get the stack and look up the 
sender chain
if the method is somewhere to be found. If yes -> it is exectuted right now.

One problem is that which methods are on the stack changes, so you should
try to avoid process switches while doing the analysis.

Marcus





Re: [Pharo-users] Is a non-break space whitespace?

2017-09-25 Thread Ben Coman
On Mon, Sep 25, 2017 at 3:53 PM, Richard Sargent <
richard.sarg...@gemtalksystems.com> wrote:

> Ben Coman wrote
> > On Sun, Sep 24, 2017 at 7:53 PM, PBKResearch <
>
> > peter@.co
>
> > >
> > wrote:
> >
> >> Hello All
> >>
> >>
> >>
> >> I have a little puzzle to disturb your Sunday lunch, maybe. I have been
> >> scraping text data from web pages, which often comes with redundant
> space
> >> before or after. I routinely use ‘trim’ on the final string output, but
> I
> >> have found cases where there are still redundant spaces. Inspecting the
> >> results, I find that the characters are non-break spaces (codepoint 160,
> >> Unicode U+00A0). Looking at the code, String>>#trim depends on
> >> Character>>#isSeparator, which does not answer true for a non-break
> >> space.
> >> I can use trimBoth: [:char| char asInteger = 160] to remove the
> redundant
> >> spaces if I know where to expect them, so it is not a major problem. But
> >> the question remains: should non-break space be included in the list of
> >> separators in Character>>#isSeparator.
> >>
> >>
> >>
> >> Peter Kenny
> >>
> >>
> >>
> >
> > Off the cuff.. intuitively "by definition" a Non-Break space seems to be
> > Not-a-Separator.
> > If the web pages you are scraping are misusing non-break space to munge
> > formatting, that is not something to be solved by modifying semantics of
> > #isSeparator.
> > Stef's suggestion for a selector that takes a list of separators seems
> > appropriate.
>
>
> Rather than off-the-cuffing anything, please honour the Unicode Character
> Properties. Refer to
> https://en.wikipedia.org/wiki/Unicode_character_property#Whitespace, among
> others.
>

I hope it was clear I wasn't speaking from a position of authoritative
knowledge..
Nice to learn something new.  Thanks for the correction.
cheers -ben


Re: [Pharo-users] How to find if a method is being executed in a given process

2017-09-25 Thread Ben Coman
On Mon, Sep 25, 2017 at 6:06 PM, Steven Costiou 
wrote:

> Hi,
>
> how can i know if a given method is being executed ?
>
> For ex.:
>
> process := [[mycondition] whileTrue:[ myObject doStuff. myDelay wait]] fork
>
> I want to suspend process and find if doStuff is being executed or if
> process is waiting.
>
I'm not sure if your wanting something more built in, or just "some way",
so for the latter, consider wrapping in with your own status flags...

status := #setup.
watcher := [[true] whileTrue:[
Transcript crShow: status.
900 milliSeconds wait]
] forkAt:36.
result := 0.
worker := [[true] whileTrue:[
status := #WORKING.
1 second wait.
result := result + 1.
Transcript crShow: result.
status:=#waiting.
3 seconds wait]
] forkAt:35.
worker suspend.
worker resume.

cheers -ben


[Pharo-users] Testing a Unicode Character's Category

2017-09-25 Thread Prof. Andrew P. Black
The Pharo image has a table of Unicode Character Categories in a class variable 
GeneralCategory of class Unicode.  But there do not seem to be many methods to 
interpret this data.  For example, while there is a method

Unicode class >> #isDigit: aCharacter

that checks if the Unicode category of aCharacter is Nd, and 

Unicode class >> #isLetter: aCharacter

that checks if aCharacter is in one of the letter categories, there does not 
seem to be a general way of asking “what is the category of this character”.

I want to check if a character is a mathematical symbol, that is, if it is in 
the Unicode Category Sm.  What’s the right way of doing this?
Would it be reasonable to add a method Unicode class >> #category: aCharacter 
that answers one of the 29 category symbols #Cc to #Zs?  Or “is” methods for 
each category?

Andrew


Re: [Pharo-users] How to find if a method is being executed in a given process

2017-09-25 Thread Steven Costiou
Le 2017-09-25 12:21, jtuc...@objektfabrik.de wrote : 

> Steven
> 
> You could add use a semaphore if changing code is an option.
> We once used MethodWrappers in VAST to answer a similar question regarding 
> whether a body of code can be removed from a system.
> 
> Joachim

This is exactly my usecase, i need to remove code that may be called by
a method on the stack - and i know exactly which method. However my base
hypothesis is that it is in an already running process (maybe a loop)
and that part i cannot change. Is there an existing Pharo implementation
of MethodWrappers ? 

Le 2017-09-25 14:32, Ben Coman wrote :

> I'm not sure if your wanting something more built in, or just "some way", 
> 
> so for the latter, consider wrapping in with your own status flags... 
> 
> status := #setup. 
> watcher := [[true] whileTrue:[  
> Transcript crShow: status.  
> 900 milliSeconds wait] 
> ] forkAt:36. 
> result := 0. 
> worker := [[true] whileTrue:[  
> status := #WORKING.  
> 1 second wait. 
> result := result + 1.  
> Transcript crShow: result.  
> status:=#waiting.  
> 3 seconds wait] 
> ] forkAt:35. 
> worker suspend. 
> worker resume. 
> 
> cheers -ben

 I want to avoid adding control in the code, because hypothetically the
process i want to check is already running and possibly written by
somebody else. I've think about a similar solution using metalinks, but
if the loop is on the stack then i don't know what i can do. 

Le 2017-09-25 12:42, Marcus Denker a wrote :

> you could iterate all processes, there then get the stack and look up the 
> sender chain
> if the method is somewhere to be found. If yes -> it is exectuted right now. 
> One problem is that which methods are on the stack changes, so you should 
> try to avoid process switches while doing the analysis. 
> 
> Marcus

Ok so if i know which process to analyse, i can just do something like
the following that i found in the Halt class: 

[ cntxt isNil ] whileFalse: [ 
cntxt selector = aSelector ifTrue: [ ... ].
cntxt := cntxt sender ] 

But if i actually found the method i was looking for on the stack, can i
somehow ask the suspended context to "execute" until it returns from
this method ? 

Steven. 

  

Re: [Pharo-users] Is a non-break space whitespace?

2017-09-25 Thread stephan

On 25-09-17 09:53, Richard Sargent wrote:

Rather than off-the-cuffing anything, please honour the Unicode Character
Properties. Refer to
https://en.wikipedia.org/wiki/Unicode_character_property#Whitespace, among
others.


That is a good idea. And it won't help you if you scrape data from the 
web, as you'll find plenty of bad encoding. And unclarity over which 
version of which standard was used (see mongolian vowel separator)


Stephan




Re: [Pharo-users] Pharo 7 license question

2017-09-25 Thread Jimmie Houchin

Hello, thanks for the reply.

I have thought about recursive and unfortunately it is not in my opinion 
an adequate or equivalent substitute. It may be inoffensive, but it is 
not accurate in conveying those properties or characteristics of the 
GPL. Something that is recursive generally makes repeated calls to 
itself. It is neatly contained and does not propagate outside of itself. 
Calling a recursive method does not make the call chain all the way up 
to main recursive. The recursive method does its recursion and generally 
returns its result back to the caller, ending the recursion. The only 
thing the caller receives is the results, not the recursion.


There are many positive cultural references to something viral or 
infect(ious). For something to go viral, depends on what that something 
is. She has an infectious smile, or laugh. Even in biology where we get 
the term viral. It is not absolutely or always negative. There are 
things that scientist attempt to use viral characteristics to do good 
things. Context is everything.


There are no words a GPL proponent could provide which adequately or 
otherwise describe the viral characteristic of the GPL that would be 
considered positive by a GPL opponent.


Back to context.

To a GPL proponent, the viral nature of the GPL is considered a positive 
and good thing. It is the primary reason to choose and use the GPL.


To the GPL opponent, the viral nature of the GPL is considered a 
negative and bad thing. It is the primary reason to oppose and to avoid 
using the GPL.


Two side both viewing the same exact thing and understanding it very 
differently. One positive, one negative. There is no positive spin for 
this aspect of the GPL for someone wishing to avoid that aspect. No 
matter what words are chosen.


For the MIT/BSD person we don't necessarily care if you wish to license 
your software under the GPL. What we care is that your software is 
expressly and explicitly trying to override our choices and compel us to 
become GPL. That is what we don't like. The fact that GPL software is 
GPL software in perpetuity is okay. Just leave us alone. But we know 
that is not how the GPL works.



A perspective occurred to me this morning. The original author of GPL 
software is not bound by the GPL. They have freedoms the GPL takes away. 
They have the freedom to turn their software into closed source, 
proprietary software. They have the freedom to not release all of their 
modifications. They have the freedom to not infect all their other 
software which may use this otherwise GPLd code. They have freedom to 
relicense their software. They have many, many freedoms which the GPL 
removes from everyone who receives the GPLd software. The original 
author of GPL software has for himself MIT like freedoms.


What we on the MIT/BSD side of things want is for everybody to have all 
of the freedoms the original author of the software has. People who 
receive our software maintain all freedoms.


I have seen over the years many GPL licensed projects change to some 
more permissive license. Once they did so, the success of the project 
improved. They had greater buy in, and an increase in use. It increased 
the size of the open source community and an increase in the code base 
of an open source project. These are good things.


Here I will let it rest. I don't know what else can be expressed to help 
clarify both sides.


Jimmie






On 09/22/2017 03:27 AM, Hilaire wrote:

The appropriate and neutral term to describe GPL licence is "recursive".

GPL licence was designed to build a better computing community, where 
freedom is 1st consideration, even at the expense of a lower acceptance.


Hilaire


Le 20/09/2017 à 21:30, Jimmie Houchin a écrit :
So my question to you. What words would you use instead of viral and 
infection that equally describe that characteristic of the GPL and 
variants?







Re: [Pharo-users] How to find if a method is being executed in a given process

2017-09-25 Thread Ben Coman
On Mon, Sep 25, 2017 at 9:19 PM, Steven Costiou 
wrote:

>
>
> Le 2017-09-25 12:21, jtuc...@objektfabrik.de wrote :
>
> Steven
>
> You could add use a semaphore if changing code is an option.
> We once used MethodWrappers in VAST to answer a similar question regarding
> whether a body of code can be removed from a system.
>
> Joachim
>
>
>
> This is exactly my usecase, i need to remove code that may be called by a
> method on the stack - and i know exactly which method. However my base
> hypothesis is that it is in an already running process (maybe a loop) and
> that part i cannot change. Is there an existing Pharo implementation of
> MethodWrappers ?
>
>
>
> Le 2017-09-25 14:32, Ben Coman wrote :
>
>
> I'm not sure if your wanting something more built in, or just "some way",
> so for the latter, consider wrapping in with your own status flags...
>
> status := #setup.
> watcher := [[true] whileTrue:[
> Transcript crShow: status.
> 900 milliSeconds wait]
> ] forkAt:36.
> result := 0.
> worker := [[true] whileTrue:[
> status := #WORKING.
> 1 second wait.
> result := result + 1.
> Transcript crShow: result.
> status:=#waiting.
> 3 seconds wait]
> ] forkAt:35.
> worker suspend.
> worker resume.
>
> cheers -ben
>
>
>  I want to avoid adding control in the code, because hypothetically the
> process i want to check is already running and possibly written by somebody
> else. I've think about a similar solution using metalinks, but if the loop
> is on the stack then i don't know what i can do.
>
>
>
> Le 2017-09-25 12:42, Marcus Denker a wrote :
>
> you could iterate all processes, there then get the stack and look up the
> sender chain
> if the method is somewhere to be found. If yes -> it is exectuted right
> now.
>
> One problem is that which methods are on the stack changes, so you should
> try to avoid process switches while doing the analysis.
>
> Marcus
>
> Ok so if i know which process to analyse, i can just do something like the
> following that i found in the Halt class:
>
> [ cntxt isNil ] whileFalse: [
> cntxt selector = aSelector ifTrue: [ ... ].
> cntxt := cntxt sender ]
>
> But if i actually found the method i was looking for on the stack, can i
> somehow ask the suspended context to "execute" until it returns from this
> method ?
>
> Steven.
>
>
>
See Halt class >> now has pragma .
Look at its senders and maybe Process>>compelte: give you some dieas.

cheers -ben


Re: [Pharo-users] How to find if a method is being executed in a given process

2017-09-25 Thread Marcus Denker

> On 25 Sep 2017, at 15:19, Steven Costiou  wrote:
> 
>  
> Le 2017-09-25 12:21, jtuc...@objektfabrik.de wrote :
> 
>> Steven
>> 
>> You could add use a semaphore if changing code is an option.
>> We once used MethodWrappers in VAST to answer a similar question regarding 
>> whether a body of code can be removed from a system.
>> 
>> Joachim
>  
> This is exactly my usecase, i need to remove code that may be called by a 
> method on the stack - and i know exactly which method. However my base 
> hypothesis is that it is in an already running process (maybe a loop) and 
> that part i cannot change. Is there an existing Pharo implementation of 
> MethodWrappers ?
> 
> 

I do not know how MethodWrappers would solve this.. in the end, they do 
something very similar to what happens when you put a MetaLink on a methodNode…
(we do not wrap but recompile the AST instead, wrapping is used if the method 
has a primitive, though).

You can even see MetaLinks as “just” a generalisation of methodWrappers to any 
AST node.

So you would have the same problem: the wrapper is used *for the next call*.

Marcus

Re: [Pharo-users] NeoJSON and polymorphism

2017-09-25 Thread Juraj Kubelka
Hi Sven,

thank you! 

In the NeoJSON repository, you likely want to merge 
Neo-JSON-Core-SvenVanCaekenberghe.43 and 44. And the same for the test cases.

> On Sep 24, 2017, at 06:05, Sven Van Caekenberghe  wrote:
> 
> Hi Juraj,
> 
> This would be a simpler form of the type/class tags that are often used in 
> JSON encoding. Since there are many ways to do this, there cannot be one 
> solution. NeoJSON mapping was not designed to cover these cases. Nor is JSON 
> meant to do this. STON is one (rather elegant if I may say so) answer to this 
> problem. Your example would be encoded as
> 
> [ 
>  PngAttachement { #url:'http://example.com/random-name.txt', 
> #fileName:'chapter-one.txt' },
>  TxtAttachement { #url:'http://example.com/random-name.png', 
> #fileName:'image.png' }
> ]

About STON usage, I wonder how it works in terms of a data structure evolution. 
Currently I use JSON format to store a data permanently. The data are supposed 
to be accesible for a long time (years). I am pretty sure that the protocol 
will evolve and we will end up with several JSON versions. I think that having 
different JSON mapping schemes will allow to map old JSON versions to a latest 
object structure (or to several different versions if necessary).

For the example above, think of the scenario that PngAttachment does not exist 
anymore. In a simple scenario there could be an ImageAttachment class instead 
with the same instance variables. In a more complex scenario, there could be a 
AttachmentTwo { #type: AttachmentTwoType { … instances … }, #path: 
AttachmentTwoPath { … instances … } }. 

I can use JSON mappings that transform the old JSON version to the new class 
structure. I am not sure if STON is that flexible. 
What do you think? Do I miss something? 

> 
> Still, the question of how to do this kind of dynamic decoding is an 
> interesting challenge. Please update to the following commits:
> 
> ===
> Name: Neo-JSON-Core-SvenVanCaekenberghe.44
> Author: SvenVanCaekenberghe
> Time: 22 September 2017, 3:24:51.679449 pm
> UUID: f1ebeade-2816-0d00-a04c-ae370e598362
> Ancestors: Neo-JSON-Core-SvenVanCaekenberghe.42
> 
> Implement some missing code in NeoJSONCustomMapping (the writing part of 
> #listOfElementSchema: #listOfType:andElementSchema: #mapWithValueSchema:)
> 
> Add NeoJSONStreamingWriter>>#writeElementAs:
> 
> Add NeoJSONMappingTests>>#testDynamicTyping as an example
> ===
> Name: Neo-JSON-Tests-SvenVanCaekenberghe.41
> Author: SvenVanCaekenberghe
> Time: 22 September 2017, 3:25:09.881494 pm
> UUID: a9a900e0-2816-0d00-a04d-a6fb0e598362
> Ancestors: Neo-JSON-Tests-SvenVanCaekenberghe.39
> 
> Implement some missing code in NeoJSONCustomMapping (the writing part of 
> #listOfElementSchema: #listOfType:andElementSchema: #mapWithValueSchema:)
> 
> Add NeoJSONStreamingWriter>>#writeElementAs:
> 
> Add NeoJSONMappingTests>>#testDynamicTyping as an example
> ===
> 
> Now you can do as follows:
> 
> NeoJSONMappingTests>>#testDynamicTyping
>  | data customMapping json result |
>  data := Array with: #foo->1 with: #(foo 2).
>  "The idea is to map a key value combination as either a classic association 
> or a simple pair, 
>   using key & value properties as well as a type property to distinguish 
> between the two"
>  customMapping := [ :mapper |
>mapper 
>  for: #AssocOrPair customDo: [ :mapping |
>mapping
>  encoder: [ :x | 
>x isArray 
>  ifTrue: [ { #type->#pair. #key->x first. #value->x second } 
> asDictionary ] 
>  ifFalse: [ { #type->#assoc. #key->x key. #value->x value } 
> asDictionary ] ];
>  decoder: [ :x |
>(x at: #type) = #pair
>  ifTrue: [ Array with: (x at: #key) with: (x at: #value) ]
>  ifFalse: [ (x at: #key) -> (x at: #value)] ] ];
>  for: #ArrayOfAssocOrPair customDo: [ :mapping |
>mapping listOfType: Array andElementSchema: #AssocOrPair ];
>  yourself ].
>  json := String streamContents: [ :out |
>(customMapping value: (NeoJSONWriter on: out)) nextPut: data as: 
> #ArrayOfAssocOrPair ].
>  result := (customMapping value: (NeoJSONReader on: json readStream)) nextAs: 
> #ArrayOfAssocOrPair.
>  self assert: result equals: data
> 
> Everything is virtual (not implemented as methods on actual classes) which 
> makes the example self contained and non intrusive, but not very elegant, nor 
> object oriented or extendable. Also, it is not as efficient as NeoJSON 
> mapping was designed for, since it creates intermediate structures.

Nice example. If #decoder: and #encoder: are used, is it still possible to use 
inner mappings? For example in my previous example, one instance variable is a 
ZnUrl instance that is stored as a String. Can I say “use ZnUrl mapping in for 
this intermediate structure”? Well, I understand that I can hard code it 
directly in the the #decoder: and #encoder: messages using #asZnUrl and 
#asString messages. I am thinking about a more complicated structur

Re: [Pharo-users] How to find if a method is being executed in a given process

2017-09-25 Thread Stephane Ducasse
This is exactly my usecase, i need to remove code that may be called
by a method on the stack - and i know exactly which method. However my
base hypothesis is that it is in an already running process (maybe a
loop) and that part i cannot change. Is there an existing Pharo
implementation of MethodWrappers ?

How can you remove a method if it may be called?

Stef

On Mon, Sep 25, 2017 at 4:16 PM, Marcus Denker  wrote:
>
> On 25 Sep 2017, at 15:19, Steven Costiou  wrote:
>
>
>
> Le 2017-09-25 12:21, jtuc...@objektfabrik.de wrote :
>
> Steven
>
> You could add use a semaphore if changing code is an option.
> We once used MethodWrappers in VAST to answer a similar question regarding
> whether a body of code can be removed from a system.
>
> Joachim
>
>
>
> This is exactly my usecase, i need to remove code that may be called by a
> method on the stack - and i know exactly which method. However my base
> hypothesis is that it is in an already running process (maybe a loop) and
> that part i cannot change. Is there an existing Pharo implementation of
> MethodWrappers ?
>
>
>
> I do not know how MethodWrappers would solve this.. in the end, they do
> something very similar to what happens when you put a MetaLink on a
> methodNode…
> (we do not wrap but recompile the AST instead, wrapping is used if the
> method has a primitive, though).
>
> You can even see MetaLinks as “just” a generalisation of methodWrappers to
> any AST node.
>
> So you would have the same problem: the wrapper is used *for the next call*.
>
> Marcus



Re: [Pharo-users] How to find if a method is being executed in a given process

2017-09-25 Thread Marcus Denker

> On 25 Sep 2017, at 17:47, Stephane Ducasse  wrote:
> 
> This is exactly my usecase, i need to remove code that may be called
> by a method on the stack - and i know exactly which method.

I do not understand.

I think we are all not in sync and talk about four different things.

> However my
> base hypothesis is that it is in an already running process (maybe a
> loop) and that part i cannot change. Is there an existing Pharo
> implementation of MethodWrappers ?
> 

Yes, method wrappers exist. But as much as I know they do not solve the problem 
of
on-stack replacement.

Else, whatever you do with MethodWrappers you should be able to do with 
MetaLinks on 
the methodNode. (I would be interested in cases where this is not possible).

Marcus




Re: [Pharo-users] How to find if a method is being executed in a given process

2017-09-25 Thread Steven Costiou
Le 2017-09-25 17:47, Stephane Ducasse a écrit :

> This is exactly my usecase, i need to remove code that may be called
> by a method on the stack - and i know exactly which method. However my
> base hypothesis is that it is in an already running process (maybe a
> loop) and that part i cannot change. Is there an existing Pharo
> implementation of MethodWrappers ?
> 
> How can you remove a method if it may be called?
> 
> Stef

Lets say i have the following method: 

m 

^self m1 

I have dynamically changed the code of m for a specific object o by the
following: 

m 

self m2. 

^self m1 

m2 is behavior that is dynamically added to the object o. 

If i want to revert the object o to its original behavior, that will
change back m and remove m2, i must be sure that the changed m is not on
the stack, else it could still call m2 that no longer exists. 

Actually i tried Ben's suggestion, and it works. I just ask the process
to run until the method i target is popped out of the stack and then i
can remoev my code. 

Steven. 

[Pharo-users] How to include DeployUtils in a Configuration?

2017-09-25 Thread Hernán Morales Durand
I am trying to include DeployUtils in a ConfigurationOf (Pharo 6.1)
following instructions at:

https://github.com/fstephany/DeployUtils

If I include the dependency as suggested:

spec baseline: 'DeployUtils' with: [
spec repository: 'github://fstephany/DeployUtils/repository'].

then when I load the configuration I get:

Error: Unable to resolve project package for 'DeployUtils'. It is
likely that that the configuration referencing this project will not
validate properly (see MetacelloToolBox
class>>validateConfiguration:).

If I include the dependency as:

spec
project: 'DeployUtils' with: [
spec
className: #DeployUtils;
versionString: 'baseline';
repository: 'github://fstephany/DeployUtils/repository' ];

Then I get DU multiple missing dependencies:

This package depends on the following classes:
  StringStreamLogger
  Log
  StdoutStreamLogger
You must resolve these dependencies before you will be able to load
these definitions:
  DUFileLogger
  DUFileLogger>>#withFileLocator:
  DUFileLogger>>#addLogHook:
  DUFileLogger>>#defaultFormatter
  DUFileLogger>>#defaultStream
  DUFileLogger>>#fileLocator:
  DUStdoutStreamLogger
  DUStdoutStreamLogger>>#addLogHook:
  Log>>#debug:tag:
  Log>>#info:tag:
  Log>>#warning:tag:

And finally a MNU with

#loader: was sent to nil

(also when I try to inspect I got a #gtInspectorProjectsIn: was sent to nil)
Any ideas?
Cheers,

Hernán



Re: [Pharo-users] Testing a Unicode Character's Category

2017-09-25 Thread Richard Sargent
Andrew P. Black wrote
> The Pharo image has a table of Unicode Character Categories in a class
> variable GeneralCategory of class Unicode.  But there do not seem to be
> many methods to interpret this data.  For example, while there is a method
> 
>   Unicode class >> #isDigit: aCharacter
> 
> that checks if the Unicode category of aCharacter is Nd, and 
> 
>   Unicode class >> #isLetter: aCharacter
> 
> that checks if aCharacter is in one of the letter categories, there does
> not seem to be a general way of asking “what is the category of this
> character”.
> 
> I want to check if a character is a mathematical symbol, that is, if it is
> in the Unicode Category Sm.  What’s the right way of doing this?
> Would it be reasonable to add a method Unicode class >> #category:
> aCharacter that answers one of the 29 category symbols #Cc to #Zs?  Or
> “is” methods for each category?
> 
> Andrew

Hi Andrew,

I would recommend the guideline that "special codes" should be modelled as
private to the class (or family of classes) in question and answers to
questions like "is it a mathematical symbol" be answered by a method with
almost that exact name.

There may be a justification for exposing the code itself, but not for
directly interpreting the meaning of the code. A contrived example would be
to answer a Dictionary grouping each UnicodeCharacterData instance by its
General Category so that one could manipulate the set of related instances
in some manner. As I said, contrived.

Also, the existing methods provide a template (pattern?) for future such
methods.




--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] Usability issues with Calypso

2017-09-25 Thread Sean P. DeNigris
Denis Kudriashov wrote
> In Calypso you should not create protocols with star. In method editor
> status bar there is explicit checkbox "extension"  to specify external
> package for the method.
> We should move away from star convention and work directly with packages.
> Calypso gives you the tools for this.

Aha! Cool and agreed. However, when I check the box on an existing method
and select a package, the method doesn't seem to move to the over package :/



-
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] Bloc Space within a Space

2017-09-25 Thread Sean P. DeNigris
Stephane Ducasse-3 wrote
> with multiple little worlds showing windows inside and to control all
> the events.

That sounds awesome! Smalltalk is at heart a simulation bench and the
inability to simulate the IDE itself has felt like heavy shackles when I
tried to implement several possible-blue-plane ideas in the past. If we had
a UI where we could sub out and control all the events/time/cursor, we would
have something unimaginably cool :)



-
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



[Pharo-users] Need help with NeoJSON reader definition

2017-09-25 Thread jtuc...@objektfabrik.de

Hi there,


I am having a hard time configuring a NeoJSONReader for a JSON file like 
this:


{
    "Paging": { someStuff
   },
    "ErrorMessage": null,
    "ErrorCode": 0,
    "Data": [
    {object1},

        {object2}

        ]

}


Where I want to ignore everything but the list named "Data". (Of course 
I'll have to take a look at ErrorMessages later, but one step after the 
other...).


I've tried several combinations of mappers and always end up with 
NoeJSON parsing Exceptions. I semm unable to see the obvious.


In The end I just want to only use the contents of the Data list and map 
each entry in there to some smalltalk object. I was successful with 
other structures and lists, but this time I am unable to see the forest 
among all those trees.


Any hints?


Joachim