[Pharo-users] More info & examples on MAAdaptiveModel ?

2019-03-27 Thread Albrecht Baur via Pharo-users
--- Begin Message ---

Hi all,

I am looking for more info or usage examples of MAAdaptiveModel.

So far I found the following good resources:

 * The masters thesis of Lukas Renggli and the impl. of Pier:
   
http://sdmeta.gforge.inria.fr/Teaching/Lille/0910-MetaModelisation/Magritte/Reng06a.pdf
 * In the package Magritte-Tests-Model: The test MAAdaptiveModelTest

Could someone point me to more resources on MAAdaptiveModel if there are 
any?


Especially the topic searching / building search indexes on 
MAAdaptiveModel data stored e.g. in mongodb as voyage root would be 
helpful. -> How is the performance when searching on MAAdaptiveModel 
values with and without index ?


Hints would be nice!

Albrecht


--- End Message ---


Re: [Pharo-users] how to convert this with a stream

2019-03-27 Thread Richard O'Keefe
"I have a SortedCollection of Teams.  Now I need to convert *it*
 to a line like ...".
Well, no.  You need to convert *each team* separately to such a
line.  So something like
  aStream nextPutAll: '...header line...'; cr.
  mySortedTeams do: [:eachTeam |
 -write a formatted line describing eachTeam to aStream].

Now it gets interesting.  Whose responsibility is it to write
a representation of a Team instance to a stream?  Should it be
done by the Team instance, or should it be done outside?

Question 1: is there obviously one and only one format, or do
you think that in a more realistic example there might be more
than one way to print a Team object?  I concluded that there
might be many different ways to do it.  (I personally dislike
putting variable length fields on the left.)

Question 2: *Can* it be done from the outside or *must* it be
done inside?  Is there any information in the printed representation
that the caller cannot ask the team object for?  In this case, all
of the information is available through Team's public interface.

Question 3: Should Teams and printing be *coupled*?  Should a Team
know about details like the dividing line between columns?  In this
case, I decided that putting the formatting code inside the Team
object was highly undesirable coupling.

Question 4: Is it *possible* for a Team object to do the formatting
without knowing about all the other Teams in the collection?  In this
case, the specification is rather vague.  It seemed to me that all
the numeric columns should be the same width and should be wide enough
to hold the largest number with a space on each side.

In answer to question 4, my Tournament code contains
   w := mySortedTeams inject: 1 into: [:acc :team |
(team matchCount max: team points) printString size max: acc].
and this clearly requires knowledge of all the teams, so it makes no
sense to put it in Team. (Of course, if the column widths are fixed,
this argument fails, but such a choice makes no sense for large problems.)

So now you need something like
   aStream nextPutAll: team name; space: 30 - team name size.
and then a numeric value might be written as
   aStream nextPutAll: ' | '; space: w - team points printString size;
 print: team points.

Please do not use << . Historically, << had no meaning in Smalltalk.
In some Smalltalks it means leftwards bit shift.  It is just too
confusing.  (In a shell, you would use > for output, not <<, which
is used for a kind of input.)  It is really weird to use s << String cr
instead of s cr.  So idomatic Smalltalk would be
  s nextPutAll: t name; cr.

Why are you writing to (an output stream over) an Array?
Surely you want a String?
But in any case, I would split this into two methods:

  printTeams: teams on: aStream
-- print heading --
-- print each team --
  printTeamsAsString: teams
^String streamContents: [:s | self printTeams: teams on:s]


On Wed, 27 Mar 2019 at 07:12, Roelof Wobben  wrote:

> Hello,
>
> I have a SortedCollection of teams.
>
> Now I need to convert this to a line like this :
>
> 'Allegoric Alaskans |  1 |  1 |  0 |  0 |  3'
>
> I tried it with this :
>
> outcome := Array
>  streamContents: [ :s |
>  TeamStatusSorted
>  do: [ :each |
>  s << each name.
>  s << String cr ] ].
>  ^ outcome
>
>
> or String streamContents but it will not give me the right answer,
> So please some hints how I can make this work.
>
> Roelof
>
>
>


Re: [Pharo-users] how to convert this with a stream

2019-03-27 Thread Roelof Wobben

  
  
@Richard , thanks a lot
  
  I was already using that way and finnaly I solved it
  
  here is my code :  https://github.com/RoelofWobben/Tournament-
  
  Someone who can give feedback to the way I solved it
  
  Roelof
  
  
  
  
  Op 27-3-2019 om 13:06 schreef Richard O'Keefe:


  
  
"I have a
  SortedCollection of Teams.  Now I need to convert *it*
 to a line like ...".
Well, no.  You need to
  convert *each team* separately to such a
line.  So something
  like
  aStream nextPutAll:
  '...header line...'; cr.
  mySortedTeams do:
  [:eachTeam |
     -write a
  formatted line describing eachTeam to aStream].


Now it gets
  interesting.  Whose responsibility is it to write
