[IronPython] Expression printing in interactive mode

2009-04-29 Thread Seo Sanghyeon
In changeset 42603, a change was made to
IronPython.Hosting.PythonCommandLine.RunOneInteraction,

- SourceUnit su = Language.CreateSnippet(s, stdin,
SourceCodeKind.InteractiveCode);
+ SourceUnit su = Language.CreateSnippet(s, stdin,
(s.Contains(Environment.NewLine))? SourceCodeKind.Statements :
SourceCodeKind.InteractiveCode);

Why is this? It seems to me that s always contains newline, so its net
effect is making all interactive code non-interactive. In Python, this
means no expression is printed in interactive mode.

-- 
Seo Sanghyeon
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Expression printing in interactive mode

2009-04-29 Thread Dino Viehland
There was some internal work going on w/ running a remote console
and it looks like this change was related to that.  In 
Microsoft.Scripting.Hosting.Shell there's a comment added to its 
RunOneInteraction w/ the same change:

/// We check if the code read is an interactive command or statements 
is by checking for NewLine
/// If the code contains NewLine, it's a set of statements (most 
probably from SendToConsole)
/// If the code does not contain a NewLine, it's an interactive command 
typed by the user at the prompt

Looking at the code thought I'm guessing this is totally broken on 
Unix because in ReadStatement we append a newline, with a 
wonderful comment there:

// Note that this does not use Environment.NewLine because some 
languages (eg. Python) only
// recognize \n as a line terminator.
b.Append(\n);

So this just happens to do the right thing on Windows due to the
mismatches between the new lines being used.

I guess we should actually be checking for more than one \n.

 -Original Message-
 From: users-boun...@lists.ironpython.com [mailto:users-
 boun...@lists.ironpython.com] On Behalf Of Seo Sanghyeon
 Sent: Wednesday, April 29, 2009 10:48 AM
 To: Discussion of IronPython
 Subject: [IronPython] Expression printing in interactive mode
 
 In changeset 42603, a change was made to
 IronPython.Hosting.PythonCommandLine.RunOneInteraction,
 
 - SourceUnit su = Language.CreateSnippet(s, stdin,
 SourceCodeKind.InteractiveCode);
 + SourceUnit su = Language.CreateSnippet(s, stdin,
 (s.Contains(Environment.NewLine))? SourceCodeKind.Statements :
 SourceCodeKind.InteractiveCode);
 
 Why is this? It seems to me that s always contains newline, so its net
 effect is making all interactive code non-interactive. In Python, this
 means no expression is printed in interactive mode.
 
 --
 Seo Sanghyeon
 ___
 Users mailing list
 Users@lists.ironpython.com
 http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Expression printing in interactive mode

2009-04-29 Thread Seo Sanghyeon
2009/4/30 Dino Viehland di...@microsoft.com:
 Looking at the code thought I'm guessing this is totally broken on
 Unix because in ReadStatement we append a newline, with a
 wonderful comment there:

                // Note that this does not use Environment.NewLine because 
 some languages (eg. Python) only
                // recognize \n as a line terminator.
                b.Append(\n);

 So this just happens to do the right thing on Windows due to the
 mismatches between the new lines being used.

Ah, mystery solved. So it worked by accident on systems where NewLine != \n...

-- 
Seo Sanghyeon
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Expression printing in interactive mode

2009-04-29 Thread Dino Viehland
Actually now that I think about it more than one \n isn't right 
either because that will change how we parse multi-line statements
at the REPL.  Maybe this should just be undone.

 -Original Message-
 From: users-boun...@lists.ironpython.com [mailto:users-
 boun...@lists.ironpython.com] On Behalf Of Dino Viehland
 Sent: Wednesday, April 29, 2009 11:13 AM
 To: Discussion of IronPython
 Subject: Re: [IronPython] Expression printing in interactive mode
 
 There was some internal work going on w/ running a remote console
 and it looks like this change was related to that.  In
 Microsoft.Scripting.Hosting.Shell there's a comment added to its
 RunOneInteraction w/ the same change:
 
 /// We check if the code read is an interactive command or
 statements is by checking for NewLine
 /// If the code contains NewLine, it's a set of statements
 (most probably from SendToConsole)
 /// If the code does not contain a NewLine, it's an interactive
 command typed by the user at the prompt
 
 Looking at the code thought I'm guessing this is totally broken on
 Unix because in ReadStatement we append a newline, with a
 wonderful comment there:
 
 // Note that this does not use Environment.NewLine
 because some languages (eg. Python) only
 // recognize \n as a line terminator.
 b.Append(\n);
 
 So this just happens to do the right thing on Windows due to the
 mismatches between the new lines being used.
 
 I guess we should actually be checking for more than one \n.
 
  -Original Message-
  From: users-boun...@lists.ironpython.com [mailto:users-
  boun...@lists.ironpython.com] On Behalf Of Seo Sanghyeon
  Sent: Wednesday, April 29, 2009 10:48 AM
  To: Discussion of IronPython
  Subject: [IronPython] Expression printing in interactive mode
 
  In changeset 42603, a change was made to
  IronPython.Hosting.PythonCommandLine.RunOneInteraction,
 
  - SourceUnit su = Language.CreateSnippet(s, stdin,
  SourceCodeKind.InteractiveCode);
  + SourceUnit su = Language.CreateSnippet(s, stdin,
  (s.Contains(Environment.NewLine))? SourceCodeKind.Statements :
  SourceCodeKind.InteractiveCode);
 
  Why is this? It seems to me that s always contains newline, so its
 net
  effect is making all interactive code non-interactive. In Python,
 this
  means no expression is printed in interactive mode.
 
  --
  Seo Sanghyeon
  ___
  Users mailing list
  Users@lists.ironpython.com
  http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
 
 ___
 Users mailing list
 Users@lists.ironpython.com
 http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com