Earlier quoted context omitted.
If your language has you type more because it has a static ype system then it's just poor at inferring types and/or it's syntax has you write out things that it could infer anyway. You may have to write types in C# from time to time, but often you don't have to: // This an array of integers. var x = new[]{1, 2, 3}; // This is a list of integers. var y = x.ToList(); // This is an anonymous type. var pet = new { Age =…
Inferring types is cool, if it doesn't create bugs. But it does. Its not a lot of work to just say it outright, and it can save your life.
CShell: A simple, yet powerful, C# scripting IDE
51–60 of 90 posts
Re: CShell: A simple, yet powerful, C# scripting IDE
#52Earlier quoted context omitted.
If your language has you type more because it has a static ype system then it's just poor at inferring types and/or it's syntax has you write out things that it could infer anyway. You may have to write types in C# from time to time, but often you don't have to: // This an array of integers. var x = new[]{1, 2, 3}; // This is a list of integers. var y = x.ToList(); // This is an anonymous type. var pet = new { Age =…
Inferring types is cool, if it doesn't create bugs. But it does. Its not a lot of work to just say it outright, and it can save your life.
Re: CShell: A simple, yet powerful, C# scripting IDE
#53When I try the Tutorial.csx, I can't get this snippet to work:
static class MyMath { public static long Fibonacci(long n) { //anything more than 48 will result in a stack overflow. if (n >= 48) throw new ArgumentException("Enter a number less than 48"); if (n == 0) return 0; if (n == 1) return 1; return Fibonacci(n - 1) + Fibonacci(n - 2); } }
// Now the method can be called like so: MyMath.Fibonacci(12);
It gives me : "(14,0): error CS1525: Unexpected symbol `MyMath'" in the repl, anyone knows why?
Re: CShell: A simple, yet powerful, C# scripting IDE
#54Earlier quoted context omitted.
Inferring types is cool, if it doesn't create bugs. But it does. Its not a lot of work to just say it outright, and it can save your life.
Can you elaborate? I'm not sure what you mean.
Re: CShell: A simple, yet powerful, C# scripting IDE
#55Earlier quoted context omitted.
Can you elaborate? I'm not sure what you mean.
Unexpected conversions can add bugs. Putting a string into a table that was implicitely integer - if your string doesn't start with digits it gets converted to zero. Was that what you intended? Did you think the table would hold a string?
Re: CShell: A simple, yet powerful, C# scripting IDE
#56public static class Foo { public static string B; } Foo.B = "5";
doesn't work either ("Unexpected symbol `Foo'").
I really don't get how to use that thing.
Re: CShell: A simple, yet powerful, C# scripting IDE
#57First of all, let me say this is something I've wanted for a while, so good job and thank you to the author. When I try the Tutorial.csx, I can't get this snippet to work: static class MyMath { public static long Fibonacci(long n) { //anything more than 48 will result in a stack overflow. if (n >= 48) throw new ArgumentException("Enter a number less than 48"); if (n == 0) return 0; if (n == 1) return 1; return Fibona…
Re: CShell: A simple, yet powerful, C# scripting IDE
#58Earlier quoted context omitted.
Unexpected conversions can add bugs. Putting a string into a table that was implicitely integer - if your string doesn't start with digits it gets converted to zero. Was that what you intended? Did you think the table would hold a string?
So it's not actually the type inference that's the problem -- it's developers who carelessly define implicit conversion operators on their classes.
Re: CShell: A simple, yet powerful, C# scripting IDE
#59Earlier quoted context omitted.
Can you elaborate? I'm not sure what you mean.
Unexpected conversions can add bugs. Putting a string into a table that was implicitely integer - if your string doesn't start with digits it gets converted to zero. Was that what you intended? Did you think the table would hold a string?
Re: CShell: A simple, yet powerful, C# scripting IDE
#60I'm getting "(35,0): error CS1525: Unexpected symbol `static'" trying to run Tutorial.csx (when MyMath is uncommented), whether running the entire script or just the class and the MyMath.Fibonacci call alone, by Run Selection (then it's "Unexpected symbol `MyMath'"). public static class Foo { public static string B; } Foo.B = "5"; doesn't work either ("Unexpected symbol `Foo'"). I really don't get how to use that thi…
Error 2014-05-09 15:42:45.8796 AppBootstrapper Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.Collections.ArrayList.get_Item(Int32 index) at CShell.Modules.Repl.Controls.CSRepl.ShowPreviousCommand() in c:\Users\luke\Dev\GitHub\CShell\Src\CShell\Modules\Repl\Controls\CSRepl.xaml.cs:line 241 at CShell.Modules.Repl.Controls.CSRepl.TextAreaOnPreviewKeyDown(Object sender, KeyEventArgs keyEventArgs) in c:\Users\luke\Dev\GitHub\CShell\Src\CShell\Modules\Repl\Controls\CSRepl.xaml.cs:line 377 at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey) at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled) at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers) at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)