F# Interactive does not support namespace keyword when the code read from standard input
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
Please provide a succinct description of the issue.
It seems that "namespace" keyword is causing errors when the script is read from standard input. This also makes harder to use the F# Interactive functionality from an IDE (Monodevelop/Xamarin Studio/Visual Studio) with properly designed F# code (The F# Component Design Guidelines -> 3.2 Object, Type and Module Design -> Do use namespaces or modules to contain your types and modules) because it will only work when part of the code/script is selected instead of a simple send script or select all and send (this is really time consuming with a single file that contains multiple namespace).
#### Repro steps
```fsharp
namespace Namespace1
module Module1 =
let x = 1
```
Provide the steps required to reproduce the problem
1. start fsharpi console (the same problem exists in Monodevelop 7.0.1 (flatpak) with packaged mono & fsharp)
2. copy & paste the code
3. "error FS0010: Unexpected keyword 'namespace' in interaction"
#### Expected behavior
namespace keyword supported in F# Interactive
Provide a description of the expected behaviour.
The namespace should have the same support that module has in F# Interactive.
#### Actual behavior
```
F# Interactive for F# 4.1
Freely distributed under the Apache 2.0 Open Source License
For help type #help;;
> namespace Namespace1
namespace Namespace1
^^^^^^^^^
/tmp/fsnamespace/stdin(1,1): error FS0010: Unexpected keyword 'namespace' in interaction
```
Provide a description of the actual behaviour observed.
"namespace" keyword is not recognized.
#### Known workarounds
No workaround know yet, as script loading from file does not provide the same functionality.
Provide a description of any known workarounds.
#### Related information
Please note when the script is loaded as file, the namespace functionality works (but prefixed with FSI_xywz). However this is not the same functionality as a F# interactive with standard input, because I have to restart the process every time I make any modification losing all the currently loaded data (which could be large and time consuming) and every calculation based on that data.
```
fsharpi --load:test.fsx
F# Interactive for F# 4.1
Freely distributed under the Apache 2.0 Open Source License
For help type #help;;
[Loading /tmp/fsnamespace/test.fsx]
namespace FSI_0002.Namespace1
val x : int
```
Provide any related information
* Operating system & Branch:
```
NAME="Ubuntu"
VERSION="16.04.2 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.2 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
```
* .NET Runtime, CoreCLR or Mono Version
```
mono --version
Mono JIT compiler version 5.0.1.1 (2017-02/5077205 Thu May 25 09:16:53 UTC 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen (concurrent by default)
```
* Editing Tools (e.g. Visual Studio Version):
1) Monodevelop 7.0.1
2) fsharpi console:
```
Package: fsharp
Version: 4.1.9-0xamarin2+debian7b1
Architecture: all
Maintainer: Debian CLI Applications Team
Installed-Size: 13246
Depends: mono-runtime (>= 3.0~), libfsharp-core4.3-cil (>= 4.1.9), libmono-corlib4.5-cil (>= 4.0.0~alpha1), libmono-system-core4.0-cil (>= 4.0.0~alpha1), libmono-system-io-compression4.0-cil (>= 3.2.1), libmono-system-numerics4.0-cil (>= 1.0), libmono-system-runtime4.0-cil (>= 2.10.1), libmono-system-windows-forms4.0-cil (>= 1.0), libmono-system4.0-cil (>= 4.0.0~alpha1), mono-xbuild (>= 1.0), libmono-compilerservices-symbolwriter4.0-cil, mono-devel (>= 4.0.0~)
Breaks: fsharp-console (<< 3.0.34+dfsg-3)
Replaces: fsharp-console (<< 3.0.34+dfsg-3)
Homepage: http://fsharp.org
Priority: optional
Section: cli-mono
Filename: pool/main/f/fsharp/fsharp_4.1.9-0xamarin2+debian7b1_all.deb
Size: 4015690
SHA256: db332c55da1f2a964dc1129cdb364e0a883c990bbd0ac3157d8a45cd311eecbc
SHA1: 9437237547f98495aa16d6b4dd4390c926a37273
MD5sum: 899dc639142c1ee0a950e3d077e65677
Description-en: functional-first programming language - compiler for the CLI
F# is a multi-paradigm programming language, supporting functional,
imperative, and object-oriented structures.
.
This package contains an F# compiler targeting the CLI runtime.
Description-md5: 3ba7deb8d62724c17dc9096ef7dc8d0c
```
* Links to F# RFCs or entries on https://github.com/fsharp/fslang-suggestions
* Links to performance testing scripts
* Indications of severity
Contributor guide
Assessment
This issue has not been assessed yet.