Re: [go-nuts] Re: Rule-swarm attacks can outdo deep reasoning

2018-10-05 Thread Lucio De Re
Good catch. I must have first coded that back before I fully accepted
the "exit the loop as early as possible" philosophy.

I have no better excuse :-).

Lucio.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Rule-swarm attacks can outdo deep reasoning

2018-10-04 Thread Ian Denhardt
Quoting Lucio (2018-10-04 23:19:48)
>On Tuesday, 2 October 2018 15:21:08 UTC+2, Eric Raymond wrote:
>
>Is promised in the thread on pytogo, I have blogged on the general
>topic of rule-swarm attacks in the domain of language transformation.
>[1]http://esr.ibiblio.org/?p=8153
>
>I'm no pragmatist, I bow to ESR for shining that light. But here's my
>own, tiny contribution to sledge-hammering human-readable dates into
>internal Go format:
> //  Function ParseDate() attempts all known legal date formats
> 79� � //
> 80� � //More formats can be added as the need arises.  It would not 
> be t
> he
> 81� � //first time.
> 82� � //
> 83� � func ParseDate(s string) (d time.Time, err error) {
> 84� �   s = strings.Trim(s, " \t")
> 85� �   if d, err = time.Parse("Mon, 02 Jan 2006 15:04:05 -0700 
> (MST)",
> s); err == nil {
> 86� �   return d, nil
> 87� �   }
> 88� �   if d, err = time.Parse("Mon, 02 Jan 2006 15:04:05 -0700", s); 
> er
> r == nil {
> 89� �   return d, nil
> 90� �   }
> 91� �   if d, err = time.Parse("Mon, 2 Jan 2006 15:04:05 -0700 
> (MST)", s
> ); err == nil {
> 92� �   return d, nil
> 93� �   }
> 94� �   if d, err = time.Parse("Mon, 2 Jan 2006 15:04:05 -0700", s); 
> err
>  == nil {
> 95� �   return d, nil
> 96� �   }
> 97� �   if d, err = time.Parse("02 Jan 2006 15:04:05 -0700", s); err 
> ==
> nil {
> 98� �   return d, nil
> 99� �   }
>100� �   if d, err = time.Parse("2 Jan 2006 15:04:05 -0700", s); err 
> == n
> il {
>101� �   return d, nil
>102� �   }
>103� �   return d, err
>104� � }
>105� �
>106� �
>
>Not pretty, I grant. This one was in the context of email headers
>(RFC-822 and later) parsing, I just haven't read enough Go code to know
>if there is a better way. The curious thing is that in my
>life-before-Go, I have frequently wanted something like this, but it
>took what I presume (perhaps unfairly) to be Rob Pike's date parsing to
>give it shape.
>Lucio.

The low-hanging fruit in the "pretty" department I see is:

formats := []string{
"Mon, 02 Jan 2006 15:04:05 -0700 (MST)",
"Mon, 02 Jan 2006 15:04:05 -0700",
...
}
for _, format  := range formats {
if d, err = time.Parse(format), s); err = nil {
return d, nil
}
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Rule-swarm attacks can outdo deep reasoning

2018-10-04 Thread Lucio


On Tuesday, 2 October 2018 15:21:08 UTC+2, Eric Raymond wrote:
>
> Is promised in the thread on pytogo, I have blogged on the general topic 
> of rule-swarm attacks in the domain of language transformation.
>
> http://esr.ibiblio.org/?p=8153
>

There's so much in your blog post I would like to address, I'm not sure 
where I would find it comfortable to do that, Eric.

One thing about comments is special to Go. I have no doubt that eventually 
a syntax for Go comments that sacrifices immediate readability for a more 
careful description will eventually mature and take over. That is of course 
the role of hypertext and gofmt has already planted the seed with godoc is 
fertilising it.

The other issue that strikes me is that it should be possible to link 
rules, individually and/or in swarms of various sizes, to the target AST 
analyser and demand a sensible response from it. Such a feedback loop would 
eliminate at least some false outcomes, be they positive or negative.