a representation of a
  Team instance to a stream?  Should it be
done by the Team
  instance, or should it be done outside?


Question 1: is there
  obviously one and only one format, or do
you think that in a
  more realistic example there might be more
than one way to print
  a Team object?  I concluded that there
might be many
  different ways to do it.  (I personally dislike
putting variable
  length fields on the left.)


Question 2: *Can* it
  be done from the outside or *must* it be
done inside?  Is there
  any information in the printed representation
that the caller cannot
  ask the team object for?  In this case, all
of the information is
  available through Team's public interface.


Question 3: Should
  Teams and printing be *coupled*?  Should a Team
know about details
  like the dividing line between columns?  In this
case, I decided that
  putting the formatting code inside the Team
object was highly
  undesirable coupling.


Question 4: Is it
  *possible* for a Team object to do the formatting
without knowing about
  all the other Teams in the collection?  In this
case, the
  specification is rather vague.  It seemed to me that all
the numeric columns
  should be the same width and should be wide enough
to hold the largest
  number with a space on each side.


In answer to question
  4, my Tournament code contains
   w := mySortedTeams
  inject: 1 into: [:acc :team |
    (team matchCount
  max: team points) printString size max: acc].
and this clearly
  requires knowledge of all the teams, so it makes no
sense to put it in
  Team. (Of course, if the column widths are fixed,
this argument fails,
  but such a choice makes no sense for large problems.)


So now you need
  something like
   aStream nextPutAll:
  team name; space: 30 - team name size.
and then a numeric
  value might be written as
   aStream nextPutAll:
  ' | '; space: w - team points printString size;
     print: team
  points.


Please do not use
  << . Historically, << had no meaning in Smalltalk.
In some Smalltalks it
  means leftwards bit shift.  It is just too
confusing.  (In a
  shell, you would use > for output, not <<, which
is used for a kind of
  input.)  It is really weird to use s << String cr
instead of s cr.  So
  idomatic Smalltalk would be
  s nextPutAll: t
  name; cr.


Why are you writing to
  (an output stream over) an Array?
  Surely you want a String?
But in any case, I
  would split this into two methods:


  printTeams: teams
  on: aStream
    -- print heading
  --
    -- print each team
  --
  printTeamsAsString:
  teams
    ^String
  streamContents: [:s | self printTeams: teams on:s]


  
  
  
On Wed, 27 Mar 2019 at 07:12,
  Roelof Wobben  wrote:

Hello,
  
  I have a SortedCollection of teams.
  
  Now I need to convert this to a line like this :
  
  'Allegoric Alaskans |  1 |  1 |  0 |  0 |  3'
  
  I tried it with this :
  
  outcome := Array
       streamContents: [ :s |
           TeamStatusSorted
               do: [ :each |
                   s << each name.
 

Re: [Pharo-users] Smalltalk CI - anyone have any luck excluding tests?

2019-03-27 Thread Guillermo Polito
Hi Tim,

I got something like what you describe that working for pillar and
OSSubprocess, but putting different tests in different packages, not tags.

https://github.com/pillar-markup/pillar
https://github.com/pharo-contributions/OSSubprocess

On Tue, Mar 12, 2019 at 6:00 PM Tim Mackinnon  wrote:

> FYI: Just bumping this - but on investigation it looks like the Pharo
> support for Tags breaks in Smalltalk CI - so top level packages with
> similar names (e.g. Exercism and ExercismWIP) all seem to get included by
> the include directive of ‘Exercism’ (with no wildcard).
>
> This is in an issue: https://github.com/hpi-swa/smalltalkCI/issues/417
>
> It does mean that many of you might be running more tests than you need
> to, and it might explain strange build failures if you are trying to use
> exclude.
>
> At some point I will have a go at fixing this, if someone doesn’t beat me
> to it.
>
> Tim
>
> On 6 Mar 2019, at 09:10, Tim Mackinnon  wrote:
>
> As part of Exercism we have to show our language track can build and run
> tests - and they use Travis - so, pretty awesome we have that tooling.
>
> So it was pretty straightforward t hook in - and there are enough examples
> around to support the docs for the .yml and .ston file - however I hit an
> issue with the inclusion and exclusion of test files. I put an issue on
> SmalltalkCI - but its sat there for 8days (
> https://github.com/hpi-swa/smalltalkCI/issues/417) so I’m wondering if
> anyone has experience with this?
>
> Essentially if I include my other packages ‘ExercismDev’ and
> ‘ExercismTools’  (see sample below - I’ve removed them from the include
> list) then some of my tests run twice (I believe because the exclude of
> #AllExercismTests doesn’t work). I also have some environmental tests that
> need improving to run more generically (Submit/Download) and again those
> don’t seem to be excluded.
>
> It’s like “exclude" simply doesn’t work - but I would think this would be
> reported more widely if this was the case. So maybe I don’t understand the
> overlap of include/exclude etc. Anyone have any thoughts?
>
> Tim
>
> SmalltalkCISpec {
>   #loading : [
> SCIMetacelloLoadSpec {
>   #baseline : 'Exercism',
>   #directory : 'dev/src',
>   #load : [ 'dev' ],
>
>   #platforms : [ #pharo ]
> }
>   ],
>
>   #testing : {
> #include : {
>   #packages : [ 'Exercism' ]
> },
> #exclude : {
>   #classes : [ #AllExercismTests, #ExercismTest, #ExercismSubmitTest, 
> #ExercismDownloadTest ],
>   #packages : [ 'ExercismWIP']
> }
>   }
> }
>
>
>
>

-- 



Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

French National Center for Scientific Research - *http://www.cnrs.fr
*


*Web:* *http://guillep.github.io* 

*Phone: *+33 06 52 70 66 13


[Pharo-users] how to -- buffered read / write to stdio

2019-03-27 Thread Isaac Gouy via Pharo-users
--- Begin Message ---
>From — "Pharo 7 file streams guideline"

https://github.com/pavel-krivanek/pharoMaterials/blob/master/Filestreams.MD


I have some ideas like —

   in := ZnFastLineReader on:   (ZnCharacterReadStream on: Stdio stdin).   
out := ZnBufferedWriteStream on: 
  (ZnCharacterWriteStream on: Stdio stdout).


What would be faster / better / more Pharo ways to do buffered reads and 
buffered writes to stdio ?

--- End Message ---


Re: [Pharo-users] More info & examples on MAAdaptiveModel ?

2019-03-27 Thread Sean P. DeNigris
Pharo Smalltalk Users mailing list wrote
> I am looking for more info or usage examples of MAAdaptiveModel.

The Nabble mirror site provides convenient search across many Smalltalk MLs.
I don't know if any of these help, but there are several hits:
http://forum.world.st/template/NamlServlet.jtp?macro=search_page&node=1294792&query=MAAdaptiveModel



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



Re: [Pharo-users] how to -- buffered read / write to stdio

2019-03-27 Thread Alistair Grant
Hi Isaac,

On Wed, 27 Mar 2019 at 17:18, Isaac Gouy via Pharo-users
 wrote:
>
> From — "Pharo 7 file streams guideline"
>
> https://github.com/pavel-krivanek/pharoMaterials/blob/master/Filestreams.MD
>
>
> I have some ideas like —
>
>in := ZnFastLineReader on:   (ZnCharacterReadStream on: Stdio stdin).  
>  out := ZnBufferedWriteStream on:
>   (ZnCharacterWriteStream on: Stdio stdout).
>
>
> What would be faster / better / more Pharo ways to do buffered reads and 
> buffered writes to stdio ?

This is heading in the right direction.  The buffered wrappers are
normally placed on the underlying binary stream, and then wrapped with
the encoder / decoder.  Follow through FileReference>>writeStream and
FileReference>>readStream to see how it is done for files.

in := ZnFastLineReader on: (ZnCharacterReadStream on:
(ZnBufferedReadStream on: Stdio stdin)).

out := ZnCharacterWriteStream on: (ZnBufferedWriteStream on: Stdio stdout).

Note that if you're doing terminal IO you'll need to handle stdin differently.

If you're writing to a terminal on Linux / MacOS you'll need to use
LFs instead of Pharo's standard CRs, so it may be worthwhile adding
ZnNewLineWriterStream on: out.

HTH,
Alistair



[Pharo-users] Resolving DNS in-image

2019-03-27 Thread Holger Freyther
Norbert and me looked at using DNS for service discovery and ran into some of 
the limitations of the NetNameResolver[1]. In the end I created an initial DNS 
implementation in Pharo called Paleo-DNS[2] to overcome these.

DNS is a protocol we use every day but rarely think of. There is an active IETF 
community that is evolving the protocol and finding new usages (service 
discovery is one of them).

In DNS there are different types of resource records (RR). The most commonly 
used ones in a client ("stub") are "A" for IPv4 addresses, "" for IPv6 
addresses, "CNAME" for aliases, "SRV" records. So far only support for "A" 
records was implemented.

So if you are curious about DNS then this is a great opportunity to add your 
favorite RR implementation to it and send a PR. There are probably 20+ of them 
to go. ;)


Query example using DNS-over-TLS (DoT) to Google Public DNS

PaleoDNSTLSTransport new
destAddress: #[8 8 4 4] port: 853;
timeout: 2 seconds;
query: (PaleoDNSQuery new
   transactionId: (SharedRandom globalGenerator 
nextInt: 65535);
addQuestion: (PaleoRRA new rr_name: 
'pharo.org.');
addAdditional: (PaleoRROpt new udpPayloadSize: 
4096))


[1] It's blocking on Unix, on Mac only one look-up may occur at a time and it 
returns exactly one address. There is also no IPv6 support.

[2] https://github.com/zecke/paleo-dns