Re: [rust-dev] Virtual fn is a bad idea

2014-03-11 Thread Haoyi Li
FWIW, C# requires that you mark overridable functions *virtual*, the
opposite of Java where you need to mark un-overridable functions *final*.
The Scala community is coming to the same conclusion that unrestricted
overriding is pretty dangerous. It's similar to monkey patching, with all
the convenience and danger it provides.


On Tue, Mar 11, 2014 at 2:15 PM, Maciej Piechotka uzytkown...@gmail.comwrote:

 On Tue, 2014-03-11 at 13:44 -0700, Patrick Walton wrote:
  On 3/11/14 1:42 PM, Daniel Micay wrote:
   Existing object systems like COM, DOM and gobject are worth looking at,
   but Rust shouldn't bend over backwards to support them. They're legacy
   technologies and while interacting with them is important, I don't
 think
   it should result in any extra complexity being added to Rust.
 
  We have to support the technologies that are in use in a pleasant way,
  or else Rust will not be practical. Regardless of your feelings about
  existing OO systems, Rust has to support them well.
 
  So far nobody in this thread has demonstrated an understanding of the
  constraints here. Traits are simply not sufficient to model the DOM, for
  example.
 
  Patrick
 
 

 Could you elaborate on DOM? I saw it referred a few times but I haven't
 seen any details. I wrote simple bindings to libxml2 dom
 (https://github.com/uzytkownik/xml-rs - warning - I wrote it while I was
 learning ruby) and I don't think there was a problem of OO - main
 problem was mapping libxml memory management and rust's one [I gave up
 with namespaces but with native rust dom implementation it would be
 possible to solve in nicer way]. Of course - I might've been at too
 early stage.

 Regarding existing OO systems - Haskell interops with few of them (like
 gtk+ for example) using typeclasses without problems I know of. Possible
 next stage would be modelling the same hierarchy but since most systems
 use multiple inheritance in one form or another it would not help much.

 Best regards

 ___
 Rust-dev mailing list
 Rust-dev@mozilla.org
 https://mail.mozilla.org/listinfo/rust-dev


___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


Re: [rust-dev] let mut - var

2014-01-29 Thread Haoyi Li
Sorry to parachute in to the conversation (long time lurker) but just to
add to the statistics, the Scala standard library and compiler has
11875:54575 ratio of mutable (var) vs immutable (val) declarations, so it
seems to match pretty well with the numbers you guys are seeing in the rust
libraries.


On Thu, Jan 30, 2014 at 12:18 PM, Samuel Williams 
space.ship.travel...@gmail.com wrote:

 Jason, I haven't actually written any rust code (yet). I'm just commenting
 based on reading other people's code - it was something I noticed in a few
 examples - it might have been bad form (assuming that mutable data are the
 Wrong Thing?). I brought it up because I wasn't sure if it was something
 that had been considered. It made the code I was reading look a bit clunky
 (which appears to be the desired result).


 On 30 January 2014 17:07, Jason Fager jfa...@gmail.com wrote:

 You *should* get sick of writing 'let mut' all over the place, not
 just b/c of the syntax but b/c you're using mutable variables all over the
 place.  Casual mutability kills maintainability.

 Affordances matter.  I'm convinced that the reason Option.unwrap() is
 used so frequently is b/c it's the shortest method name and requires the
 fewest explicit decisions, and so is the easiest thing to reach for.  If it
 were unwrap_or_fail(reason), forcing you to both type more and to think
 about a fail message, unwrap_or and unwrap_or_else wouldn't look as
 difficult in comparison.  or and or_else would be even better, or
 'do' syntax now that the keyword's free again.

 Make the Right Thing the easy thing, and don't put effort into making the
 Wrong Thing as easy or easier.



 On Wednesday, January 29, 2014, Samuel Williams 
 space.ship.travel...@gmail.com wrote:

 I agree that it is syntactic salt and that the design is to discourage
 mutability. I actually appreciate that point as a programmer.

 w.r.t. this specific issue: I think what concerns me is that it is quite
 a high burden for new programmers (I teach COSC1xx courses to new students
 so I have some idea about the level of new programmers). For example, you
 need to know more detail about what is going on - new programmers would
 find that difficult as it is one more concept to overflow their heads.

 Adding var as a keyword identically maps to new programmer's
 expectations from JavaScript. Writing a program entirely using var
 wouldn't cause any problems right? But, could be optimised more
 (potentially) if using let for immutable parts.

 Anyway, I'm not convinced either way, I'm not sure I see the entire
 picture yet. But, if I was writing code, I'd certainly get sick of writing
 let mut over and over again - and looking at existing rust examples, that
 certainly seems like the norm..






 On 30 January 2014 15:59, Samuel Williams 
 space.ship.travel...@gmail.com wrote:

 I guess the main gain would be less typing of what seems to be a
 reasonably common sequence, and the formalisation of a particular semantic
 pattern which makes it easier to recognise the code when you visually
 scanning it.


 On 30 January 2014 15:50, Kevin Ballard ke...@sb.org wrote:

 On Jan 29, 2014, at 6:43 PM, Brian Anderson bander...@mozilla.com
 wrote:

  On 01/29/2014 06:35 PM, Patrick Walton wrote:
  On 1/29/14 6:34 PM, Samuel Williams wrote:
  Perhaps this has been considered already, but when I'm reading
 rust code
  let mut just seems to stick out all over the place. Why not add a
  var keyword that does the same thing? I think there are lots of
 good
  and bad reasons to do this or not do it, but I just wanted to
 propose
  the idea and see what other people are thinking.
 
  `let` takes a pattern. `mut` is a modifier on variables in a
 pattern. It is reasonable to write `let (x, mut y) = ...`, `let (mut x, y)
 = ...`, `let (mut x, mut y) = ...`, and so forth.
 
  Having a special var syntax would defeat this orthogonality.
 
  `var` could potentially just be special-case sugar for `let mut`.

 To what end? Users still need to know about `mut` for all the other
 uses of patterns. This would reserve a new keyword and appear to duplicate
 functionality for no gain.

 -Kevin
 ___
 Rust-dev mailing list
 Rust-dev@mozilla.org
 https://mail.mozilla.org/listinfo/rust-dev





 ___
 Rust-dev mailing list
 Rust-dev@mozilla.org
 https://mail.mozilla.org/listinfo/rust-dev


___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev


Re: [rust-dev] Abandoning segmented stacks in Rust

2013-11-05 Thread Haoyi Li
C# Async/Await is distinct from segmented stacks because they store the
enclosed variables as heap objects rather than on the stack; that means it
goes through the same malloc/garbage collector as any other heap objects
you create. It's purely a compiler fiction to let you write code that
'looks' like it's stack allocating variables.




On Tue, Nov 5, 2013 at 1:42 PM, Brian Anderson bander...@mozilla.comwrote:

 On 11/04/2013 09:21 PM, Oren Ben-Kiki wrote:

 Note that as memory becomes cheaper and larger there will be more
 pressure on 64-bit OS-es to switch to large pages; the number of pages
 needed to map several GBs of memory today is already getting out of hand,
 causing TLB misses to become a performance issue in some cases - imagine a
 system with 0.xTBs of memory and it becomes ludicrous.

 So playing tricks with MMU and lazy page loading may not work as well as
 it does with today's the small 4K page size. Of course, Rust is hardly the
 only platform that would be affected :-) and ideally, it would be possible
 to have more flexibility than today in choosing which page sizes are used
 where in the program's address space... but it remains to be seen how
 exactly this would play out.

 Just a point to keep in mind...


 Thanks! That is an interesting point that I hadn't thought about.

 ___
 Rust-dev mailing list
 Rust-dev@mozilla.org
 https://mail.mozilla.org/listinfo/rust-dev

___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev