|
Re: two things about defs: msg#00430lang.scala
Burak, A-ha.. I got it. So function is an instance of a method, lambda-abstractions (closures) produces functions and so on. However, wouldn't one concept be enough? Should the user know that the function is an instantiated method? In my case it conflicted with my common sense. -- WBR, Alexander Sergeev. On Sat, 27 Jan 2007 23:14:48 +0100, Burak Emir wrote: > Alexander, > >> >> Well, I always thought that method is a function that is associated to >> particular object. In this case, it's not associated to any object since >> I'm writing definition in toplevel (or maybe it's associated to some >> artificial one). > > > mhm, that's right. the interpreter puts this stuff in an object. here's more > info http://article.gmane.org/gmane.comp.lang.scala/3242/match=interpreter > > >> It seems I still don't understand the difference between methods and >> functions, could you tell me? > > > Sure! here's a post that has lots of examples > http://article.gmane.org/gmane.comp.lang.scala/3101/match=closure > > cheers, > B > >> > BTW I think you could have omitted the & in definition of xxx, given >> > that you gave a function type in the annotation. >> > >> > hope this helps, >> > Burak >> >> -- WBR, Alexander Sergeev. >> >> > On 1/27/07, Alexander Sergeev <as.beta@xxxxxxxxx> wrote: >> >> >> >> I've posted one of these features into buglist, another one is probably >> >> waiting it's turn. >> >> >> >> First one: >> >> >> >> scala> def sum(a: Int)(b: Int): Int = a+b sum: >> >> (scala.Int)(scala.Int)scala.Int >> >> >> >> scala> val sum2 = (x: int) => (y: int) => x + y sum2: (scala.Int) => >> >> (scala.Int) => scala.Int = <function> >> >> >> >> Could interpreter print out only one version of type output? Personally >> >> I think the best one is: scala.Int => scala.Int => scala.Int = >> >> <function> >> >> >> >> Second one: >> >> >> >> scala> def yyy = &(List(1,2) foldLeft) yyy: => (scala.Nothing) => >> >> ((scala.Nothing, scala.Int) => scala.Nothing) => scala.Nothing >> >> >> >> scala> def xxx[a] : (a => ((a, int) => a) => a) = &(List(1,2) >> >> foldLeft) xxx: [a](a) => ((a, scala.Int) => a) => a >> >> >> >> Is it possible for type inference mechanism to abstract over >> >> scala.Nothing when deciding type for yyy? It would be great to have xxx >> >> automatically. Though, this problem may be undecidable. >> >> >> >> -- WBR, Alexander Sergeev. >> >> >> >> >> > >> > >> >> > > |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Another nit: 00430, Tony Morris |
|---|---|
| Next by Date: | RE: Another nit: 00430, Ted Neward |
| Previous by Thread: | Re: two things about defsi: 00430, Burak Emir |
| Next by Thread: | Re: two things about defs: 00430, Lex Spoon |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |