Bug 26386 - Support loose functions
Summary: Support loose functions
Status: NEW
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2015-01-24 19:11 UTC by Stone
Modified: 2015-01-27 12:59 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 26386 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Stone 2015-01-24 19:11:35 UTC
This is a question not a bug regarding the csharp REPL.

Currently Mono.CSharp does not support loose functions but supports variables with function expressions. 

So this is valid:
Func<int, int, int> Foo = delegate (int a, int b) { return a + b; }

but not:
public int Foo(int a, int b) { return a + b; }

Loose functions would be something I would be interested in implementing. Loose functions are supported by Roslyn and would be great if Mono could support this as well.

So before I start looking into this I need to ask if this is something that is desired (part of the mono roadmap) and if you would you accept a PR that implemented this feature? 

Because this is not currently supported I suspect that adding this feature is not straight forward.  So I would also be interested to know where the main issues lie.

Comment 1 Marek Safar 2015-01-27 12:59:22 UTC
We'd accept such PR if you don't break any existing tests. I think someone tried to implement it already but it didn't go anywhere. I can see there will most likely be issues at grammar level in our parser.