aruslan: (Default)
[personal profile] aruslan
Сижу в четвёртой главе Grokking Nemerle.

Пока не очень понял, как делать функцию, принимающую саму себя в качества аргумента.

То есть типа такого:
module test1
{
	public Main() : void
	{
		def test(cc) // cc - это test и есть.
		{
			()
		}
		test(test);
		
		/*
		def fib_(last1,last2,cur,cc)
		{
			if(cur<=0)
				last2
			else
				cc(last2,last2+last1,cur-1,cc)
		}
		def t = fib_(0,1,5,fib_);
		*/
	}
}


Очевидным образом тип - циклический.
Вывести его невозможно, явно указать - тоже.

Видимо, так просто нельзя, и правильнее использовать порождающие функции.

Буду пробовать.


Update: Можно, конечно, вот так:
	def cc_cast = cc :> int * int * int * object -> int;
	cc_cast(last2,last2+last1,cur-1,cc)

Но не с первого же дня такие злобные хаки...
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

Profile

aruslan: (Default)
aruslan

January 2014

S M T W T F S
   1234
56789 1011
12131415161718
19202122232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Apr. 9th, 2026 21:41
Powered by Dreamwidth Studios