On Fri, Jan 28, 2011 at 2:05 AM, Bojan Rajkovic <[email protected]> wrote:
>
> On Jan 27, 2011, at 9:52:35PM, Doug Blank wrote:
>
>> It would be great to be able to have C# as one of the languages to use
>> in this educational environment, but until it can address functions
>> and classes, it will be a second-class citizen. Although, it will be a
>> nice step for students to be able to take to see a fully-typed,
>> explicit language---even as it is interpreted.
>>
>> If any one has suggestions about using C# in the educational
>> environment, please let me know.
>>
>> -Doug
>
> If you're willing to fake it, you can define functions as lambdas. It'll be 
> ~= to defining them in a real sense.
>
> Try something like this:
>
>        Action<T> printMe = t => Console.WriteLine (t);
>
> or in the more complex case (retrieving some content from a webserver that 
> always returns GZip [yes, I did run into this while exploring some services 
> via the REPL]):
>
>        Func<string, string> doRequestWithPayload = payload => {
>                var wc = new WebClient ();
>                var data = wc.UploadData ("http://url:port/service";, "POST", 
> Encoding.UTF8.GetBytes (payload));
>                return new StreamReader (new GZipStream (new MemoryStream 
> (data), CompressionMode.Decompress)).ReadToEnd ();
>        }
>
> It works perfectly well in the interpreter. It's not quite a real function 
> definition, but it's close enough for most purposes. Classes on the other 
> hand are a no-go.
>
> —Bojan

Bojan, thanks for the examples! This is nice to know that many things
from C# work in the interpreter. However, these are not the kinds of
complications to show to introductory students. If there is a way to
turn on classes and functions in the compiler, that would be perfect,
and could have an impact in the classroom.

-Doug

>
> _______________________________________________
> Mono-list maillist  -  [email protected]
> http://lists.ximian.com/mailman/listinfo/mono-list
>
_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to