从纷乱创造简洁,一句就够了!

-
最新日志
最新评论
- 路人丙 发表于《IE9前瞻:终于支持圆角了?》
- 王涛 发表于《IE9前瞻:终于支持圆角了?》
- 潇洒 发表于《传说中的C#娘出世了?》
- leeo 发表于《对待IE6应该更绝一些》
- blackli 发表于《猜猜这段代码写的是什么?》
存档页
分类
功能
MJS中原来有个东西叫做CPOC
它是一组函数
耗费了将近2000行代码
充斥着caller、eval。
防止客户乱写属性、方法
阻止了很多操作
提高了系统稳定性
和“纯粹性”
但是,我还是删除了
因为它太慢
影响性能
更重要的是,它无视了很多用户和开发者的想法
有些修改需求,不对吗?
限制会消失的,对吧。
虽然,有些人会反对:
“那是内核啊,修改内核会出事情的”
但是,内核就不能修改了吗?
CPOC,被废弃了
垃圾收集中。
(注:用了很多双关,Li**Yu*(not lychees)等人可以直接理解)
(理解不了可以重新展开CPOC这个缩写,有一个是“小词”)
using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace Parabola_closure_ex { public delegate double MathFunction(double x); class Program { static MathFunction para(double a, double b, double c) { return x => a * x * x + b * x + c; } static void Main(string[] args) { MathFunction f; f = para(1, 2, 3); Console.WriteLine(f(3)); Console.ReadKey(); } } }
var para = function(a, b, c) { return function(x) { return a * x * x + b * x + c; } };
//main var f = para(1, 2, 3); alert(f(3));
IL:
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 2:0:0:0
}
.assembly Parabola_closure_ex
{
.custom instance void [mscorlib]System.Reflection.AssemblyCopyrightAttribute::.ctor(string) = ( 01 00 1B 43 6F 70 79 72 69 67 68 74 20 C2 A9 20 // ...Copyright ..
4D 69 63 72 6F 73 6F 66 74 20 32 30 30 39 00 00 ) // Microsoft 2009..
.custom instance void [mscorlib]System.Reflection.AssemblyTitleAttribute::.ctor(string) = ( 01 00 13 50 61 72 61 62 6F 6C 61 5F 63 6C 6F 73 // ...Parabola_clos
75 72 65 5F 65 78 00 00 ) // ure_ex..
.custom instance void [mscorlib]System.Reflection.AssemblyDescriptionAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyConfigurationAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyCompanyAttribute::.ctor(string) = ( 01 00 09 4D 69 63 72 6F 73 6F 66 74 00 00 ) // ...Microsoft..
.custom instance void [mscorlib]System.Reflection.AssemblyProductAttribute::.ctor(string) = ( 01 00 13 50 61 72 61 62 6F 6C 61 5F 63 6C 6F 73 // ...Parabola_clos
75 72 65 5F 65 78 00 00 ) // ure_ex..
.custom instance void [mscorlib]System.Runtime.InteropServices.GuidAttribute::.ctor(string) = ( 01 00 24 37 37 38 64 38 37 32 35 2D 36 36 64 38 // ..$778d8725-66d8
2D 34 66 36 33 2D 38 39 66 39 2D 35 63 31 61 62 // -4f63-89f9-5c1ab
30 31 65 66 66 66 66 00 00 ) // 01effff..
.custom instance void [mscorlib]System.Reflection.AssemblyTrademarkAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.InteropServices.ComVisibleAttribute::.ctor(bool) = ( 01 00 00 00 00 )
// --- 下列自定义属性会自动添加,不要取消注释 -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
.custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = ( 01 00 07 31 2E 30 2E 30 2E 30 00 00 ) // ...1.0.0.0..
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.hash algorithm 0x00008004
.ver 1:0:0:0
}
.module Parabola_closure_ex.exe
// MVID: {7393789F-0AC1-4607-976B-989DAF5B969E}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x0000000000890000
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi sealed Parabola_closure_ex.MathFunction
extends [mscorlib]System.MulticastDelegate
{
.method public hidebysig specialname rtspecialname
instance void .ctor(object 'object',
native int 'method') runtime managed
{
} // end of method MathFunction::.ctor
.method public hidebysig newslot virtual
instance float64 Invoke(float64 x) runtime managed
{
} // end of method MathFunction::Invoke
.method public hidebysig newslot virtual
instance class [mscorlib]System.IAsyncResult
BeginInvoke(float64 x,
class [mscorlib]System.AsyncCallback callback,
object 'object') runtime managed
{
} // end of method MathFunction::BeginInvoke
.method public hidebysig newslot virtual
instance float64 EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
{
} // end of method MathFunction::EndInvoke
} // end of class Parabola_closure_ex.MathFunction
.class private auto ansi beforefieldinit Parabola_closure_ex.Program
extends [mscorlib]System.Object
{
.class auto ansi sealed nested private beforefieldinit '<>c__DisplayClass1'
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field public float64 a
.field public float64 b
.field public float64 c
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// 代码大小 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method '<>c__DisplayClass1'::.ctor
.method public hidebysig instance float64
'
b__0'(float64 x) cil managed
{
// 代码大小 31 (0x1f)
.maxstack 3
.locals init ([0] float64 CS$1$0000)
IL_0000: ldarg.0
IL_0001: ldfld float64 Parabola_closure_ex.Program/'<>c__DisplayClass1'::a
IL_0006: ldarg.1
IL_0007: mul
IL_0008: ldarg.1
IL_0009: mul
IL_000a: ldarg.0
IL_000b: ldfld float64 Parabola_closure_ex.Program/'<>c__DisplayClass1'::b
IL_0010: ldarg.1
IL_0011: mul
IL_0012: add
IL_0013: ldarg.0
IL_0014: ldfld float64 Parabola_closure_ex.Program/'<>c__DisplayClass1'::c
IL_0019: add
IL_001a: stloc.0
IL_001b: br.s IL_001d
IL_001d: ldloc.0
IL_001e: ret
} // end of method '<>c__DisplayClass1'::'
b__0'
} // end of class '<>c__DisplayClass1'
.method private hidebysig static class Parabola_closure_ex.MathFunction
para(float64 a,
float64 b,
float64 c) cil managed
{
// 代码大小 45 (0x2d)
.maxstack 3
.locals init ([0] class Parabola_closure_ex.Program/'<>c__DisplayClass1' 'CS$<>8__locals2',
[1] class Parabola_closure_ex.MathFunction CS$1$0000)
IL_0000: newobj instance void Parabola_closure_ex.Program/'<>c__DisplayClass1'::.ctor()
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldarg.0
IL_0008: stfld float64 Parabola_closure_ex.Program/'<>c__DisplayClass1'::a
IL_000d: ldloc.0
IL_000e: ldarg.1
IL_000f: stfld float64 Parabola_closure_ex.Program/'<>c__DisplayClass1'::b
IL_0014: ldloc.0
IL_0015: ldarg.2
IL_0016: stfld float64 Parabola_closure_ex.Program/'<>c__DisplayClass1'::c
IL_001b: nop
IL_001c: ldloc.0
IL_001d: ldftn instance float64 Parabola_closure_ex.Program/'<>c__DisplayClass1'::'
b__0'(float64)
IL_0023: newobj instance void Parabola_closure_ex.MathFunction::.ctor(object,
native int)
IL_0028: stloc.1
IL_0029: br.s IL_002b
IL_002b: ldloc.1
IL_002c: ret
} // end of method Program::para
.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
// 代码大小 62 (0x3e)
.maxstack 3
.locals init ([0] class Parabola_closure_ex.MathFunction f)
IL_0000: nop
IL_0001: ldc.r8 1.
IL_000a: ldc.r8 2.
IL_0013: ldc.r8 3.
IL_001c: call class Parabola_closure_ex.MathFunction Parabola_closure_ex.Program::para(float64,
float64,
float64)
IL_0021: stloc.0
IL_0022: ldloc.0
IL_0023: ldc.r8 3.
IL_002c: callvirt instance float64 Parabola_closure_ex.MathFunction::Invoke(float64)
IL_0031: call void [mscorlib]System.Console::WriteLine(float64)
IL_0036: nop
IL_0037: call valuetype [mscorlib]System.ConsoleKeyInfo [mscorlib]System.Console::ReadKey()
IL_003c: pop
IL_003d: ret
} // end of method Program::Main
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// 代码大小 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
} // end of method Program::.ctor
} // end of class Parabola_closure_ex.Program
请注意那个“<>c__DisplayClass1”,闭包就这样看到啦!
<ol class="tab"> <li><a class="tabItem" href="#"><span>111111</span><a><div class="tabPage">content 1</div></li> <li><a class="tabItem" href="#"><span>222222</span></a><div class="tabPage">content 2</div></li> <li class="current"><a class="tabItem" href="#"><span>333333333333333333333</span><a><div class="tabPage"> <p>...... </p> </div> </li> </ol>
<script type="text/javascript:contextual"> page.output.print(context.tag()); </script>
只是给type加了一点东西。
$init(function() { var request = world.assembly.getXHR(); //请求对象
// Load var load = function(name, compose) { try { if (request.overrideMimeType) request.overrideMimeType('text/javascript'); request.open('GET', name, false); request.setRequestHeader("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT"); request.send(null); if (request.status == 200 || request.status == 204 || request.status == 0) { var t = request.responseText; return (t); }; } catch (e) { return '' } };
var i = 0, script, scripts = document.getElementsByTagName('script'); while ((script = scripts[i++])) { if (/:contextual$/.test(script.type)) { if (script.src) { (new Function("script,context", load(script.src))).call($(script.parentNode), $(script), $(script.parentNode)); } else { (new Function("script,context", script.innerHTML)).call($(script.parentNode), $(script), $(script.parentNode)); } } } });
好玩的在这里。(今天晚上svn,dandy里面就可以看到啦~)
最早的想法来自:http://james.padolsey.com/javascript/contextual-script-tags/
使用方法和原生的canvas一样,getContext,接着画图。非IE也可以使用(速度和原生的一样快……晕哦……)。需要silverlight 3环境。
这是微软放出的图,边框终于有圆角了,还带反锯齿(顺便BS一下Chrome,没有反锯齿……)
还有这张图:
574/578,可以预见,我们终于可以用querySelectorAll代替$()。
这里有个视频介绍IE9新的js引擎,看样子似乎用了预编译。不过E文……听不懂的说。
还有流言称IE9会使用显卡加速,不过用显卡的似乎他不是第一个,我带开safari 4后GTX295就叫……
minasan~~~ 期待吧。
连接:
http://blogs.msdn.com/ie/archive/2009/11/18/an-early-look-at-ie9-for-developers.aspx
http://blog.csdn.net/WinGeek/archive/2009/11/19/4832467.aspx
http://www.neowin.net/news/live/09/11/18/microsoft-demos-internet-explorer-9
http://www.css3.info/microsoft-announces-css3-support-for-internet-explorer-9-ie9/
看到连接1博文回复有这个“问卷”:
拭目以待吧!(诸位可以先猜猜,不过我猜VBS应该不会out——毕竟IE设计的DOM是通用跨语言接口。当然全部重写DOM模型除外。VML out概率甚高,而<canvas>嘛……可能会in,毕竟用的是DX,说不定来个增强搞搞<sence>,从此扔掉Unity 3D……)
交互式题目:x是一个数组,下标从1到n,其中只有一个数不同于其它。给你函数compare(a,b) a,b:Array of [1..n],比较x[a[1]]+x[a[2]]+……和x[b[1]]+x[b[2]]+……的结果,返回-1,0或1。现在请编写程序在最少的compare调用次数内找出x中那个独一无二的数的下标。(你只能使用compare,x是私有属性)
这就是经典的称球问题。对于n=12且已知“异常”数大于标准数的情况,可以写出下面的算法:
var get4 = function(a, b, c, d) { return (compare([a, b], [c, d]) > 0) ? (compare([a], [b]) > 0 ? a : b) : (compare([c], [d]) > 0 ? c : d); }; var getItem = function() { switch (compare([1, 2, 3, 4], [5, 6, 7, 8])) { case 0: get4(9, 10, 11, 12); case 1: get4(1, 2, 3, 4); case -1: get4(5, 6, 7, 8); } };
这里有详细算法。(不过他的和我的要求还不太一样——他在球放在天平上之后又向上加球,而我的要求相当于球放上天平以后,看到天平倾斜/平衡后必须立即拿走。)
这里有一些简化/加强版本,诸君可以一试:
var delegator = me.meetingPerson; me.acceptWishRequest(delegator,function(ea){ var w = ea.wish; RGO.acceptWishRequest({ content:w, acceptor:me, delegator:delegator },function(ea){ if(ea.status === 200){ me.addImplementTask(delegator,w); } }); });