ycl

Check-in [2a4ab146f2]
Login

Check-in [2a4ab146f2]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:var simplify
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2a4ab146f242698917d3b9d1ad945610c11caada
User & Date: pooryorick 2018-04-20 17:52:35.288
Context
2018-04-20
18:22
dir move file puts to dir puts check-in: e2edf7fd81 user: pooryorick tags: trunk
17:52
var simplify check-in: 2a4ab146f2 user: pooryorick tags: trunk
17:51
continued development check-in: ff0c3f427f user: pooryorick tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to packages/var/lib/methods.tcl.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#! /bin/env tclsh

package require {ycl proc}
namespace import [yclprefix]::proc::method

package require {ycl var}

namespace export *

apply [list {} {
	method $.locate {*}[[yclprefix] var $.locate {*}[set [namespace parent]::sov::$.locate]]

	method $ {*}[[yclprefix] var $ {{varname args} {} {}} {[$_ $.locate $varname]} \
		{set ${_}::$varname $val} {[set ${_}::$varname]}] 

	method $.exists {*}[[yclprefix] var $.exists {{varname args} {} {}} \
		{[list $_ $ $varname]} {$_ $ $varname}] 

} [namespace current]]





<
<
<
<
<
<
<
<
<
<
<
<
<
<
1
2
3
4
5














#! /bin/env tclsh

package require {ycl proc}
namespace import [yclprefix]::proc::method















Changes to packages/var/lib/upmethods.tcl.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#! /bin/env tclsh

package require {ycl proc}
namespace import [yclprefix]::proc::upmethod
namespace export *

upmethod $.locate {*}[[yclprefix] var $.locate {varname {} {}} {${_}::$varname} \
	{[namespace which $x] eq {}} {$path $.locate $varname}]

upmethod $ {*}[[yclprefix] var $ {{varname args} {} {}} {[$_ $.locate $varname]} \
	{set ${_}::$varname $val} {[set ${_}::$varname]}] 

upmethod $.exists {*}[[yclprefix] var $.exists {{varname args} {} {}} \
	{[list $_ $ $varname]} {$_ $ $varname}] 






<
<
<
<
<
<
<
<
1
2
3
4
5
6








#! /bin/env tclsh

package require {ycl proc}
namespace import [yclprefix]::proc::upmethod
namespace export *









Changes to packages/var/lib/var.tcl.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /bin/env tclsh

package require {ycl knit}
namespace import [yclprefix]::knit::knit

package require {ycl proc}
namespace import [yclprefix]::proc::method

variable methods {$ $.exists $.locate}

namespace export *

knit $.locate {argspec thisvarname objmissing nextlocate} {
	list #{argspec} {
		if {[info exists #{thisvarname}]} {
			return #{thisvarname}
		} else {
			set paths [lmap x [$_ eval namespace path] {
				#This previously used [namespace which $x], but that seemed wrong
				if {#{objmissing}} continue else {set x}
			}]
			foreach path $paths {
				if {[catch {#{nextlocate}} eres eopts]} {
					return -code error -opts $eopts $eres
				} else {
					return $eres
				}
			}
			return -code error --errorcode [
				list VIAVAR LOOKUP VARNAME $varname] \
					[list {can't read} $varname {no such variable}]
					
		}
	}
}

namespace eval sov {
	variable $.locate {{varname {} {}} {${_}::$varname} {[namespace which $x] eq {}} {$path $.locate $varname}}
}


knit $ {argspec locate set get} {
	list #{argspec} {
		switch [llength $args] {
			0 {
				return [set #{locate}]
			} 
			1 {
				lassign $args val
				#{set}
				return #{get}
			}
			default {
				error [list {wrong # args}]
			}
		}
	}
}


knit $.exists {argspec catchget set} {
	list #{argspec}  {
		if {[catch #{catchget}]} {
			if {[llength $args]} {
				lassign $args val
				#{set} [lindex $args[set args {}] 0]
				return 1
			} else {
				return 0
			}
		} else {
			return 1
		}
	}
}




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

1
2










































































3
#! /bin/env tclsh












































































Changes to packages/var/pkgIndex.tcl.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /bin/env tclsh

package ifneeded {ycl var} 0.1 [list apply {{dir} {
	package require {ycl package}
	[yclprefix]::package::source var $dir/lib/var.tcl 
	package provide {ycl var} 0.1
}} $dir]

package ifneeded {ycl var methods} 0.1 [list apply {{dir} {
	package require {ycl package}
	package require {ycl var}
	[yclprefix]::package::source var::methods $dir/lib/methods.tcl 
	package provide {ycl var methods} 0.1
}} $dir]

package ifneeded {ycl var upmethods} 0.1 [list apply {{dir} {
	package require {ycl package}
	package require {ycl var}
	[yclprefix]::package::source var::upmethods $dir/lib/upmethods.tcl 
	package provide {ycl var upmethods} 0.1
}} $dir]








<
<
<
<
<
<







1
2
3
4
5
6
7
8






9
10
11
12
13
14
15
#! /bin/env tclsh

package ifneeded {ycl var} 0.1 [list apply {{dir} {
	package require {ycl package}
	[yclprefix]::package::source var $dir/lib/var.tcl 
	package provide {ycl var} 0.1
}} $dir]








package ifneeded {ycl var upmethods} 0.1 [list apply {{dir} {
	package require {ycl package}
	package require {ycl var}
	[yclprefix]::package::source var::upmethods $dir/lib/upmethods.tcl 
	package provide {ycl var upmethods} 0.1
}} $dir]