But, as I like to stress, I'm a rank amateur, deeply steeped in that very 
pervasive Western Philosophy that seeks meaning in every atom of the 
Universe, every pattern. It is hard to sacrifice the aesthetic needs of 
that mindset, because that results in nullifying the long-term value of 
one's actions and causes the future to become irrelevant. And, in passing, 
I think the idea that the distant future is important enough to sacrifice 
some of the present to it, is a Judeo-Christian, rather than a Hellenic 
principle (although, in Sting's lyrics "the Russians love their children, 
too)".

Lucio.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Rule-swarm attacks can outdo deep reasoning

2018-10-04 Thread Lucio


On Tuesday, 2 October 2018 15:21:08 UTC+2, Eric Raymond wrote:
>
> Is promised in the thread on pytogo, I have blogged on the general topic 
> of rule-swarm attacks in the domain of language transformation.
>
> http://esr.ibiblio.org/?p=8153
>

I'm no pragmatist, I bow to ESR for shining that light. But here's my own, 
tiny contribution to sledge-hammering human-readable dates into internal Go 
format:

//  Function ParseDate() attempts all known legal date formats79  //
80  //  More formats can be added as the need arises.  It would not be the
81  //first time.82  //83  func ParseDate(s string) (d time.Time, 
err error) {84  s = strings.Trim(s, " \t")85if d, err = 
time.Parse("Mon, 02 Jan 2006 15:04:05 -0700 (MST)", s); err == nil {86  
return d, nil87 }88 if d, err = 
time.Parse("Mon, 02 Jan 2006 15:04:05 -0700", s); err == nil {89
return d, nil90 }91 if d, err = time.Parse("Mon, 2 Jan 
2006 15:04:05 -0700 (MST)", s); err == nil {92   return d, nil
93 }94 if d, err = time.Parse("Mon, 2 Jan 2006 15:04:05 -0700", 
s); err == nil {95 return d, nil96 }97 
if d, err = time.Parse("02 Jan 2006 15:04:05 -0700", s); err == nil {98 
return d, nil99 }   100 if d, err = time.Parse("2 Jan 
2006 15:04:05 -0700", s); err == nil {   101  return d, nil   102   
  }   103 return d, err   104  }   105 106  


Not pretty, I grant. This one was in the context of email headers (RFC-822 
and later) parsing, I just haven't read enough Go code to know if there is 
a better way. The curious thing is that in my life-before-Go, I have 
frequently wanted something like this, but it took what I presume (perhaps 
unfairly) to be Rob Pike's date parsing to give it shape.

Lucio.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Rule-swarm attacks can outdo deep reasoning

2018-10-04 Thread Eric Raymond


On Wednesday, October 3, 2018 at 4:05:30 PM UTC-4, Michael Ellis wrote:
>
> Nice writeup. Thanks.  Based on today's xkcd , I 
> think Randall Munroe must have read it, too ;-)
>

Seems likely.  Randall and I have been friendly.
 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Rule-swarm attacks can outdo deep reasoning

2018-10-03 Thread Michael Ellis
Nice writeup. Thanks.  Based on today's xkcd , I 
think Randall Munroe must have read it, too ;-)

On Tuesday, October 2, 2018 at 9:21:08 AM UTC-4, Eric Raymond wrote:
>
> Is promised in the thread on pytogo, I have blogged on the general topic 
> of rule-swarm attacks in the domain of language transformation.
>
> http://esr.ibiblio.org/?p=8153
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Rule-swarm attacks can outdo deep reasoning

2018-10-02 Thread David Collier-Brown
In a previous life, two co-op students did the B-to-C conversion suite for 
Honeywell as a suite of transformations for use by developers. Ten years 
later, my team and I did porting tools that provided humans with advice, 
some of which was trivially sufficient, others were merely advisory.  

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.